You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stratos.apache.org by la...@apache.org on 2015/04/25 05:53:04 UTC

stratos git commit: Use iterator to iterate through members to put them in terminate process

Repository: stratos
Updated Branches:
  refs/heads/master b2cd07dcf -> 7f5d30e4f


Use iterator to iterate through members to put them in terminate process


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

Branch: refs/heads/master
Commit: 7f5d30e4fc09ea2a2f30b8f405946524ffea3030
Parents: b2cd07d
Author: Lahiru Sandaruwan <la...@apache.org>
Authored: Sat Apr 25 09:22:45 2015 +0530
Committer: Lahiru Sandaruwan <la...@apache.org>
Committed: Sat Apr 25 09:22:45 2015 +0530

----------------------------------------------------------------------
 .../services/impl/AutoscalerServiceImpl.java    | 22 +++++++++++---------
 1 file changed, 12 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/7f5d30e4/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/services/impl/AutoscalerServiceImpl.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/services/impl/AutoscalerServiceImpl.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/services/impl/AutoscalerServiceImpl.java
index b484d2c..74578f6 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/services/impl/AutoscalerServiceImpl.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/services/impl/AutoscalerServiceImpl.java
@@ -978,7 +978,7 @@ public class AutoscalerServiceImpl implements AutoscalerService {
                             = clusterMonitor.getClusterContext().getNetworkPartitionCtxt(networkPartition.getId());
 
                     try {
-                        
+
                         addNewPartitionsToClusterMonitor(clusterLevelNetworkPartitionContext, networkPartition,
                                 deploymentPolicy.getDeploymentPolicyID(), clusterMonitor.getClusterContext().getServiceId());
                     } catch (RemoteException e) {
@@ -995,8 +995,9 @@ public class AutoscalerServiceImpl implements AutoscalerService {
                         throw new InvalidDeploymentPolicyException(message, e);
                     } catch (CloudControllerServiceInvalidCartridgeTypeExceptionException e) {
 
-                        String message = "Cluster monitor update failed for [deployment-policy] "
-                                + deploymentPolicy.getDeploymentPolicyID() + " [cluster] " + clusterMonitor.getClusterId();
+                        String message = "Invalid cartridge type, Cluster monitor update failed for [deployment-policy] "
+                                + deploymentPolicy.getDeploymentPolicyID() + " [cartridge] "
+                                + clusterMonitor.getClusterContext().getServiceId();
                         log.error(message);
                         throw new InvalidDeploymentPolicyException(message, e);
                     }
@@ -1019,17 +1020,18 @@ public class AutoscalerServiceImpl implements AutoscalerService {
 
                     //It has found that this partition context which is in cluster monitor is removed in updated policy
                     clusterLevelPartitionContext.setIsObsoletePartition(true);
+                    Iterator<MemberContext> memberContextIterator = clusterLevelPartitionContext.getActiveMembers().iterator();
+                    while (memberContextIterator.hasNext()) {
 
-                    while (clusterLevelPartitionContext.getActiveMembers().size() != 0) {
-
-                        MemberContext member = clusterLevelPartitionContext.getActiveMembers().get(0);
-                        clusterLevelPartitionContext.moveActiveMemberToTerminationPendingMembers(member.getMemberId());
+                        clusterLevelPartitionContext.moveActiveMemberToTerminationPendingMembers(
+                                memberContextIterator.next().getMemberId());
                     }
 
-                    while (clusterLevelPartitionContext.getPendingMembers().size() != 0) {
+                    memberContextIterator = clusterLevelPartitionContext.getPendingMembers().iterator();
+                    while (memberContextIterator.hasNext()) {
 
-                        MemberContext member = clusterLevelPartitionContext.getPendingMembers().get(0);
-                        clusterLevelPartitionContext.movePendingMemberToObsoleteMembers(member.getMemberId());
+                        clusterLevelPartitionContext.movePendingMemberToObsoleteMembers(
+                                memberContextIterator.next().getMemberId());
                     }
                 }
             }