Repository: stratos
Updated Branches:
  refs/heads/4.0.0-grouping 33314ee0a -> e3da9aa8c


meging autoscaler conflicts with master


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

Branch: refs/heads/4.0.0-grouping
Commit: e3da9aa8c0d73203dfc97114788dc996b7b19fb1
Parents: 33314ee
Author: Reka <[email protected]>
Authored: Thu Aug 28 18:39:05 2014 +0530
Committer: Reka <[email protected]>
Committed: Thu Aug 28 18:39:05 2014 +0530

----------------------------------------------------------------------
 .../AutoscalerTopologyEventReceiver.java        | 201 +++++++++----------
 .../autoscaler/monitor/AbstractMonitor.java     |  60 +++---
 .../autoscaler/monitor/ClusterMonitor.java      |  35 +---
 3 files changed, 128 insertions(+), 168 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/e3da9aa8/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.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 8669441..2ac006b 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.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;
-<<<<<<< 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 @@ public class AutoscalerTopologyEventReceiver implements 
Runnable {
 
         });
 
-<<<<<<< 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 @@ public class AutoscalerTopologyEventReceiver implements 
Runnable {
 //            }
 //
 //        });
-=======
+
         topologyEventReceiver.addEventListener(new 
MemberReadyToShutdownEventListener() {
             @Override
             protected void onEvent(Event event) {
@@ -197,7 +196,7 @@ public class AutoscalerTopologyEventReceiver implements 
Runnable {
 
                     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 @@ public class AutoscalerTopologyEventReceiver implements 
Runnable {
 
         });
 
-        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 @@ public class AutoscalerTopologyEventReceiver implements 
Runnable {
                 }
             }
 
-                });
->>>>>>> master
+        });
+
 
         topologyEventReceiver.addEventListener(new 
ClusterRemovedEventListener() {
             @Override
@@ -424,51 +405,51 @@ public class AutoscalerTopologyEventReceiver implements 
Runnable {
         });
 
         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 @@ public class AutoscalerTopologyEventReceiver implements 
Runnable {
 
 
 
-        
+
     }
 
 //    private class LBClusterMonitorAdder implements Runnable {
@@ -675,7 +656,7 @@ public class AutoscalerTopologyEventReceiver implements 
Runnable {
 //    }
 
     @SuppressWarnings("unused")
-       private void runTerminateAllRule(AbstractMonitor monitor) {
+    private void runTerminateAllRule(AbstractMonitor monitor) {
 
         FactHandle terminateAllFactHandle = null;
 
@@ -725,25 +706,25 @@ public class AutoscalerTopologyEventReceiver implements 
Runnable {
 //    }
 
     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()));
             }
         }
+    }
 }

http://git-wip-us.apache.org/repos/asf/stratos/blob/e3da9aa8/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/AbstractMonitor.java
----------------------------------------------------------------------
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 3d5ab2f..3c95c91 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 @@ import java.util.Map;
  * 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<NetworkpartitionId, Network Partition Context>
-       protected Map<String, NetworkPartitionContext> networkPartitionCtxts;
-       protected DeploymentPolicy deploymentPolicy;
-       protected AutoscalePolicy autoscalePolicy;
+    private static final Log log = LogFactory.getLog(AbstractMonitor.class);
+    // Map<NetworkpartitionId, Network Partition Context>
+    protected Map<String, NetworkPartitionContext> networkPartitionCtxts;
+    protected DeploymentPolicy deploymentPolicy;
+    protected AutoscalePolicy autoscalePolicy;
 
 
     protected FactHandle minCheckFactHandle;
@@ -61,12 +61,12 @@ import java.util.Map;
     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 @@ import java.util.Map;
         }
     }
 
-       @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()){

http://git-wip-us.apache.org/repos/asf/stratos/blob/e3da9aa8/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ClusterMonitor.java
----------------------------------------------------------------------
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 2428c6f..a17bf55 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 class ClusterMonitor extends AbstractMonitor {
                 } 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 class ClusterMonitor extends AbstractMonitor {
         }
     }
 
-<<<<<<< HEAD
-    private void monitor() {
-//        if(clusterCtxt != null ) {
-=======
     private boolean isPrimaryMember(MemberContext memberContext){
         Properties props = memberContext.getProperties();
         if (log.isDebugEnabled()) {
@@ -122,8 +118,6 @@ public class ClusterMonitor extends AbstractMonitor {
     }
 
     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 @@ public class ClusterMonitor extends AbstractMonitor {
 
             //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<String> primaryMemberListInPartition = new 
ArrayList<String>();
                 // get active primary members in this partition context
@@ -156,8 +143,7 @@ public class ClusterMonitor extends AbstractMonitor {
                 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 @@ public class ClusterMonitor extends AbstractMonitor {
             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 @@ public class ClusterMonitor extends AbstractMonitor {
     public String toString() {
         return "ClusterMonitor [clusterId=" + clusterId + ", serviceId=" + 
serviceId +
                 ", deploymentPolicy=" + deploymentPolicy + ", 
autoscalePolicy=" + autoscalePolicy +
-<<<<<<< HEAD
-                ", lbReferenceType=" + lbReferenceType + "]";
-=======
                 ", lbReferenceType=" + lbReferenceType +
                 ", hasPrimary=" + hasPrimary + " ]";
->>>>>>> master
     }
 
     public String getLbReferenceType() {

Reply via email to