Repository: stratos
Updated Branches:
  refs/heads/master 3da25af49 -> 70cc17beb


Fixing the warnings in monitor and application builder classes


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

Branch: refs/heads/master
Commit: 70cc17bebb4e2eccc83e4060be1afeefdb4e86aa
Parents: aa25af5
Author: reka <[email protected]>
Authored: Mon May 11 17:21:31 2015 +0530
Committer: reka <[email protected]>
Committed: Tue May 12 14:02:03 2015 +0530

----------------------------------------------------------------------
 .../applications/topic/ApplicationBuilder.java  |  65 +++++-----
 .../autoscaler/monitor/MonitorFactory.java      | 129 ++++++-------------
 .../monitor/cluster/ClusterMonitor.java         |  70 +++-------
 3 files changed, 86 insertions(+), 178 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/70cc17be/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/topic/ApplicationBuilder.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 b5da7a7..91b8b74 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
@@ -65,8 +65,8 @@ public class ApplicationBuilder {
     /**
      * Create application clusters in cloud controller and send application 
created event.
      *
-     * @param application
-     * @param appClusterContexts
+     * @param application        the application
+     * @param appClusterContexts the clusters in the application
      */
     public static synchronized void handleApplicationDeployment(Application 
application,
                                                                 
ApplicationClusterContext[] appClusterContexts) {
@@ -360,9 +360,9 @@ public class ApplicationBuilder {
                                     
cluster.getInstanceIdToInstanceContextMap().values()) {
                                 ClusterStatusEventPublisher.
                                         
sendClusterStatusClusterTerminatingEvent(applicationId,
-                                        aClusterData.getServiceType(),
-                                        aClusterData.getClusterId(),
-                                        instance.getInstanceId());
+                                                aClusterData.getServiceType(),
+                                                aClusterData.getClusterId(),
+                                                instance.getInstanceId());
                             }
                         }
                     }
