changes to drools rule
Project: http://git-wip-us.apache.org/repos/asf/incubator-stratos/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-stratos/commit/ad402b59 Tree: http://git-wip-us.apache.org/repos/asf/incubator-stratos/tree/ad402b59 Diff: http://git-wip-us.apache.org/repos/asf/incubator-stratos/diff/ad402b59 Branch: refs/heads/master Commit: ad402b59f500233c6d00932650b167622a140a5c Parents: d6a16c1 Author: Nirmal Fernando <[email protected]> Authored: Sun Dec 1 16:27:43 2013 +0530 Committer: Nirmal Fernando <[email protected]> Committed: Sun Dec 1 16:27:43 2013 +0530 ---------------------------------------------------------------------- .../src/test/resources/autoscaler-old.drl | 79 ++++++++++++++++++++ 1 file changed, 79 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/ad402b59/components/org.apache.stratos.autoscaler/src/test/resources/autoscaler-old.drl ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.autoscaler/src/test/resources/autoscaler-old.drl b/components/org.apache.stratos.autoscaler/src/test/resources/autoscaler-old.drl new file mode 100644 index 0000000..7881efe --- /dev/null +++ b/components/org.apache.stratos.autoscaler/src/test/resources/autoscaler-old.drl @@ -0,0 +1,79 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF 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.ClusterContext; +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.deployment.partition.Partition; +import org.apache.stratos.cloud.controller.pojo.MemberContext; + + +global org.apache.stratos.autoscaler.policy.PolicyManager $manager; +global org.apache.stratos.autoscaler.AutoscalerContext $context; +global org.apache.commons.logging.Log log; +global org.apache.stratos.autoscaler.rule.AutoscalerRuleEvaluator $evaluator; +global org.apache.stratos.messaging.domain.topology.Topology $topology; +global java.util.Map partitionCtxts; +global java.lang.String clusterId; + +import function org.apache.stratos.autoscaler.rule.AutoscalerRuleEvaluator.delegateSpawn; +import function org.apache.stratos.autoscaler.rule.AutoscalerRuleEvaluator.delegateTerminate; + +rule "Minimum Rule" +dialect "mvel" + when + $ctxt : PartitionContext () + eval($ctxt.getCurrentMemberCount() < $ctxt.getMinimumMemberCount()) + + then + memberContext = delegateSpawn($ctxt.getPartition(),clusterId); + if(memberContext != null) { + $ctxt.addPendingMember(memberContext); + } + +end + +rule "Terminate Obsoleted Instances" +dialect "mvel" + when + $ctxt : PartitionContext () + eval($ctxt.getObsoletedMembers().size() > 0) + memberId : String() from $ctxt.getObsoletedMembers() + eval($ctxt.removeObsoleteMember(memberId)) + then + delegateTerminate(memberId); +end \ No newline at end of file
