Repository: stratos
Updated Branches:
  refs/heads/master 5f0ce17cd -> 1fcaecd49


code formatting


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

Branch: refs/heads/master
Commit: 1fcaecd49c7d4cf6cc6b899b14bacc827da1401d
Parents: 5f0ce17
Author: reka <[email protected]>
Authored: Sat Nov 29 16:17:58 2014 +0530
Committer: reka <[email protected]>
Committed: Sat Nov 29 16:17:58 2014 +0530

----------------------------------------------------------------------
 .../autoscaler/monitor/MonitorFactory.java      | 38 +++++++++++---------
 .../monitor/component/ApplicationMonitor.java   | 22 ++++++------
 .../monitor/component/GroupMonitor.java         | 37 +++++++++++++++++--
 3 files changed, 68 insertions(+), 29 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/1fcaecd4/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/MonitorFactory.java
----------------------------------------------------------------------
diff --git 
a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/MonitorFactory.java
 
b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/MonitorFactory.java
index 7015236..d779a5c 100644
--- 
a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/MonitorFactory.java
+++ 
b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/MonitorFactory.java
@@ -53,9 +53,10 @@ public class MonitorFactory {
     /**
      * 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
+     * @param context           Application/Group/Cluster context
+     * @param appId             appId of the application which requires to 
create app monitor
+     * @param parentMonitor     parent of the monitor
+     * @param parentInstanceIds instance ids of the parent instances
      * @return Monitor which can be 
ApplicationMonitor/GroupMonitor/ClusterMonitor
      * @throws TopologyInConsistentException throws while traversing thr 
topology
      * @throws DependencyBuilderException    throws while building dependency 
for app monitor
@@ -63,13 +64,13 @@ public class MonitorFactory {
      * @throws PartitionValidationException  throws while validating the 
partition used in a cluster
      */
     public static Monitor getMonitor(ParentComponentMonitor parentMonitor,
-                                     ApplicationChildContext context, String 
appId, List<String> instanceIds)
-            throws TopologyInConsistentException,
-            DependencyBuilderException, PolicyValidationException, 
PartitionValidationException {
-
+                                     ApplicationChildContext context, String 
appId,
+                                     List<String> parentInstanceIds)
+            throws TopologyInConsistentException, DependencyBuilderException,
+            PolicyValidationException, PartitionValidationException {
         Monitor monitor;
         if (context instanceof GroupChildContext) {
-            monitor = getGroupMonitor(parentMonitor, context, appId, 
instanceIds);
+            monitor = getGroupMonitor(parentMonitor, context, appId, 
parentInstanceIds);
         } else if (context instanceof ClusterChildContext) {
             monitor = getClusterMonitor(parentMonitor, (ClusterChildContext) 
context);
             if (monitor != null) {
@@ -77,7 +78,7 @@ public class MonitorFactory {
                 ClusterChildContext clusterChildCtxt = (ClusterChildContext) 
context;
                 AbstractClusterMonitor clusterMonitor = 
(AbstractClusterMonitor) monitor;
                 // FIXME: passing null as alias for cluster instance 
temporarily. should be removed.
-                createClusterInstance(clusterChildCtxt.getServiceName(), 
clusterMonitor.getClusterId(), null, instanceIds.get(0));
+                createClusterInstance(clusterChildCtxt.getServiceName(), 
clusterMonitor.getClusterId(), null, parentInstanceIds.get(0));
                 
AutoscalerContext.getInstance().addClusterMonitor((AbstractClusterMonitor) 
monitor);
             }
         } else {
@@ -86,7 +87,8 @@ public class MonitorFactory {
         return monitor;
     }
 
-    private static void createClusterInstance(String serviceType, String 
clusterId, String alias, String instanceId) {
+    private static void createClusterInstance(String serviceType, String 
clusterId, String alias,
+                                              String instanceId) {
         CloudControllerClient.getInstance().createClusterInstance(serviceType, 
clusterId, alias, instanceId);
     }
 
@@ -101,7 +103,8 @@ public class MonitorFactory {
      * @throws TopologyInConsistentException throws while traversing thr 
topology
      */
     public static Monitor getGroupMonitor(ParentComponentMonitor parentMonitor,
-                                          ApplicationChildContext context, 
String appId, List<String> instanceIds)
+                                          ApplicationChildContext context, 
String appId,
+                                          List<String> instanceIds)
             throws DependencyBuilderException,
             TopologyInConsistentException {
         GroupMonitor groupMonitor;
@@ -116,7 +119,8 @@ public class MonitorFactory {
             if (parentMonitor != null) {
                 groupMonitor.setParent(parentMonitor);
                 //Setting the dependent behaviour of the monitor
-                if (parentMonitor.hasStartupDependents() || 
(context.hasStartupDependents() && context.hasChild())) {
+                if (parentMonitor.hasStartupDependents() || 
(context.hasStartupDependents() &&
+                                                            
context.hasChild())) {
                     groupMonitor.setHasStartupDependents(true);
                 } else {
                     groupMonitor.setHasStartupDependents(false);
@@ -150,7 +154,7 @@ public class MonitorFactory {
          * If not first app deployment, acquiring read lock to check current 
the status of the group,
          * when the stratos got to restarted
          */
-        if(!initialStartup) {
+        if (!initialStartup) {
             ApplicationHolder.acquireReadLock();
             try {
                 Group group = ApplicationHolder.getApplications().
@@ -212,11 +216,12 @@ public class MonitorFactory {
         }
 
         //If not first app deployment, then calculate the current status of 
the app instance.
-        if(!initialStartup) {
+        if (!initialStartup) {
             ApplicationHolder.acquireReadLock();
             try {
                 Application application = 
ApplicationHolder.getApplications().getApplication(appId);
-                for(ApplicationInstance instance : 
application.getInstanceIdToInstanceContextMap().values()) {
+                for (ApplicationInstance instance :
+                                        
application.getInstanceIdToInstanceContextMap().values()) {
                     //Starting statusChecking to make it sync with the 
Topology in the restart of stratos.
                     ServiceReferenceHolder.getInstance().
                             getGroupStatusProcessorChain().
@@ -274,7 +279,8 @@ public class MonitorFactory {
             clusterMonitor.setId(clusterId);
 
             //setting the startup dependent behaviour of the cluster monitor
-            if (parentMonitor.hasStartupDependents() || 
(context.hasStartupDependents() && context.hasChild())) {
+            if (parentMonitor.hasStartupDependents() || 
(context.hasStartupDependents() &&
+                                                        context.hasChild())) {
                 clusterMonitor.setHasStartupDependents(true);
             } else {
                 clusterMonitor.setHasStartupDependents(false);

http://git-wip-us.apache.org/repos/asf/stratos/blob/1fcaecd4/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/component/ApplicationMonitor.java
----------------------------------------------------------------------
diff --git 
a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/component/ApplicationMonitor.java
 
b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/component/ApplicationMonitor.java
index 63e4a03..58a02a6 100644
--- 
a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/component/ApplicationMonitor.java
+++ 
b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/component/ApplicationMonitor.java
@@ -20,21 +20,21 @@ package org.apache.stratos.autoscaler.monitor.component;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import 
org.apache.stratos.autoscaler.context.partition.network.ApplicationLevelNetworkPartitionContext;
 import org.apache.stratos.autoscaler.applications.ApplicationHolder;
 import org.apache.stratos.autoscaler.applications.topic.ApplicationBuilder;
+import 
org.apache.stratos.autoscaler.context.partition.network.ApplicationLevelNetworkPartitionContext;
 import 
org.apache.stratos.autoscaler.exception.application.DependencyBuilderException;
 import 
org.apache.stratos.autoscaler.exception.application.ParentMonitorNotFoundException;
-import 
org.apache.stratos.autoscaler.exception.policy.PolicyValidationException;
 import 
org.apache.stratos.autoscaler.exception.application.TopologyInConsistentException;
+import 
org.apache.stratos.autoscaler.exception.policy.PolicyValidationException;
 import org.apache.stratos.autoscaler.monitor.Monitor;
-import 
org.apache.stratos.autoscaler.monitor.events.builder.MonitorStatusEventBuilder;
 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.pojo.policy.deployment.partition.network.ApplicationLevelNetworkPartition;
+import 
org.apache.stratos.autoscaler.monitor.events.builder.MonitorStatusEventBuilder;
 import org.apache.stratos.autoscaler.pojo.policy.PolicyManager;
 import org.apache.stratos.autoscaler.pojo.policy.deployment.DeploymentPolicy;
+import 
org.apache.stratos.autoscaler.pojo.policy.deployment.partition.network.ApplicationLevelNetworkPartition;
 import org.apache.stratos.messaging.domain.applications.Application;
 import org.apache.stratos.messaging.domain.applications.ApplicationStatus;
 import org.apache.stratos.messaging.domain.applications.GroupStatus;
@@ -201,7 +201,7 @@ public class ApplicationMonitor extends 
ParentComponentMonitor {
         DeploymentPolicy deploymentPolicy = getDeploymentPolicy(application);
         String instanceId;
         for (ApplicationLevelNetworkPartition networkPartition : 
deploymentPolicy.getApplicationLevelNetworkPartitions()) {
-            if(networkPartition.isActiveByDefault()) {
+            if (networkPartition.isActiveByDefault()) {
                 ApplicationLevelNetworkPartitionContext context =
                         new 
ApplicationLevelNetworkPartitionContext(networkPartition.getId());
                 instanceId = createApplicationInstance(application, 
networkPartition.getId());
@@ -221,11 +221,11 @@ public class ApplicationMonitor extends 
ParentComponentMonitor {
     }
 
     public void createInstanceOnBurstingForApplication() throws 
TopologyInConsistentException,
-                                                                
PolicyValidationException,
-                                                                
ParentMonitorNotFoundException {
+            PolicyValidationException,
+            ParentMonitorNotFoundException {
         //TODO get lock
         Application application = 
ApplicationHolder.getApplications().getApplication(appId);
-        if(application == null) {
+        if (application == null) {
             String msg = "Application cannot be found in the Topology.";
             throw new TopologyInConsistentException(msg);
         }
@@ -234,8 +234,8 @@ public class ApplicationMonitor extends 
ParentComponentMonitor {
         //Find out the inActive network partition
         boolean burstNPFound = false;
         for (ApplicationLevelNetworkPartition networkPartition : 
deploymentPolicy.getApplicationLevelNetworkPartitions()) {
-            if(!networkPartition.isActiveByDefault()) {
-                
if(!this.networkPartitionCtxts.containsKey(networkPartition.getId())) {
+            if (!networkPartition.isActiveByDefault()) {
+                if 
(!this.networkPartitionCtxts.containsKey(networkPartition.getId())) {
                     ApplicationLevelNetworkPartitionContext context =
                             new 
ApplicationLevelNetworkPartitionContext(networkPartition.getId());
                     context.setCreatedOnBurst(true);
@@ -247,7 +247,7 @@ public class ApplicationMonitor extends 
ParentComponentMonitor {
             }
         }
 
-        if(!burstNPFound) {
+        if (!burstNPFound) {
             log.warn("[Application] " + appId + " cannot be burst as no 
available resources found");
         } else {
             startDependency(application, instanceId);

http://git-wip-us.apache.org/repos/asf/stratos/blob/1fcaecd4/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/component/GroupMonitor.java
----------------------------------------------------------------------
diff --git 
a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/component/GroupMonitor.java
 
b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/component/GroupMonitor.java
index cccc0cc..0d10858 100644
--- 
a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/component/GroupMonitor.java
+++ 
b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/component/GroupMonitor.java
@@ -36,9 +36,9 @@ 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.builder.MonitorStatusEventBuilder;
-import 
org.apache.stratos.autoscaler.pojo.policy.deployment.partition.network.ChildLevelNetworkPartition;
 import org.apache.stratos.autoscaler.pojo.policy.PolicyManager;
 import org.apache.stratos.autoscaler.pojo.policy.deployment.DeploymentPolicy;
+import 
org.apache.stratos.autoscaler.pojo.policy.deployment.partition.network.ChildLevelNetworkPartition;
 import org.apache.stratos.messaging.domain.applications.Application;
 import org.apache.stratos.messaging.domain.applications.ApplicationStatus;
 import org.apache.stratos.messaging.domain.applications.Group;
@@ -179,7 +179,7 @@ public class GroupMonitor extends ParentComponentMonitor 
implements EventHandler
 
     @Override
     public void onParentStatusEvent(MonitorStatusEvent statusEvent)
-                                throws ParentMonitorNotFoundException {
+            throws ParentMonitorNotFoundException {
         String instanceId = statusEvent.getInstanceId();
         // send the ClusterTerminating event
         if (statusEvent.getStatus() == GroupStatus.Terminating ||
@@ -247,6 +247,15 @@ public class GroupMonitor extends ParentComponentMonitor 
implements EventHandler
         this.groupScalingEnabled = groupScalingEnabled;
     }
 
+    /**
+     * This will start the minimum required dependency instances
+     * based on the given parent instance ids
+     *
+     * @param group             blue print of the instance to be started
+     * @param parentInstanceIds parent instanceIds used to start the child 
instance
+     * @return whether first app startup or not
+     * @throws TopologyInConsistentException
+     */
     public boolean startMinimumDependencies(Group group, List<String> 
parentInstanceIds)
             throws TopologyInConsistentException {
         boolean initialStartup = false;
@@ -279,6 +288,14 @@ public class GroupMonitor extends ParentComponentMonitor 
implements EventHandler
         return initialStartup;
     }
 
+    /**
+     * This will create the required instance and start the dependency
+     *
+     * @param group             blue print of the instance to be started
+     * @param parentInstanceIds parent instanceIds used to start the child 
instance
+     * @throws TopologyInConsistentException
+     */
+
     public void createInstanceAndStartDependency(Group group, List<String> 
parentInstanceIds)
             throws TopologyInConsistentException {
         List<String> instanceIds = new ArrayList<String>();
@@ -323,6 +340,13 @@ public class GroupMonitor extends ParentComponentMonitor 
implements EventHandler
         startDependency(group, instanceIds);
     }
 
+    /**
+     * This will start the group instance based on the given parent instanceId
+     *
+     * @param group
+     * @param parentInstanceId
+     * @throws ParentMonitorNotFoundException
+     */
     public void createInstanceAndStartDependency(Group group, String 
parentInstanceId)
             throws ParentMonitorNotFoundException {
         String deploymentPolicyName = group.getDeploymentPolicy();
@@ -363,6 +387,15 @@ public class GroupMonitor extends ParentComponentMonitor 
implements EventHandler
         startDependency(group, instanceId);
     }
 
+    /**
+     * This will create the group instance in the applications Topology
+     *
+     * @param group
+     * @param parentInstanceId
+     * @param partitionId
+     * @param networkPartitionId
+     * @return
+     */
     private String createGroupInstance(Group group, String parentInstanceId, 
String partitionId,
                                        String networkPartitionId) {
         String instanceId = parentInstanceId;

Reply via email to