@@ -520,8 +520,6 @@ public class ApplicationBuilder {
 
             GroupStatus status = GroupStatus.Created;
             String instanceId = parentId;
-            int minGroupInstances = group.getGroupMinInstances();
-            int maxGroupInstances = group.getGroupMaxInstances();
             /*
             * When min != 1 or max != 1, we need to generate
             * instance ids as it is having more than one group instances
@@ -532,7 +530,7 @@ public class ApplicationBuilder {
 
             if (!group.containsInstanceContext(instanceId)) {
                 //setting the status, persist and publish
-                GroupInstance groupInstance = null;
+                GroupInstance groupInstance;
                 groupInstance = new GroupInstance(groupId, instanceId);
                 groupInstance.setParentId(parentId);
                 groupInstance.setPartitionId(partitionId);
@@ -631,11 +629,12 @@ public class ApplicationBuilder {
                     updateGroupMonitor(appId, groupId, status, 
groupInstance.getNetworkPartitionId(),
                             instanceId, groupInstance.getParentId());
                     ApplicationHolder.persistApplication(application);
-                    
ApplicationsEventPublisher.sendGroupInstanceTerminatingEvent(appId, groupId, 
instanceId);
+                    
ApplicationsEventPublisher.sendGroupInstanceTerminatingEvent(appId,
+                            groupId, instanceId);
                 } else {
                     log.warn("Group state transition is not valid: [group-id] 
" + groupId +
-                            " [instance-id] " + instanceId + " [current-state] 
" + groupInstance.getStatus()
-                            + "[requested-state] " + status);
+                            " [instance-id] " + instanceId + " [current-state] 
" +
+                            groupInstance.getStatus() + "[requested-state] " + 
status);
                 }
 
             } else {
@@ -651,33 +650,34 @@ public class ApplicationBuilder {
                                                  String networkPartitionId, 
String instanceId) {
         //Updating the Application Monitor
         ApplicationMonitor applicationMonitor = 
AutoscalerContext.getInstance().getAppMonitor(appId);
-        NetworkPartitionContext context = applicationMonitor.
-                getNetworkPartitionContext(networkPartitionId);
+
         if (applicationMonitor != null) {
-            if(status == ApplicationStatus.Active) {
-                if(log.isDebugEnabled()) {
+            NetworkPartitionContext context = applicationMonitor.
+                    getNetworkPartitionContext(networkPartitionId);
+            if (status == ApplicationStatus.Active) {
+                if (log.isDebugEnabled()) {
                     log.debug("Moving pending [application-instance] " + 
instanceId +
                             " to active list in [application] " + appId);
                 }
                 context.movePendingInstanceToActiveInstances(instanceId);
-            } else if(status == ApplicationStatus.Terminating) {
+            } else if (status == ApplicationStatus.Terminating) {
                 applicationMonitor.setTerminating(true);
 
-                if(context.getActiveInstance(instanceId) != null) {
-                    if(log.isDebugEnabled()) {
+                if (context.getActiveInstance(instanceId) != null) {
+                    if (log.isDebugEnabled()) {
                         log.debug("Moving active [application-instance] " + 
instanceId +
                                 " to termination pending list " + "in 
[application] " + appId);
                     }
                     
context.moveActiveInstanceToTerminationPendingInstances(instanceId);
-                } else if(context.getPendingInstance(instanceId) != null) {
-                    if(log.isDebugEnabled()) {
+                } else if (context.getPendingInstance(instanceId) != null) {
+                    if (log.isDebugEnabled()) {
                         log.debug("Moving pending  [application-instance]" + 
instanceId +
                                 " to termination pending list in [application] 
" + appId);
                     }
                     
context.movePendingInstanceToTerminationPendingInstances(instanceId);
                 }
-            } else if(status == ApplicationStatus.Terminated) {
-                if(log.isDebugEnabled()) {
+            } else if (status == ApplicationStatus.Terminated) {
+                if (log.isDebugEnabled()) {
                     log.debug("Removing termination pending 
[application-instance] " + instanceId
                             + " [application] " + appId);
                 }
@@ -696,28 +696,28 @@ public class ApplicationBuilder {
         GroupMonitor monitor = getGroupMonitor(appId, groupId);
         if (monitor != null) {
             NetworkPartitionContext context = 
monitor.getNetworkPartitionContext(networkPartitionId);
-            if(status == GroupStatus.Active) {
-                if(log.isDebugEnabled()) {
+            if (status == GroupStatus.Active) {
+                if (log.isDebugEnabled()) {
                     log.debug("Moving pending group instance to active list in 
[group] " + groupId
                             + " [group-instance] " + instanceId);
                 }
                 context.movePendingInstanceToActiveInstances(instanceId);
-            } else if(status == GroupStatus.Terminating) {
-                if(context.getActiveInstance(instanceId) != null) {
-                    if(log.isDebugEnabled()) {
+            } else if (status == GroupStatus.Terminating) {
+                if (context.getActiveInstance(instanceId) != null) {
+                    if (log.isDebugEnabled()) {
                         log.debug("Moving active group instance to termination 
pending list in " +
                                 "[group] " + groupId + " [group-instance] " + 
instanceId);
                     }
                     
context.moveActiveInstanceToTerminationPendingInstances(instanceId);
-                } else if(context.getPendingInstance(instanceId) != null) {
-                    if(log.isDebugEnabled()) {
+                } else if (context.getPendingInstance(instanceId) != null) {
+                    if (log.isDebugEnabled()) {
                         log.debug("Moving pending group instance to 
termination pending list in " +
                                 "[group] " + groupId + " [group-instance] " + 
instanceId);
                     }
                     
context.movePendingInstanceToTerminationPendingInstances(instanceId);
                 }
-            } else if(status == GroupStatus.Terminated) {
-                if(log.isDebugEnabled()) {
+            } else if (status == GroupStatus.Terminated) {
+                if (log.isDebugEnabled()) {
                     log.debug("Removing termination pending group instance in 
" +
                             "[group] " + groupId + " [group-instance] " + 
instanceId);
                 }
@@ -734,8 +734,7 @@ public class ApplicationBuilder {
         //Updating the Application Monitor
         ApplicationMonitor applicationMonitor = 
AutoscalerContext.getInstance().getAppMonitor(appId);
         if (applicationMonitor != null) {
-            GroupMonitor monitor = (GroupMonitor) 
applicationMonitor.findGroupMonitorWithId(groupId);
-            return monitor;
+            return (GroupMonitor) 
applicationMonitor.findGroupMonitorWithId(groupId);
         }
         return null;
     }

http://git-wip-us.apache.org/repos/asf/stratos/blob/70cc17be/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 8446bf6..ed026ec 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
@@ -48,6 +48,7 @@ import org.apache.stratos.messaging.domain.topology.Topology;
 import org.apache.stratos.messaging.message.receiver.topology.TopologyManager;
 
 import java.util.ArrayList;
+import java.util.Collections;
 import java.util.List;
 import java.util.Properties;
 
@@ -80,7 +81,8 @@ public class MonitorFactory {
         if (context instanceof GroupChildContext) {
             monitor = getGroupMonitor(parentMonitor, context, appId, 
parentInstanceIds);
         } else if (context instanceof ClusterChildContext) {
-            monitor = getClusterMonitor(parentMonitor, (ClusterChildContext) 
context, parentInstanceIds);
+            monitor = getClusterMonitor(parentMonitor, (ClusterChildContext) 
context,
+                    parentInstanceIds);
         } else {
             monitor = getApplicationMonitor(appId);
         }
@@ -119,8 +121,10 @@ public class MonitorFactory {
 
             boolean hasScalingDependents = false;
             if (parentMonitor.getScalingDependencies() != null) {
-                for (ScalingDependentList scalingDependentList : 
parentMonitor.getScalingDependencies()) {
-                    if 
(scalingDependentList.getScalingDependentListComponents().contains(context.getId()))
 {
+                for (ScalingDependentList scalingDependentList :
+                        parentMonitor.getScalingDependencies()) {
+                    if 
(scalingDependentList.getScalingDependentListComponents().
+                            contains(context.getId())) {
                         hasScalingDependents = true;
                     }
                 }
@@ -128,17 +132,15 @@ public class MonitorFactory {
 
             groupMonitor = new GroupMonitor(group, appId, instanceIds, 
hasScalingDependents);
             groupMonitor.setAppId(appId);
-            if (parentMonitor != null) {
-                groupMonitor.setParent(parentMonitor);
-                //Setting the dependent behaviour of the monitor
-                if (parentMonitor.hasStartupDependents() || 
(context.hasStartupDependents() &&
-                        context.hasChild())) {
-                    groupMonitor.setHasStartupDependents(true);
-                } else {
-                    groupMonitor.setHasStartupDependents(false);
-                }
-                groupMonitor.startScheduler();
+            groupMonitor.setParent(parentMonitor);
+            //Setting the dependent behaviour of the monitor
+            if (parentMonitor.hasStartupDependents() || 
(context.hasStartupDependents() &&
+                    context.hasChild())) {
+                groupMonitor.setHasStartupDependents(true);
+            } else {
+                groupMonitor.setHasStartupDependents(false);
             }
+            groupMonitor.startScheduler();
         } finally {
             ApplicationHolder.releaseReadLock();
         }
@@ -148,20 +150,6 @@ public class MonitorFactory {
         // Starting the minimum dependencies
         groupMonitor.createInstanceAndStartDependencyAtStartup(group, 
instanceIds);
 
-        /**
-         * If not first app deployment, acquiring read lock to check current 
the status of the group,
-         * when the stratos got to restarted
-         */
-        /*if (!initialStartup) {
-            //Starting statusChecking to make it sync with the Topology in the 
restart of stratos.
-            for (GroupInstance instance : 
group.getInstanceIdToInstanceContextMap().values()) {
-                ServiceReferenceHolder.getInstance().
-                        getGroupStatusProcessorChain().
-                        process(group.getUniqueIdentifier(), appId, 
instance.getInstanceId());
-            }
-
-        }*/
-
         return groupMonitor;
 
     }
