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 2014/01/14 19:39:58 UTC
git commit: Removing the active member when instance is terminated by
fault member event
Updated Branches:
refs/heads/master 26be402c7 -> 442be445f
Removing the active member when instance is terminated by fault member event
Project: http://git-wip-us.apache.org/repos/asf/incubator-stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-stratos/commit/442be445
Tree: http://git-wip-us.apache.org/repos/asf/incubator-stratos/tree/442be445
Diff: http://git-wip-us.apache.org/repos/asf/incubator-stratos/diff/442be445
Branch: refs/heads/master
Commit: 442be445f74e5bc14af6bbe1beaf12bb9ffc57a4
Parents: 26be402
Author: Lahiru Sandaruwan <la...@apache.org>
Authored: Wed Jan 15 00:14:12 2014 +0530
Committer: Lahiru Sandaruwan <la...@apache.org>
Committed: Wed Jan 15 00:14:12 2014 +0530
----------------------------------------------------------------------
.../apache/stratos/autoscaler/PartitionContext.java | 15 +++++++++++++++
.../health/AutoscalerHealthStatReceiver.java | 8 ++++++++
.../topology/AutoscalerTopologyReceiver.java | 14 +++++++++-----
3 files changed, 32 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/442be445/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 3ea8d80..36c3e97 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
@@ -329,6 +329,21 @@ public class PartitionContext implements Serializable{
return activeMembers.size() + pendingMembers.size();
}
+ public void removeActiveMemberById(String memberId) {
+
+ synchronized (activeMembers) {
+
+ for (Iterator<MemberContext> iterator = activeMembers.listIterator(); iterator.hasNext();) {
+ String currentMemberId = ((MemberContext) iterator).getMemberId();
+ if(memberId.equals(currentMemberId)){
+
+ iterator.remove();
+ break;
+ }
+ }
+ }
+ }
+
private class PendingMemberWatcher implements Runnable {
private PartitionContext ctxt;
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/442be445/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/health/AutoscalerHealthStatReceiver.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/health/AutoscalerHealthStatReceiver.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/health/AutoscalerHealthStatReceiver.java
index c2f1097..aee9d31 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/health/AutoscalerHealthStatReceiver.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/health/AutoscalerHealthStatReceiver.java
@@ -380,6 +380,10 @@ public class AutoscalerHealthStatReceiver implements Runnable {
log.error("Member id not found in received message");
}
} else {
+
+ if (log.isDebugEnabled()) {
+ log.debug(String.format("Member fault event: [member] %s ", e.getMemberId()));
+ }
handleMemberFaultEvent(clusterId, memberId);
}
}
@@ -734,12 +738,16 @@ public class AutoscalerHealthStatReceiver implements Runnable {
CloudControllerClient ccClient = CloudControllerClient.getInstance();
ccClient.terminate(memberId);
+
// start a new member in the same Partition
String partitionId = monitor.getPartitionOfMember(memberId);
Partition partition = monitor.getDeploymentPolicy().getPartitionById(partitionId);
PartitionContext partitionCtxt = nwPartitionCtxt.getPartitionCtxt(partitionId);
+
+ partitionCtxt.removeActiveMemberById(memberId);
String lbClusterId = AutoscalerRuleEvaluator.getLbClusterId(partitionCtxt, nwPartitionCtxt);
+
partitionCtxt.addPendingMember(ccClient.spawnAnInstance(partition, clusterId, lbClusterId, nwPartitionCtxt.getId()));
if (log.isInfoEnabled()) {
log.info(String.format("Instance spawned for fault member: [partition] %s [cluster] %s [lb cluster] %s ",
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/442be445/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 9906a96..7162826 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
@@ -105,6 +105,10 @@ public class AutoscalerTopologyReceiver implements Runnable {
}
th.start();
+ if(log.isDebugEnabled()) {
+ log.debug(String.format("Cluster monitor thread has been started successfully: [cluster] %s "
+ , cluster.getClusterId()));
+ }
}
}
}
@@ -157,7 +161,7 @@ public class AutoscalerTopologyReceiver implements Runnable {
// runTerminateAllRule(monitor);
monitor.destroy();
if(log.isDebugEnabled()) {
- log.debug(String.format("Cluster monitor has been removed: [cluster] %s ", clusterId));
+ log.debug(String.format("Cluster monitor has been removed successfully: [cluster] %s ", clusterId));
}
}
finally {
@@ -206,7 +210,7 @@ public class AutoscalerTopologyReceiver implements Runnable {
log.error(String.format("Member is not available in termination pending list: [member] %s", e.getMemberId()));
}
} else if(log.isInfoEnabled()){
- log.info(String.format("Member stat context has been removed: [member] %s", e.getMemberId()));
+ log.info(String.format("Member stat context has been removed successfully: [member] %s", e.getMemberId()));
}
// partitionContext.decrementCurrentActiveMemberCount(1);
@@ -243,7 +247,7 @@ public class AutoscalerTopologyReceiver implements Runnable {
}
partitionContext.addMemberStatsContext(new MemberStatsContext(memberId));
if(log.isInfoEnabled()){
- log.info(String.format("Member stat context has been added: [member] %s", memberId));
+ log.info(String.format("Member stat context has been added successfully: [member] %s", memberId));
}
// partitionContext.incrementCurrentActiveMemberCount(1);
partitionContext.movePendingMemberToActiveMembers(memberId);
@@ -304,7 +308,7 @@ public class AutoscalerTopologyReceiver implements Runnable {
th.start();
AutoscalerContext.getInstance().addLbMonitor(monitor);
if(log.isInfoEnabled()){
- log.info(String.format("LB Cluster monitor has been added: [cluster] %s",
+ log.info(String.format("LB Cluster monitor has been added successfully: [cluster] %s",
cluster.getClusterId()));
}
}
@@ -337,7 +341,7 @@ public class AutoscalerTopologyReceiver implements Runnable {
th.start();
AutoscalerContext.getInstance().addMonitor(monitor);
if(log.isInfoEnabled()){
- log.info(String.format("Cluster monitor has been added: [cluster] %s",
+ log.info(String.format("Cluster monitor has been added successfully: [cluster] %s",
cluster.getClusterId()));
}
}