Repository: incubator-stratos Updated Branches: refs/heads/master 8d4cf7cca -> 9694fa2bb
fixing STRATOS-494 Project: http://git-wip-us.apache.org/repos/asf/incubator-stratos/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-stratos/commit/9694fa2b Tree: http://git-wip-us.apache.org/repos/asf/incubator-stratos/tree/9694fa2b Diff: http://git-wip-us.apache.org/repos/asf/incubator-stratos/diff/9694fa2b Branch: refs/heads/master Commit: 9694fa2bb607063b3781a2a061a1936bf7ea860b Parents: 8d4cf7c Author: rekathiru <[email protected]> Authored: Tue Mar 11 14:56:58 2014 -0400 Committer: rekathiru <[email protected]> Committed: Tue Mar 11 14:56:58 2014 -0400 ---------------------------------------------------------------------- .../stratos/autoscaler/PartitionContext.java | 20 ++++++++--------- .../topology/AutoscalerTopologyReceiver.java | 23 ++++++++++---------- 2 files changed, 21 insertions(+), 22 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/9694fa2b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/PartitionContext.java ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/PartitionContext.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/PartitionContext.java index 7fcfa93..d9189dc 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/PartitionContext.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/PartitionContext.java @@ -170,8 +170,7 @@ public class PartitionContext implements Serializable{ if (id == null) { return false; } - - for (Iterator<MemberContext> iterator = pendingMembers.iterator(); iterator.hasNext();) { + for (Iterator<MemberContext> iterator = pendingMembers.iterator(); iterator.hasNext();) { MemberContext pendingMember = (MemberContext) iterator.next(); if(id.equals(pendingMember.getMemberId())){ iterator.remove(); @@ -247,10 +246,10 @@ public class PartitionContext implements Serializable{ public boolean removeTerminationPendingMember(String memberId) { boolean terminationPendingMemberAvailable = false; - for (MemberContext memberContext: activeMembers){ + for (MemberContext memberContext: terminationPendingMembers){ if(memberContext.getMemberId().equals(memberId)){ - terminationPendingMemberAvailable =true; - activeMembers.remove(memberContext); + terminationPendingMemberAvailable = true; + terminationPendingMembers.remove(memberContext); break; } } @@ -357,23 +356,24 @@ public class PartitionContext implements Serializable{ } public int getNonTerminatedMemberCount() { - return activeMembers.size() + pendingMembers.size(); + return activeMembers.size() + pendingMembers.size() + terminationPendingMembers.size(); } - public void removeActiveMemberById(String memberId) { - + public boolean removeActiveMemberById(String memberId) { + boolean removeActiveMember = false; synchronized (activeMembers) { Iterator<MemberContext> iterator = activeMembers.listIterator(); while (iterator.hasNext()) { MemberContext memberContext = iterator.next(); - if(memberId.equals(memberContext.getMemberId())){ - iterator.remove(); + removeActiveMember = true; + break; } } } + return removeActiveMember; } public boolean activeMemberExist(String memberId) { http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/9694fa2b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyReceiver.java ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyReceiver.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyReceiver.java index fae2307..d526717 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyReceiver.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyReceiver.java @@ -223,10 +223,8 @@ public class AutoscalerTopologyReceiver implements Runnable { AbstractMonitor monitor; if(AutoscalerContext.getInstance().moniterExist(clusterId)){ - monitor = AutoscalerContext.getInstance().getMonitor(clusterId); } else { - //This is LB member monitor = AutoscalerContext.getInstance().getLBMonitor(clusterId); } @@ -236,19 +234,20 @@ public class AutoscalerTopologyReceiver implements Runnable { PartitionContext partitionContext = networkPartitionContext.getPartitionCtxt(partitionId); String memberId = e.getMemberId(); partitionContext.removeMemberStatsContext(memberId); - - if(partitionContext.removePendingMember(memberId)) { - if(log.isDebugEnabled()){ - log.debug(String.format("Member is removed from pending list: [member] %s", memberId)); - } - } - - if(!partitionContext.removeTerminationPendingMember(memberId)){ + if(partitionContext.removeTerminationPendingMember(memberId)){ + if(log.isDebugEnabled()){ + log.debug(String.format("Member is removed from termination pending members list: [member] %s", memberId)); + } + } else if(partitionContext.removePendingMember(memberId)) { if(log.isDebugEnabled()){ - log.debug(String.format("Member is not available in termination pending list: [member] %s", memberId)); + log.debug(String.format("Member is removed from pending members list: [member] %s", memberId)); } - } + } else if(partitionContext.removeActiveMemberById(memberId)){ + log.warn(String.format("Member is in the wrong list and it is removed from active members list", memberId)); + } else { + log.warn(String.format("Member is not available in any of the list active, pending and termination pending", memberId)); + } if(log.isInfoEnabled()){ log.info(String.format("Member stat context has been removed successfully: [member] %s", memberId));
