You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stratos.apache.org by is...@apache.org on 2014/10/29 11:42:05 UTC
[1/2] git commit: refactoring current undeployment logic in Autoscaler
Repository: stratos
Updated Branches:
refs/heads/4.0.0-grouping 55e3eff1f -> caa6f1b15
refactoring current undeployment logic in Autoscaler
Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/6fbb9525
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/6fbb9525
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/6fbb9525
Branch: refs/heads/4.0.0-grouping
Commit: 6fbb9525bd5555a2589fb7475c1e99aa98af38a7
Parents: 55e3eff
Author: Isuru Haththotuwa <is...@apache.org>
Authored: Wed Oct 29 15:42:06 2014 +0530
Committer: Isuru Haththotuwa <is...@apache.org>
Committed: Wed Oct 29 15:42:16 2014 +0530
----------------------------------------------------------------------
.../AutoscalerTopologyEventReceiver.java | 171 ++++++++++---------
1 file changed, 93 insertions(+), 78 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/stratos/blob/6fbb9525/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java
index d66795c..c866339 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java
@@ -354,87 +354,102 @@ public class AutoscalerTopologyEventReceiver implements Runnable {
ApplicationUndeployedEvent applicationUndeployedEvent = (ApplicationUndeployedEvent) event;
- // acquire reead locks for application and relevant clusters
- TopologyManager.acquireReadLockForApplication(applicationUndeployedEvent.getApplicationId());
- Set<ClusterDataHolder> clusterDataHolders = applicationUndeployedEvent.getClusterData();
- if (clusterDataHolders != null) {
- for (ClusterDataHolder clusterData : clusterDataHolders) {
- TopologyManager.acquireReadLockForCluster(clusterData.getServiceType(),
- clusterData.getClusterId());
- }
- }
-
- try {
- ApplicationMonitor appMonitor = AutoscalerContext.getInstance().
- getAppMonitor(applicationUndeployedEvent.getApplicationId());
-
- if (appMonitor != null) {
- // update the status as Terminating
- appMonitor.setStatus(ApplicationStatus.Terminating);
+ ApplicationMonitor appMonitor = AutoscalerContext.getInstance().
+ getAppMonitor(applicationUndeployedEvent.getApplicationId());
-// List<String> clusters = appMonitor.
-// findClustersOfApplication(applicationUndeployedEvent.getApplicationId());
+ if (appMonitor != null) {
+ // set Application Monitor state to 'Terminating'
+ appMonitor.setStatus(ApplicationStatus.Terminating);
- boolean clusterMonitorsFound = false;
- for (ClusterDataHolder clusterData : clusterDataHolders) {
- //stopping the cluster monitor and remove it from the AS
- ClusterMonitor clusterMonitor =
- ((ClusterMonitor) AutoscalerContext.getInstance().getMonitor(clusterData.getClusterId()));
- if (clusterMonitor != null) {
- clusterMonitorsFound = true;
- clusterMonitor.setDestroyed(true);
- //clusterMonitor.terminateAllMembers();
- if (clusterMonitor.getStatus() == ClusterStatus.Active) {
- // terminated gracefully
- clusterMonitor.setStatus(ClusterStatus.Terminating);
- InstanceNotificationPublisher.sendInstanceCleanupEventForCluster(clusterData.getClusterId());
- } else {
- // if not active, forcefully terminate
- clusterMonitor.setStatus(ClusterStatus.Terminating);
- clusterMonitor.terminateAllMembers();
-// try {
-// // TODO: introduce a task to do this cleanup
-// CloudControllerClient.getInstance().terminateAllInstances(clusterData.getClusterId());
-// } catch (TerminationException e) {
-// log.error("Unable to terminate instances for [ cluster id ] " +
-// clusterData.getClusterId(), e);
-// }
- }
- } else {
- log.warn("No Cluster Monitor found for cluster id " + clusterData.getClusterId());
- // if Cluster Monitor is not found, still the Cluster Terminated
- // should be sent to update the parent Monitor
- StatusEventPublisher.sendClusterTerminatedEvent(
- applicationUndeployedEvent.getApplicationId(),
- clusterData.getServiceType(), clusterData.getClusterId());
- }
- }
-
- // if by any chance, the cluster monitors have failed, we still need to undeploy this application
- // hence, check if the Cluster Monitors are not found and send the Application Terminated event
- if (!clusterMonitorsFound) {
- StatusEventPublisher.sendApplicationTerminatedEvent(
- applicationUndeployedEvent.getApplicationId(), clusterDataHolders);
- }
-
- } else {
- log.warn("Application Monitor cannot be found for the undeployed [application] "
- + applicationUndeployedEvent.getApplicationId());
- // send the App Terminated event to cleanup
- StatusEventPublisher.sendApplicationTerminatedEvent(
- applicationUndeployedEvent.getApplicationId(), clusterDataHolders);
- }
-
- } finally {
- if (clusterDataHolders != null) {
- for (ClusterDataHolder clusterData : clusterDataHolders) {
- TopologyManager.releaseReadLockForCluster(clusterData.getServiceType(),
- clusterData.getClusterId());
- }
- }
- TopologyManager.
- releaseReadLockForApplication(applicationUndeployedEvent.getApplicationId());
+ } else {
+ // ApplicationMonitor is not found, send Terminating event to clean up
+ StatusEventPublisher.sendApplicationTerminatedEvent(
+ applicationUndeployedEvent.getApplicationId(), applicationUndeployedEvent.getClusterData());
}
+
+// ApplicationUndeployedEvent applicationUndeployedEvent = (ApplicationUndeployedEvent) event;
+//
+// // acquire reead locks for application and relevant clusters
+// TopologyManager.acquireReadLockForApplication(applicationUndeployedEvent.getApplicationId());
+// Set<ClusterDataHolder> clusterDataHolders = applicationUndeployedEvent.getClusterData();
+// if (clusterDataHolders != null) {
+// for (ClusterDataHolder clusterData : clusterDataHolders) {
+// TopologyManager.acquireReadLockForCluster(clusterData.getServiceType(),
+// clusterData.getClusterId());
+// }
+// }
+//
+// try {
+// ApplicationMonitor appMonitor = AutoscalerContext.getInstance().
+// getAppMonitor(applicationUndeployedEvent.getApplicationId());
+//
+// if (appMonitor != null) {
+// // update the status as Terminating
+// appMonitor.setStatus(ApplicationStatus.Terminating);
+//
+//// List<String> clusters = appMonitor.
+//// findClustersOfApplication(applicationUndeployedEvent.getApplicationId());
+//
+// boolean clusterMonitorsFound = false;
+// for (ClusterDataHolder clusterData : clusterDataHolders) {
+// //stopping the cluster monitor and remove it from the AS
+// ClusterMonitor clusterMonitor =
+// ((ClusterMonitor) AutoscalerContext.getInstance().getMonitor(clusterData.getClusterId()));
+// if (clusterMonitor != null) {
+// clusterMonitorsFound = true;
+// clusterMonitor.setDestroyed(true);
+// //clusterMonitor.terminateAllMembers();
+// if (clusterMonitor.getStatus() == ClusterStatus.Active) {
+// // terminated gracefully
+// clusterMonitor.setStatus(ClusterStatus.Terminating);
+// InstanceNotificationPublisher.sendInstanceCleanupEventForCluster(clusterData.getClusterId());
+// } else {
+// // if not active, forcefully terminate
+// clusterMonitor.setStatus(ClusterStatus.Terminating);
+// clusterMonitor.terminateAllMembers();
+//// try {
+//// // TODO: introduce a task to do this cleanup
+//// CloudControllerClient.getInstance().terminateAllInstances(clusterData.getClusterId());
+//// } catch (TerminationException e) {
+//// log.error("Unable to terminate instances for [ cluster id ] " +
+//// clusterData.getClusterId(), e);
+//// }
+// }
+// } else {
+// log.warn("No Cluster Monitor found for cluster id " + clusterData.getClusterId());
+// // if Cluster Monitor is not found, still the Cluster Terminated
+// // should be sent to update the parent Monitor
+// StatusEventPublisher.sendClusterTerminatedEvent(
+// applicationUndeployedEvent.getApplicationId(),
+// clusterData.getServiceType(), clusterData.getClusterId());
+// }
+// }
+//
+// // if by any chance, the cluster monitors have failed, we still need to undeploy this application
+// // hence, check if the Cluster Monitors are not found and send the Application Terminated event
+// if (!clusterMonitorsFound) {
+// StatusEventPublisher.sendApplicationTerminatedEvent(
+// applicationUndeployedEvent.getApplicationId(), clusterDataHolders);
+// }
+//
+// } else {
+// log.warn("Application Monitor cannot be found for the undeployed [application] "
+// + applicationUndeployedEvent.getApplicationId());
+// // send the App Terminated event to cleanup
+// StatusEventPublisher.sendApplicationTerminatedEvent(
+// applicationUndeployedEvent.getApplicationId(), clusterDataHolders);
+// }
+//
+// } finally {
+// if (clusterDataHolders != null) {
+// for (ClusterDataHolder clusterData : clusterDataHolders) {
+// TopologyManager.releaseReadLockForCluster(clusterData.getServiceType(),
+// clusterData.getClusterId());
+// }
+// }
+// TopologyManager.
+// releaseReadLockForApplication(applicationUndeployedEvent.getApplicationId());
+// }
}
});
[2/2] git commit: fixing a NPE is ApplicationMonitor
Posted by is...@apache.org.
fixing a NPE is ApplicationMonitor
Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/caa6f1b1
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/caa6f1b1
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/caa6f1b1
Branch: refs/heads/4.0.0-grouping
Commit: caa6f1b155ba103664f889e17a5f56f5f8f916f5
Parents: 6fbb952
Author: Isuru Haththotuwa <is...@apache.org>
Authored: Wed Oct 29 16:11:39 2014 +0530
Committer: Isuru Haththotuwa <is...@apache.org>
Committed: Wed Oct 29 16:11:39 2014 +0530
----------------------------------------------------------------------
.../stratos/autoscaler/monitor/application/ApplicationMonitor.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/stratos/blob/caa6f1b1/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java
index 35f4a70..dc53403 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java
@@ -148,7 +148,7 @@ public class ApplicationMonitor extends ParentComponentMonitor {
this.status = status;
//notify the children about the state change
- MonitorStatusEventBuilder.notifyChildren(this.parent, new ApplicationStatusEvent(status, appId));
+ MonitorStatusEventBuilder.notifyChildren(this, new ApplicationStatusEvent(status, appId));
}
@Override