@@ -185,7 +173,8 @@ public class MonitorFactory {
             ApplicationHolder.acquireReadLock();
             application = 
ApplicationHolder.getApplications().getApplication(applicationId);
             if (application == null) {
-                throw new RuntimeException("Application not found in the 
topology: [application-id] " + applicationId);
+                throw new RuntimeException("Application not found in the 
topology: " +
+                        "[application-id] " + applicationId);
             }
 
             applicationMonitor = new ApplicationMonitor(application);
@@ -198,18 +187,6 @@ public class MonitorFactory {
 
         applicationMonitor.startMinimumDependencies(application);
 
-        /*//If not first app deployment, then calculate the current status of 
the app instance.
-        if (!initialStartup) {
-            for (ApplicationInstance instance :
-                    application.getInstanceIdToInstanceContextMap().values()) {
-                //Starting statusChecking to make it sync with the Topology in 
the restart of stratos.
-                ServiceReferenceHolder.getInstance().
-                        getGroupStatusProcessorChain().
-                        process(appId, appId, instance.getInstanceId());
-
-            }
-        }*/
-
         return applicationMonitor;
     }
 
@@ -217,10 +194,10 @@ public class MonitorFactory {
      * Updates ClusterContext for given cluster
      *
      * @param parentMonitor parent of the monitor
-     * @param context
+     * @param context the child-context from the startup-dependency tree
      * @return ClusterMonitor - Updated ClusterContext
-     * @throws 
org.apache.stratos.autoscaler.exception.policy.PolicyValidationException
-     * @throws 
org.apache.stratos.autoscaler.exception.partition.PartitionValidationException
+     * @throws PolicyValidationException policy validation error
+     * @throws PartitionValidationException partition validation error
      */
     public static ClusterMonitor getClusterMonitor(ParentComponentMonitor 
parentMonitor,
                                                    ClusterChildContext context,
@@ -254,11 +231,12 @@ public class MonitorFactory {
             // deployment policy validation
             String deploymentPolicyId = 
AutoscalerUtil.getDeploymentPolicyIdByAlias(parentMonitor.appId,
                     AutoscalerUtil.getAliasFromClusterId(clusterId));
-            DeploymentPolicy deploymentPolicy = null;
+            DeploymentPolicy deploymentPolicy;
             try {
                 deploymentPolicy = 
PolicyManager.getInstance().getDeploymentPolicy(deploymentPolicyId);
             } catch (Exception e) {
-                String msg = String.format("Error while getting deployment 
policy from cloud controller [deployment-policy-id] %s", deploymentPolicyId);
+                String msg = String.format("Error while getting deployment 
policy from " +
+                        "cloud controller [deployment-policy-id] %s", 
deploymentPolicyId);
                 log.error(msg, e);
                 throw new RuntimeException(msg, e);
             }
@@ -267,16 +245,16 @@ public class MonitorFactory {
             for (NetworkPartition networkPartition : 
deploymentPolicy.getNetworkPartitions()) {
 
                 if (networkPartition != null) {
-
-                    for (Partition partition : 
networkPartition.getPartitions()) {
-                        partitionList.add(partition);
-                    }
-
+                    Collections.addAll(partitionList, 
networkPartition.getPartitions());
                     try {
 
-                        
CloudControllerServiceClient.getInstance().validateNetworkPartitionOfDeploymentPolicy(serviceName,
 networkPartition.getId());
+                        CloudControllerServiceClient.getInstance().
+                                
validateNetworkPartitionOfDeploymentPolicy(serviceName,
+                                        networkPartition.getId());
                     } catch (Exception e) {
-                        String msg = String.format("Error while validating 
deployment policy from cloud controller [network-partition-id] %s", 
networkPartition.getId());
+                        String msg = String.format("Error while validating 
deployment policy " +
+                                "from cloud controller [network-partition-id] 
%s",
+                                networkPartition.getId());
                         log.error(msg, e);
                         throw new RuntimeException(msg, e);
                     }
@@ -286,7 +264,8 @@ public class MonitorFactory {
 
             boolean hasScalingDependents = false;
             if (parentMonitor.getScalingDependencies() != null) {
-                for (ScalingDependentList scalingDependentList : 
parentMonitor.getScalingDependencies()) {
+                for (ScalingDependentList scalingDependentList :
+                        parentMonitor.getScalingDependencies()) {
                     if 
(scalingDependentList.getScalingDependentListComponents().contains(clusterId)) {
                         hasScalingDependents = true;
                     }
@@ -299,14 +278,16 @@ public class MonitorFactory {
                 groupScalingEnabledSubtree = 
findIfChildIsInGroupScalingEnabledSubTree(groupMonitor);
             }
 
-            ClusterMonitor clusterMonitor = new ClusterMonitor(cluster, 
hasScalingDependents, groupScalingEnabledSubtree,
+            ClusterMonitor clusterMonitor = new ClusterMonitor(cluster, 
hasScalingDependents,
+                    groupScalingEnabledSubtree,
                     deploymentPolicyId);
 
             Properties props = cluster.getProperties();
             if (props != null) {
                 // Set hasPrimary property
                 // hasPrimary is true if there are primary members available 
in that cluster
-                
clusterMonitor.setHasPrimary(Boolean.parseBoolean(cluster.getProperties().getProperty(IS_PRIMARY)));
+                clusterMonitor.setHasPrimary(Boolean.parseBoolean(
+                        cluster.getProperties().getProperty(IS_PRIMARY)));
             }
 
             // Setting the parent of the cluster monitor
@@ -332,41 +313,7 @@ public class MonitorFactory {
         }
     }
 
-    private static org.apache.stratos.cloud.controller.stub.domain.Partition[] 
convertPartitionsToCCPartitions(
-            Partition[] partitions) {
-
-        org.apache.stratos.cloud.controller.stub.domain.Partition[] 
ccPartitions
-                = new 
org.apache.stratos.cloud.controller.stub.domain.Partition[partitions.length];
-        for (int i = 0; i < partitions.length; i++) {
-            org.apache.stratos.cloud.controller.stub.domain.Partition 
ccPartition
-                    = new 
org.apache.stratos.cloud.controller.stub.domain.Partition();
-            ccPartition.setId(partitions[i].getId());
-            ccPartition.setDescription(partitions[i].getDescription());
-            ccPartition.setIsPublic(partitions[i].getIsPublic());
-            
ccPartition.setKubernetesClusterId(partitions[i].getKubernetesClusterId());
-            
ccPartition.setProperties(AutoscalerUtil.toStubProperties(partitions[i].getProperties()));
-            ccPartition.setProvider(partitions[i].getProvider());
-            ccPartitions[i] = ccPartition;
-        }
-        return ccPartitions;
-    }
-
-//    private static org.apache.stratos.cloud.controller.stub.Properties 
convertPropertiesToCCProperties(
-//            Properties properties) {
-//
-//        org.apache.stratos.cloud.controller.stub.Properties ccProperties
-//                = new org.apache.stratos.cloud.controller.stub.Properties();
-//        Property[] propertyArray = properties.getProperties();
-//        for(int i = 0; i < propertyArray.length; i++){
-//
-//            
ccProperties.getProperties()[i].setName(properties.getProperties()[i].getName());
-//            
ccProperties.getProperties()[i].setValue(properties.getProperties()[i].getValue());
-//        }
-//        return ccProperties;
-//    }
-
     private static boolean 
findIfChildIsInGroupScalingEnabledSubTree(GroupMonitor groupMonitor) {
-        boolean groupScalingEnabledSubtree = false;
         ParentComponentMonitor parentComponentMonitor = 
groupMonitor.getParent();
 
         if (parentComponentMonitor != null && parentComponentMonitor 
instanceof GroupMonitor) {
@@ -374,6 +321,6 @@ public class MonitorFactory {
         } else {
             return groupMonitor.isGroupScalingEnabled();
         }
-        return groupScalingEnabledSubtree;
+        return false;
     }
-}
\ No newline at end of file
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/70cc17be/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitor.java
----------------------------------------------------------------------
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 f4bf93c..750daa6 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
@@ -88,7 +88,6 @@ public class ClusterMonitor extends Monitor {
 
 
     protected boolean hasFaultyMember = false;
-    protected boolean stop = false;
     protected ClusterContext clusterContext;
     protected String serviceType;
     private AtomicBoolean monitoringStarted;
@@ -155,10 +154,12 @@ public class ClusterMonitor extends Monitor {
             if (other.clusterId != null) {
                 return false;
             }
+        } else {
+            if (!this.clusterId.equals(other.clusterId)) {
+                return false;
+            }
         }
-        if (!this.clusterId.equals(other.clusterId)) {
-            return false;
-        }
+
         return true;
     }
 
@@ -209,22 +210,10 @@ public class ClusterMonitor extends Monitor {
         this.isDestroyed = isDestroyed;
     }
 
-    public boolean isHasFaultyMember() {
-        return hasFaultyMember;
-    }
-
     public void setHasFaultyMember(boolean hasFaultyMember) {
         this.hasFaultyMember = hasFaultyMember;
     }
 
-    public boolean isStop() {
-        return stop;
-    }
-
-    public void setStop(boolean stop) {
-        this.stop = stop;
-    }
-
     public String getServiceId() {
         return serviceType;
     }
@@ -239,10 +228,6 @@ public class ClusterMonitor extends Monitor {
         return monitoringStarted;
     }
 
-    public void setMonitoringStarted(boolean monitoringStarted) {
-        this.monitoringStarted.set(monitoringStarted);
-    }
-
     public ClusterContext getClusterContext() {
         return clusterContext;
     }
@@ -451,7 +436,7 @@ public class ClusterMonitor extends Monitor {
                                 if (rifReset || memoryConsumptionReset || 
loadAverageReset) {
 
                                     log.info("Executing scaling rule as 
statistics have been reset");
-                                    ClusterContext clusterContext = 
(ClusterContext) ClusterMonitor.this.clusterContext;
+                                    ClusterContext clusterContext = 
ClusterMonitor.this.clusterContext;
 
                                     
instanceContext.getScaleCheckKnowledgeSession().setGlobal("clusterId", 
getClusterId());
                                     
instanceContext.getScaleCheckKnowledgeSession().setGlobal("rifReset", rifReset);
@@ -568,10 +553,6 @@ public class ClusterMonitor extends Monitor {
                 ", hasPrimary=" + hasPrimary + " ]";
     }
 
-    public boolean isHasPrimary() {
-        return hasPrimary;
-    }
-
     public void setHasPrimary(boolean hasPrimary) {
         this.hasPrimary = hasPrimary;
     }
@@ -614,8 +595,8 @@ public class ClusterMonitor extends Monitor {
                 + ", [event] " + scalingEvent.getId() + ", [group instance] " 
+ scalingEvent.getInstanceId()
                 + ", [factor] " + scalingEvent.getFactor());
 
-        float scalingFactorBasedOnDependencies = 
scalingFactorBasedOnDependencies = scalingEvent.getFactor();
-        ClusterContext vmClusterContext = (ClusterContext) clusterContext;
+        float scalingFactorBasedOnDependencies = scalingEvent.getFactor();
+        ClusterContext vmClusterContext = clusterContext;
         String instanceId = scalingEvent.getInstanceId();
 
         ClusterInstanceContext clusterInstanceContext =
@@ -826,12 +807,12 @@ public class ClusterMonitor extends Monitor {
         String networkPartitionId = 
averageRequestsInFlightEvent.getNetworkPartitionId();
         String clusterId = averageRequestsInFlightEvent.getClusterId();
         String clusterInstanceId = 
averageRequestsInFlightEvent.getClusterInstanceId();
-        Float servedCount = averageRequestsInFlightEvent.getServedCount();
+        /*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",
@@ -939,11 +920,6 @@ public class ClusterMonitor extends Monitor {
         memberStatsContext.setGradientOfMemoryConsumption(value);
     }
 
-    public void handleMemberSecondDerivativeOfMemoryConsumptionEvent(
-            MemberSecondDerivativeOfMemoryConsumptionEvent 
memberSecondDerivativeOfMemoryConsumptionEvent) {
-
-    }
-
     public void handleMemberAverageLoadAverageEvent(
             MemberAverageLoadAverageEvent memberAverageLoadAverageEvent) {
 
@@ -1057,11 +1033,6 @@ public class ClusterMonitor extends Monitor {
                 ClusterStatusInactiveProcessor.class.getName(), clusterId, 
clusterInstanceId);
     }
 
-    public void handleMemberStartedEvent(
-            MemberStartedEvent memberStartedEvent) {
-
-    }
-
     public void handleMemberActivatedEvent(
             MemberActivatedEvent memberActivatedEvent) {
 
@@ -1188,10 +1159,6 @@ public class ClusterMonitor extends Monitor {
                 ClusterStatusTerminatedProcessor.class.getName(), clusterId, 
clusterInstanceId);
     }
 
-    public void handleClusterRemovedEvent(
-            ClusterRemovedEvent clusterRemovedEvent) {
-
-    }
 
     public void handleDynamicUpdates(Properties properties) throws 
InvalidArgumentException {
 
@@ -1251,7 +1218,6 @@ public class ClusterMonitor extends Monitor {
                                 partitionContext.getPartitionId() + "]");
                     }
                     // need to terminate active, pending and obsolete members
-                    //FIXME to traverse concurrent
                     // active members
 
                     if 
(AutoscalerContext.getInstance().getAppMonitor(getAppId()).isForce()) {
@@ -1260,10 +1226,7 @@ public class ClusterMonitor extends Monitor {
                     }
 
                     List<String> activeMemberIdList = new ArrayList<String>();
-                    Iterator<MemberContext> iterator = 
partitionContext.getActiveMembers().listIterator();
-                    while (iterator.hasNext()) {
-                        MemberContext activeMemberCtxt = iterator.next();
-
+                    for (MemberContext activeMemberCtxt : 
partitionContext.getActiveMembers()) {
                         activeMemberIdList.add(activeMemberCtxt.getMemberId());
 
                     }
@@ -1308,13 +1271,13 @@ public class ClusterMonitor extends Monitor {
     }
 
     public Map<String, ClusterLevelNetworkPartitionContext> 
getAllNetworkPartitionCtxts() {
-        return ((ClusterContext) 
this.clusterContext).getNetworkPartitionCtxts();
+        return (this.clusterContext).getNetworkPartitionCtxts();
     }
 
     public ClusterInstanceContext getClusterInstanceContext(String 
networkPartitionId, String instanceId) {
         Map<String,
                 ClusterLevelNetworkPartitionContext> 
clusterLevelNetworkPartitionContextMap =
-                ((ClusterContext) 
this.clusterContext).getNetworkPartitionCtxts();
+                (this.clusterContext).getNetworkPartitionCtxts();
         if (StringUtils.isBlank(networkPartitionId)) {
             throw new RuntimeException("Network partition id is null");
         }
@@ -1329,7 +1292,7 @@ public class ClusterMonitor extends Monitor {
     }
 
     public Collection<ClusterLevelNetworkPartitionContext> 
getNetworkPartitionCtxts() {
-        return ((ClusterContext) 
this.clusterContext).getNetworkPartitionCtxts().values();
+        return (this.clusterContext).getNetworkPartitionCtxts().values();
     }
 
     public void createClusterInstances(List<String> parentInstanceIds, Cluster 
cluster)
@@ -1344,7 +1307,6 @@ public class ClusterMonitor extends Monitor {
                 getCluster(this.clusterId);
         try {
             return createInstance(instanceId, cluster);
-            //TODO exception
         } catch (PolicyValidationException e) {
             log.error("Error while creating the cluster instance", e);
         } catch (PartitionValidationException e) {
@@ -1368,7 +1330,7 @@ public class ClusterMonitor extends Monitor {
             if (clusterInstance != null) {
 
                 // Cluster instance is already there. No need to create one.
-                ClusterContext clusterContext = (ClusterContext) 
this.getClusterContext();
+                ClusterContext clusterContext = this.getClusterContext();
                 if (clusterContext == null) {
                     clusterContext = 
ClusterContextFactory.getVMClusterContext(clusterInstance.getInstanceId(), 
cluster,
                             hasScalingDependents(), this.deploymentPolicyId);
@@ -1419,7 +1381,7 @@ public class ClusterMonitor extends Monitor {
         //TODO take read lock for network partition context
         //FIXME to iterate properly
         for (ClusterLevelNetworkPartitionContext networkPartitionContext :
-                ((ClusterContext) 
this.clusterContext).getNetworkPartitionCtxts().values()) {
+                (this.clusterContext).getNetworkPartitionCtxts().values()) {
             ClusterInstanceContext clusterInstanceContext =
                     (ClusterInstanceContext) 
networkPartitionContext.getInstanceContext(instanceId);
             if (clusterInstanceContext != null) {

Reply via email to