You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stratos.apache.org by im...@apache.org on 2014/10/30 05:13:25 UTC
[01/50] [abbrv] git commit: initial app unsubscription changes
Repository: stratos
Updated Branches:
refs/heads/docker-grouping-merge dd9cc950d -> 17cc86ebd
initial app unsubscription changes
Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/4f59f4b8
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/4f59f4b8
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/4f59f4b8
Branch: refs/heads/docker-grouping-merge
Commit: 4f59f4b8bdbb4d9aeab043ea6544f9654ab2c634
Parents: 87d77a2
Author: Isuru Haththotuwa <is...@apache.org>
Authored: Sun Oct 26 21:47:35 2014 +0530
Committer: Isuru Haththotuwa <is...@apache.org>
Committed: Sun Oct 26 21:54:59 2014 +0530
----------------------------------------------------------------------
.../grouping/topic/StatusEventPublisher.java | 23 ++-
.../AutoscalerTopologyEventReceiver.java | 141 ++++++++-----------
.../stratos/autoscaler/monitor/Monitor.java | 7 +-
.../monitor/ParentComponentMonitor.java | 20 +--
.../monitor/application/ApplicationMonitor.java | 40 +++---
.../status/checker/StatusChecker.java | 13 +-
.../ApplicationStatusTopicReceiver.java | 4 +-
.../impl/CloudControllerServiceImpl.java | 4 +-
.../controller/topology/TopologyBuilder.java | 129 ++++++++---------
.../topology/TopologyEventPublisher.java | 20 +++
.../topology/ApplicationTerminatedEvent.java | 12 +-
.../topology/ApplicationTerminatingEvent.java | 12 +-
...StatusClusterTerminatedMessageProcessor.java | 2 +-
.../ApplicationTerminatingMessageProcessor.java | 10 +-
.../topology/ClusterTerminatedProcessor.java | 16 +--
.../topology/ClusterTerminatingProcessor.java | 16 +--
.../topology/GroupTerminatedProcessor.java | 4 +-
17 files changed, 243 insertions(+), 230 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/stratos/blob/4f59f4b8/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/StatusEventPublisher.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/StatusEventPublisher.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/StatusEventPublisher.java
index 0800b14..c0c64ac 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/StatusEventPublisher.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/StatusEventPublisher.java
@@ -10,6 +10,7 @@ import org.apache.stratos.messaging.event.application.status.*;
import org.apache.stratos.messaging.event.application.status.ApplicationActivatedEvent;
import org.apache.stratos.messaging.event.application.status.ApplicationInactivatedEvent;
import org.apache.stratos.messaging.event.application.status.ApplicationTerminatedEvent;
+import org.apache.stratos.messaging.event.application.status.ApplicationTerminatingEvent;
import org.apache.stratos.messaging.event.application.status.ClusterActivatedEvent;
import org.apache.stratos.messaging.event.application.status.ClusterInActivateEvent;
import org.apache.stratos.messaging.event.application.status.ClusterMaintenanceModeEvent;
@@ -72,9 +73,10 @@ public class StatusEventPublisher {
" [cluster]: " + clusterId);
}
//TODO
- /*ClusterActivatedEvent clusterActivatedEvent = new ClusterActivatedEvent(appId, serviceName, clusterId);
+ AppStatusClusterTerminatingEvent appStatusClusterTerminatingEvent =
+ new AppStatusClusterTerminatingEvent(appId, serviceName, clusterId);
- publishEvent(clusterActivatedEvent);*/
+ publishEvent(appStatusClusterTerminatingEvent);
}
public static void sendClusterTerminatedEvent(String appId, String serviceName, String clusterId) {
@@ -83,10 +85,11 @@ public class StatusEventPublisher {
log.info("Publishing Cluster in-activate event for [application]: " + appId +
" [cluster]: " + clusterId);
}
- //TODO
- /* Cluster clusterActivatedEvent = new ClusterActivatedEvent(appId, serviceName, clusterId);
- publishEvent(clusterActivatedEvent);*/
+ AppStatusClusterTerminatedEvent appStatusClusterTerminatedEvent =
+ new AppStatusClusterTerminatedEvent(appId, serviceName, clusterId);
+
+ publishEvent(appStatusClusterTerminatedEvent);
}
public static void sendGroupActivatedEvent(String appId, String groupId) {
@@ -156,6 +159,16 @@ public class StatusEventPublisher {
publishEvent(applicationInActivatedEvent);
}
+ public static void sendApplicationTerminatingEvent (String appId) {
+ if (log.isInfoEnabled()) {
+ log.info("Publishing Application terminated event for [application]: " + appId);
+ }
+
+ ApplicationTerminatingEvent applicationTerminatingEvent = new ApplicationTerminatingEvent(appId);
+
+ publishEvent(applicationTerminatingEvent);
+ }
+
public static void sendApplicationTerminatedEvent (String appId, Set<ClusterDataHolder> clusterData) {
if (log.isInfoEnabled()) {
log.info("Publishing Application terminated event for [application]: " + appId);
http://git-wip-us.apache.org/repos/asf/stratos/blob/4f59f4b8/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 2f7cca4..654d5b2 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
@@ -41,7 +41,6 @@ import org.apache.stratos.messaging.event.topology.*;
import org.apache.stratos.messaging.event.topology.ApplicationActivatedEvent;
import org.apache.stratos.messaging.event.topology.ApplicationCreatedEvent;
import org.apache.stratos.messaging.event.topology.ClusterActivatedEvent;
-import org.apache.stratos.messaging.event.topology.ClusterInActivateEvent;
import org.apache.stratos.messaging.event.topology.GroupActivatedEvent;
import org.apache.stratos.messaging.listener.topology.*;
import org.apache.stratos.messaging.message.receiver.topology.TopologyEventReceiver;
@@ -204,9 +203,9 @@ public class AutoscalerTopologyEventReceiver implements Runnable {
log.info("[ClusterInActivateEvent] Received: " + event.getClass());
- ClusterTerminatedEvent clusterInactivateEvent = (ClusterTerminatedEvent) event;
- String appId = clusterInactivateEvent.getAppId();
- String clusterId = clusterInactivateEvent.getClusterId();
+ ClusterTerminatingEvent clusterTerminatingEvent = (ClusterTerminatingEvent) event;
+ String appId = clusterTerminatingEvent.getAppId();
+ String clusterId = clusterTerminatingEvent.getClusterId();
AbstractClusterMonitor clusterMonitor =
(AbstractClusterMonitor) AutoscalerContext.getInstance().getMonitor(clusterId);
@@ -224,9 +223,9 @@ public class AutoscalerTopologyEventReceiver implements Runnable {
log.info("[ClusterInActivateEvent] Received: " + event.getClass());
- ClusterTerminatedEvent clusterInactivateEvent = (ClusterTerminatedEvent) event;
- String appId = clusterInactivateEvent.getAppId();
- String clusterId = clusterInactivateEvent.getClusterId();
+ ClusterTerminatedEvent clusterTerminatedEvent = (ClusterTerminatedEvent) event;
+ String appId = clusterTerminatedEvent.getAppId();
+ String clusterId = clusterTerminatedEvent.getClusterId();
AbstractClusterMonitor clusterMonitor =
(AbstractClusterMonitor) AutoscalerContext.getInstance().getMonitor(clusterId);
@@ -328,78 +327,17 @@ public class AutoscalerTopologyEventReceiver implements Runnable {
}
});
-// topologyEventReceiver.addEventListener(new ApplicationUndeployedEventListener() {
-// @Override
-// protected void onEvent(Event event) {
-//
-// log.info("[ApplicationUndeployedEvent] Received: " + event.getClass());
-//
-// 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());
-//
-// for (String clusterId : clusters) {
-// //stopping the cluster monitor and remove it from the AS
-// ClusterMonitor clusterMonitor =
-// ((ClusterMonitor) AutoscalerContext.getInstance().getMonitor(clusterId));
-// if (clusterMonitor != null) {
-// clusterMonitor.setDestroyed(true);
-// clusterMonitor.terminateAllMembers();
-// clusterMonitor.setStatus(ClusterStatus.Terminating);
-// } else {
-// log.warn("No Cluster Monitor found for cluster id " + clusterId);
-// }
-// }
-//
-// } else {
-// log.warn("Application Monitor cannot be found for the undeployed [application] "
-// + applicationUndeployedEvent.getApplicationId());
-// }
-//
-// } finally {
-// if (clusterDataHolders != null) {
-// for (ClusterDataHolder clusterData : clusterDataHolders) {
-// TopologyManager.releaseReadLockForCluster(clusterData.getServiceType(),
-// clusterData.getClusterId());
-// }
-// }
-// TopologyManager.
-// releaseReadLockForApplication(applicationUndeployedEvent.getApplicationId());
-// }
-// }
-// });
-
-
- topologyEventReceiver.addEventListener(new ApplicationTerminatingEventListener() {
+ topologyEventReceiver.addEventListener(new ApplicationUndeployedEventListener() {
@Override
protected void onEvent(Event event) {
- log.info("[ApplicationTerminatingEvent] Received: " + event.getClass());
+ log.info("[ApplicationUndeployedEvent] Received: " + event.getClass());
- ApplicationTerminatingEvent appTerminatingEvent = (ApplicationTerminatingEvent) event;
+ ApplicationUndeployedEvent applicationUndeployedEvent = (ApplicationUndeployedEvent) event;
// acquire reead locks for application and relevant clusters
- TopologyManager.acquireReadLockForApplication(appTerminatingEvent.getAppId());
- Set<ClusterDataHolder> clusterDataHolders = appTerminatingEvent.getClusterData();
+ TopologyManager.acquireReadLockForApplication(applicationUndeployedEvent.getApplicationId());
+ Set<ClusterDataHolder> clusterDataHolders = applicationUndeployedEvent.getClusterData();
if (clusterDataHolders != null) {
for (ClusterDataHolder clusterData : clusterDataHolders) {
TopologyManager.acquireReadLockForCluster(clusterData.getServiceType(),
@@ -409,31 +347,31 @@ public class AutoscalerTopologyEventReceiver implements Runnable {
try {
ApplicationMonitor appMonitor = AutoscalerContext.getInstance().
- getAppMonitor(appTerminatingEvent.getAppId());
+ getAppMonitor(applicationUndeployedEvent.getApplicationId());
if (appMonitor != null) {
// update the status as Terminating
appMonitor.setStatus(ApplicationStatus.Terminating);
- List<String> clusters = appMonitor.
- findClustersOfApplication(appTerminatingEvent.getAppId());
+// List<String> clusters = appMonitor.
+// findClustersOfApplication(applicationUndeployedEvent.getApplicationId());
- for (String clusterId : clusters) {
+ for (ClusterDataHolder clusterData : clusterDataHolders) {
//stopping the cluster monitor and remove it from the AS
ClusterMonitor clusterMonitor =
- ((ClusterMonitor) AutoscalerContext.getInstance().getMonitor(clusterId));
+ ((ClusterMonitor) AutoscalerContext.getInstance().getMonitor(clusterData.getClusterId()));
if (clusterMonitor != null) {
clusterMonitor.setDestroyed(true);
clusterMonitor.terminateAllMembers();
clusterMonitor.setStatus(ClusterStatus.Terminating);
} else {
- log.warn("No Cluster Monitor found for cluster id " + clusterId);
+ log.warn("No Cluster Monitor found for cluster id " + clusterData.getClusterId());
}
}
} else {
log.warn("Application Monitor cannot be found for the undeployed [application] "
- + appTerminatingEvent.getAppId());
+ + applicationUndeployedEvent.getApplicationId());
}
} finally {
@@ -444,6 +382,38 @@ public class AutoscalerTopologyEventReceiver implements Runnable {
}
}
TopologyManager.
+ releaseReadLockForApplication(applicationUndeployedEvent.getApplicationId());
+ }
+ }
+ });
+
+
+ topologyEventReceiver.addEventListener(new ApplicationTerminatingEventListener() {
+ @Override
+ protected void onEvent(Event event) {
+
+ log.info("[ApplicationTerminatingEvent] Received: " + event.getClass());
+
+ ApplicationTerminatingEvent appTerminatingEvent = (ApplicationTerminatingEvent) event;
+
+ // acquire reead locks for application and relevant clusters
+ TopologyManager.acquireReadLockForApplication(appTerminatingEvent.getAppId());
+
+ try {
+ ApplicationMonitor appMonitor = AutoscalerContext.getInstance().
+ getAppMonitor(appTerminatingEvent.getAppId());
+
+ if (appMonitor != null) {
+ // update the status as Terminating
+ appMonitor.setStatus(ApplicationStatus.Terminating);
+
+ } else {
+ log.warn("Application Monitor cannot be found for the undeployed [application] "
+ + appTerminatingEvent.getAppId());
+ }
+
+ } finally {
+ TopologyManager.
releaseReadLockForApplication(appTerminatingEvent.getAppId());
}
}
@@ -472,12 +442,13 @@ public class AutoscalerTopologyEventReceiver implements Runnable {
ApplicationMonitor monitor = AutoscalerContext.getInstance().
getAppMonitor(applicationRemovedEvent.getApplicationId());
if (monitor != null) {
- List<String> clusters = monitor.
- findClustersOfApplication(applicationRemovedEvent.getApplicationId());
- for (String clusterId : clusters) {
+ //List<String> clusters = monitor.
+ // findClustersOfApplication(applicationRemovedEvent.getApplicationId());
+ for (ClusterDataHolder clusterData : clusterDataHolders) {
//stopping the cluster monitor and remove it from the AS
- ((ClusterMonitor) AutoscalerContext.getInstance().getMonitor(clusterId)).setDestroyed(true);
- AutoscalerContext.getInstance().removeMonitor(clusterId);
+ ((ClusterMonitor) AutoscalerContext.getInstance().getMonitor(clusterData.getClusterId())).
+ setDestroyed(true);
+ AutoscalerContext.getInstance().removeMonitor(clusterData.getClusterId());
}
//removing the application monitor
AutoscalerContext.getInstance().
http://git-wip-us.apache.org/repos/asf/stratos/blob/4f59f4b8/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/Monitor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/Monitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/Monitor.java
index 1ac0893..7199ee8 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/Monitor.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/Monitor.java
@@ -73,7 +73,7 @@ public abstract class Monitor implements EventHandler {
this.appId = parent.getAppId();
}
- public boolean hasMonitors() {
+ public boolean hasActiveMonitors() {
boolean hasMonitor = false;
if(this.aliasToActiveMonitorsMap != null ) {
hasMonitor = true;
@@ -81,6 +81,11 @@ public abstract class Monitor implements EventHandler {
return hasMonitor;
}
+ public boolean hasMonitors () {
+
+ return this.aliasToActiveMonitorsMap != null || this.aliasToInActiveMonitorsMap != null;
+ }
+
public boolean isHasDependent() {
return hasDependent;
}
http://git-wip-us.apache.org/repos/asf/stratos/blob/4f59f4b8/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ParentComponentMonitor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ParentComponentMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ParentComponentMonitor.java
index 26eff1d..4eb4bcb 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ParentComponentMonitor.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ParentComponentMonitor.java
@@ -20,7 +20,6 @@ package org.apache.stratos.autoscaler.monitor;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.autoscaler.AutoscalerContext;
import org.apache.stratos.autoscaler.exception.DependencyBuilderException;
import org.apache.stratos.autoscaler.exception.PartitionValidationException;
import org.apache.stratos.autoscaler.exception.PolicyValidationException;
@@ -96,16 +95,19 @@ public abstract class ParentComponentMonitor extends Monitor {
Monitor monitor = this.aliasToInActiveMonitorsMap.get(idOfEvent);
if (monitor != null) {
- for (Monitor monitor1 : monitor.getAliasToActiveMonitorsMap().values()) {
- if (monitor.hasMonitors()) {
- StatusEventPublisher.sendGroupTerminatingEvent(this.appId, monitor1.getId());
- } else {
- StatusEventPublisher.sendClusterTerminatingEvent(this.appId,
- ((AbstractClusterMonitor) monitor1).getServiceId(), monitor.getId());
+ // check if aliasToActiveMonitors are null (in case of a Cluster Monitor)
+ if (monitor.getAliasToActiveMonitorsMap() != null) {
+ for (Monitor monitor1 : monitor.getAliasToActiveMonitorsMap().values()) {
+ if (monitor.hasActiveMonitors()) {
+ StatusEventPublisher.sendGroupTerminatingEvent(this.appId, monitor1.getId());
+ } else {
+ StatusEventPublisher.sendClusterTerminatingEvent(this.appId,
+ ((AbstractClusterMonitor) monitor1).getServiceId(), monitor.getId());
+ }
}
}
} else {
- log.warn("Active Monitor not found for the id " + idOfEvent);
+ log.warn("Inactive Monitor not found for the id " + idOfEvent);
}
}
@@ -123,7 +125,7 @@ public abstract class ParentComponentMonitor extends Monitor {
monitor = this.aliasToActiveMonitorsMap.
get(terminationContext.getId());
//start to kill it
- if (monitor.hasMonitors()) {
+ if (monitor.hasActiveMonitors()) {
//it is a group
StatusEventPublisher.sendGroupTerminatingEvent(this.appId, terminationContext.getId());
} else {
http://git-wip-us.apache.org/repos/asf/stratos/blob/4f59f4b8/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 deb0950..45530c5 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
@@ -61,26 +61,26 @@ public class ApplicationMonitor extends ParentComponentMonitor {
* @param appId the application which contains the clusters
* @return all the clusters of the application
*/
- public List<String> findClustersOfApplication(String appId) {
- List<String> clusters = new ArrayList<String>();
- Set<ClusterDataHolder> clusterData;
-
- TopologyManager.acquireReadLockForApplication(appId);
- try {
- clusterData = TopologyManager.getTopology().getApplication(appId).getClusterDataRecursively();
-
- } finally {
- TopologyManager.releaseReadLockForApplication(appId);
- }
-
- if (clusterData != null) {
- for (ClusterDataHolder clusterDataHolder : clusterData) {
- clusters.add(clusterDataHolder.getClusterId());
- }
- }
-
- return clusters;
- }
+// public List<String> findClustersOfApplication(String appId) {
+// List<String> clusters = new ArrayList<String>();
+// Set<ClusterDataHolder> clusterData;
+//
+// TopologyManager.acquireReadLockForApplication(appId);
+// try {
+// clusterData = TopologyManager.getTopology().getApplication(appId).getClusterDataRecursively();
+//
+// } finally {
+// TopologyManager.releaseReadLockForApplication(appId);
+// }
+//
+// if (clusterData != null) {
+// for (ClusterDataHolder clusterDataHolder : clusterData) {
+// clusters.add(clusterDataHolder.getClusterId());
+// }
+// }
+//
+// return clusters;
+// }
/**
* Find the cluster monitor by traversing recursively in the hierarchical monitors.
http://git-wip-us.apache.org/repos/asf/stratos/blob/4f59f4b8/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java
index 7aef08e..7019d0b 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java
@@ -82,6 +82,9 @@ public class StatusChecker {
//TODO
StatusEventPublisher.sendClusterCreatedEvent(monitor.getAppId(), monitor.getServiceId(),
monitor.getClusterId());
+ } else {
+ StatusEventPublisher.sendClusterTerminatedEvent(monitor.getAppId(), monitor.getServiceId(),
+ monitor.getClusterId());
}
// TODO if cluster was in terminating, then send terminated event.
}
@@ -264,9 +267,9 @@ public class StatusChecker {
clusterData.isEmpty() && groupStatus == GroupStatus.Inactive ||
groupStatus == GroupStatus.Inactive && clusterStatus == ClusterStatus.Inactive) {
//send the in activation event
- if (parent instanceof Application) {
- //send application activated event
- log.info("sending app in-active : " + appId);
+ if (parent instanceof Application) {
+ //send application activated event
+ log.info("sending app in-active : " + appId);
StatusEventPublisher.sendApplicationInactivatedEvent(appId);
} else if (parent instanceof Group) {
//send activation to the parent
@@ -294,12 +297,12 @@ public class StatusChecker {
if (parent instanceof Application) {
//send application activated event
log.info("sending app terminating: " + appId);
- StatusEventPublisher.sendApplicationTerminatedEvent(appId, parent.getClusterDataRecursively());
+ StatusEventPublisher.sendApplicationTerminatingEvent(appId);
//StatusEventPublisher.sendApp(appId);
} else if (parent instanceof Group) {
//send activation to the parent
log.info("sending group terminating : " + parent.getUniqueIdentifier());
- StatusEventPublisher.sendGroupTerminatedEvent(appId, parent.getUniqueIdentifier());
+ StatusEventPublisher.sendGroupTerminatingEvent(appId, parent.getUniqueIdentifier());
}
} else {
log.warn("Clusters/groups not found in this [component] " + appId);
http://git-wip-us.apache.org/repos/asf/stratos/blob/4f59f4b8/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/status/receiver/ApplicationStatusTopicReceiver.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/status/receiver/ApplicationStatusTopicReceiver.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/status/receiver/ApplicationStatusTopicReceiver.java
index 5aa4467..1a62fef 100644
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/status/receiver/ApplicationStatusTopicReceiver.java
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/status/receiver/ApplicationStatusTopicReceiver.java
@@ -74,14 +74,14 @@ public class ApplicationStatusTopicReceiver implements Runnable {
statusEventReceiver.addEventListener(new AppStatusClusterTerminatedEventListener() {
@Override
protected void onEvent(Event event) {
- TopologyBuilder.handleClusterTerminatedEvent((ClusterActivatedEvent) event);
+ TopologyBuilder.handleClusterTerminatedEvent((AppStatusClusterTerminatedEvent) event);
}
});
statusEventReceiver.addEventListener(new AppStatusClusterTerminatingEventListener(){
@Override
protected void onEvent(Event event) {
- TopologyBuilder.handleClusterTerminatingEvent((ClusterActivatedEvent) event);
+ TopologyBuilder.handleClusterTerminatingEvent((AppStatusClusterTerminatingEvent) event);
}
});
http://git-wip-us.apache.org/repos/asf/stratos/blob/4f59f4b8/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java
index 2fbf89a..0b322f8 100644
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java
@@ -1415,9 +1415,7 @@ public class CloudControllerServiceImpl implements CloudControllerService {
@Override
public void unDeployApplicationDefinition(String applicationId, int tenantId, String tenantDomain) throws ApplicationDefinitionException {
- TopologyBuilder.handleApplicationUndeployed(dataHolder, applicationId, tenantId, tenantDomain);
-
- //persist();
+ TopologyBuilder.handleApplicationUndeployed(applicationId);
}
}
http://git-wip-us.apache.org/repos/asf/stratos/blob/4f59f4b8/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java
index d245a6f..4d929b1 100644
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java
@@ -678,8 +678,7 @@ public class TopologyBuilder {
}
}
- public static synchronized void handleApplicationUndeployed(FasterLookUpDataHolder dataHolder,
- String applicationId, int tenantId, String tenantDomain) {
+ public static synchronized void handleApplicationUndeployed(String applicationId) {
Set<ClusterDataHolder> clusterData;
@@ -702,7 +701,6 @@ public class TopologyBuilder {
}
// for now anyway update the status forcefully
application.setStatus(ApplicationStatus.Terminating);
- log.info("Application " + applicationId + "'s status updated to " + ApplicationStatus.Terminating);
// update all the Clusters' statuses to 'Terminating'
clusterData = application.getClusterDataRecursively();
@@ -730,6 +728,13 @@ public class TopologyBuilder {
}
}
+ // update all Group's statuses to 'Terminating'
+ if (application.getGroups() != null) {
+ updateGroupStatusesRecursively(GroupStatus.Terminating, application.getGroups());
+ }
+
+ TopologyManager.updateTopology(topology);
+
} finally {
TopologyManager.releaseWriteLock();
}
@@ -934,10 +939,9 @@ public class TopologyBuilder {
public static void handleApplicationTerminatingEvent(ApplicationTerminatingEvent event) {
- Set<ClusterDataHolder> clusterData;
String applicationId = event.getAppId();
- // update the Application and Cluster Statuses as 'Terminating'
+ // update the Application Status as 'Terminating'
TopologyManager.acquireWriteLock();
try {
@@ -958,44 +962,12 @@ public class TopologyBuilder {
application.setStatus(ApplicationStatus.Terminating);
log.info("Application " + applicationId + "'s status updated to " + ApplicationStatus.Terminating);
- // update all the Clusters' statuses to 'Terminating'
- clusterData = application.getClusterDataRecursively();
- for (ClusterDataHolder clusterDataHolder : clusterData) {
- Service service = topology.getService(clusterDataHolder.getServiceType());
- if (service != null) {
- Cluster aCluster = service.getCluster(clusterDataHolder.getClusterId());
- if (aCluster != null) {
- // validate state transition
- if (!aCluster.isStateTransitionValid(ClusterStatus.Terminating)) {
- log.error("Invalid state transfer from " + aCluster.getStatus() + " to "
- + ClusterStatus.Terminating);
- }
- // for now anyway update the status forcefully
- aCluster.setStatus(ClusterStatus.Terminating);
-
- } else {
- log.warn("Unable to find Cluster with cluster id " + clusterDataHolder.getClusterId() +
- " in Topology");
- }
-
- } else {
- log.warn("Unable to update cluster with cluster id: " + clusterDataHolder.getClusterId() + " from Topology, " +
- " associated Service [ " + clusterDataHolder.getServiceType() + " ] not found");
- }
- }
-
- // update all Group's statuses to 'Terminating'
- if (application.getGroups() != null) {
- updateGroupStatusesRecursively(GroupStatus.Terminating, application.getGroups());
- }
-
} finally {
TopologyManager.releaseWriteLock();
}
TopologyEventPublisher.sendApplicationTerminatingEvent(
- new org.apache.stratos.messaging.event.topology.ApplicationTerminatingEvent(
- applicationId, clusterData));
+ new org.apache.stratos.messaging.event.topology.ApplicationTerminatingEvent(applicationId));
}
private static void updateGroupStatusesRecursively (GroupStatus groupStatus, Collection<Group> groups) {
@@ -1015,30 +987,6 @@ public class TopologyBuilder {
}
public static void handleApplicationTerminatedEvent(ApplicationTerminatedEvent event) {
-// Topology topology = TopologyManager.getTopology();
-// Application application = topology.getApplication(event.getAppId());
-// //update the status of the Group
-// if (application == null) {
-// log.warn(String.format("Application %s does not exist",
-// event.getAppId()));
-// return;
-// }
-//
-// org.apache.stratos.messaging.event.topology.ApplicationTerminatedEvent applicationTerminatedEvent =
-// new org.apache.stratos.messaging.event.topology.ApplicationTerminatedEvent(
-// event.getAppId());
-// try {
-// TopologyManager.acquireWriteLock();
-// application.setStatus(ApplicationStatus.Terminated);
-// log.info("Application terminated adding status started for Topology");
-//
-// TopologyManager.updateTopology(topology);
-// } finally {
-// TopologyManager.releaseWriteLock();
-// }
-// //publishing data
-// TopologyEventPublisher.sendApplicationTerminatedEvent(applicationTerminatedEvent);
-
Topology topology = TopologyManager.getTopology();
@@ -1051,6 +999,13 @@ public class TopologyBuilder {
} else {
Application application = topology.getApplication(event.getAppId());
+
+ if (!application.isStateTransitionValid(ApplicationStatus.Terminated)) {
+ log.error("Invalid status change from " + application.getStatus() + " to " + ApplicationStatus.Terminated);
+ }
+ // forcefully set status for now
+ application.setStatus(ApplicationStatus.Terminated);
+
int tenantId = application.getTenantId();
String tenantDomain = application.getTenantDomain();
Set<ClusterDataHolder> clusterData = application.getClusterDataRecursively();
@@ -1201,11 +1156,57 @@ public class TopologyBuilder {
TopologyEventPublisher.sendGroupTerminatingEvent(groupTerminatingTopologyEvent);
}
- public static void handleClusterTerminatedEvent(ClusterActivatedEvent event) {
+ public static void handleClusterTerminatedEvent(AppStatusClusterTerminatedEvent event) {
+
+ TopologyManager.acquireWriteLock();
+
+ try {
+ Topology topology = TopologyManager.getTopology();
+ Cluster cluster = topology.getService(event.getServiceName()).
+ getCluster(event.getClusterId());
+
+ if (!cluster.isStateTransitionValid(ClusterStatus.Terminated)) {
+ log.error("Invalid state transfer from " + cluster.getStatus() + " to " +
+ ClusterStatus.Terminated);
+ }
+ // forcefully update status
+ cluster.setStatus(ClusterStatus.Terminated);
+
+ TopologyManager.updateTopology(topology);
+ } finally {
+ TopologyManager.releaseWriteLock();
+ }
+
+ ClusterTerminatedEvent clusterTerminatedEvent = new ClusterTerminatedEvent(event.getAppId(),
+ event.getServiceName(), event.getClusterId());
+ TopologyEventPublisher.sendClusterTerminatedEvent(clusterTerminatedEvent);
}
- public static void handleClusterTerminatingEvent(ClusterActivatedEvent event) {
+ public static void handleClusterTerminatingEvent(AppStatusClusterTerminatingEvent event) {
+
+ TopologyManager.acquireWriteLock();
+
+ try {
+ Topology topology = TopologyManager.getTopology();
+ Cluster cluster = topology.getService(event.getServiceName()).
+ getCluster(event.getClusterId());
+
+ if (!cluster.isStateTransitionValid(ClusterStatus.Terminating)) {
+ log.error("Invalid state transfer from " + cluster.getStatus() + " to " +
+ ClusterStatus.Terminating);
+ }
+ // forcefully update status
+ cluster.setStatus(ClusterStatus.Terminating);
+
+ TopologyManager.updateTopology(topology);
+ } finally {
+ TopologyManager.releaseWriteLock();
+ }
+
+ ClusterTerminatingEvent clusterTerminaingEvent = new ClusterTerminatingEvent(event.getAppId(),
+ event.getServiceName(), event.getClusterId());
+ TopologyEventPublisher.sendClusterTerminatingEvent(clusterTerminaingEvent);
}
}
http://git-wip-us.apache.org/repos/asf/stratos/blob/4f59f4b8/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyEventPublisher.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyEventPublisher.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyEventPublisher.java
index 3c6277d..cd13111 100644
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyEventPublisher.java
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyEventPublisher.java
@@ -297,4 +297,24 @@ public class TopologyEventPublisher {
}
publishEvent(groupTerminatingTopologyEvent);
}
+
+ public static void sendClusterTerminatingEvent (ClusterTerminatingEvent clusterTerminatingEvent) {
+
+ if(log.isInfoEnabled()) {
+ log.info(String.format("Publishing Cluster terminating event: [appId] %s [cluster id] %s",
+ clusterTerminatingEvent.getAppId(), clusterTerminatingEvent.getClusterId()));
+ }
+
+ publishEvent(clusterTerminatingEvent);
+ }
+
+ public static void sendClusterTerminatedEvent (ClusterTerminatedEvent clusterTerminatedEvent) {
+
+ if(log.isInfoEnabled()) {
+ log.info(String.format("Publishing Cluster terminated event: [appId] %s [cluster id] %s",
+ clusterTerminatedEvent.getAppId(), clusterTerminatedEvent.getClusterId()));
+ }
+
+ publishEvent(clusterTerminatedEvent);
+ }
}
http://git-wip-us.apache.org/repos/asf/stratos/blob/4f59f4b8/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ApplicationTerminatedEvent.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ApplicationTerminatedEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ApplicationTerminatedEvent.java
index 441b902..6607a02 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ApplicationTerminatedEvent.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ApplicationTerminatedEvent.java
@@ -18,17 +18,27 @@
*/
package org.apache.stratos.messaging.event.topology;
+import org.apache.stratos.messaging.domain.topology.ClusterDataHolder;
+
+import java.util.Set;
+
/**
* This event will be sent to Topology upon termination of application
*/
public class ApplicationTerminatedEvent extends TopologyEvent {
private final String appId;
+ private final Set<ClusterDataHolder> clusterData;
- public ApplicationTerminatedEvent(String appId) {
+ public ApplicationTerminatedEvent(String appId, Set<ClusterDataHolder> clusterData) {
this.appId = appId;
+ this.clusterData = clusterData;
}
public String getAppId() {
return appId;
}
+
+ public Set<ClusterDataHolder> getClusterData() {
+ return clusterData;
+ }
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/stratos/blob/4f59f4b8/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ApplicationTerminatingEvent.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ApplicationTerminatingEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ApplicationTerminatingEvent.java
index c718f08..48fde61 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ApplicationTerminatingEvent.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ApplicationTerminatingEvent.java
@@ -18,28 +18,18 @@
*/
package org.apache.stratos.messaging.event.topology;
-import org.apache.stratos.messaging.domain.topology.ClusterDataHolder;
-
-import java.util.Set;
-
/**
* This event will be sent to Topology upon terminating of application
*/
public class ApplicationTerminatingEvent extends TopologyEvent {
private final String appId;
- private Set<ClusterDataHolder> clusterData;
- public ApplicationTerminatingEvent(String appId, Set<ClusterDataHolder> clusterData) {
+ public ApplicationTerminatingEvent(String appId) {
this.appId = appId;
- this.clusterData = clusterData;
}
public String getAppId() {
return appId;
}
-
- public Set<ClusterDataHolder> getClusterData() {
- return clusterData;
- }
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/stratos/blob/4f59f4b8/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusClusterTerminatedMessageProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusClusterTerminatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusClusterTerminatedMessageProcessor.java
index a5bed11..6cdde51 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusClusterTerminatedMessageProcessor.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusClusterTerminatedMessageProcessor.java
@@ -39,7 +39,7 @@ public class AppStatusClusterTerminatedMessageProcessor extends MessageProcessor
public boolean process(String type, String message, Object object) {
if (AppStatusClusterTerminatedEvent.class.getName().equals(type)) {
// Parse complete message and build event
- ClusterTerminatedEvent event = (ClusterTerminatedEvent) Util.
+ AppStatusClusterTerminatedEvent event = (AppStatusClusterTerminatedEvent) Util.
jsonToObject(message, AppStatusClusterTerminatedEvent.class);
if(log.isDebugEnabled()) {
http://git-wip-us.apache.org/repos/asf/stratos/blob/4f59f4b8/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationTerminatingMessageProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationTerminatingMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationTerminatingMessageProcessor.java
index cb6e887..6ad43d8 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationTerminatingMessageProcessor.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationTerminatingMessageProcessor.java
@@ -23,7 +23,7 @@ import org.apache.commons.logging.LogFactory;
import org.apache.stratos.messaging.domain.topology.Application;
import org.apache.stratos.messaging.domain.topology.ApplicationStatus;
import org.apache.stratos.messaging.domain.topology.Topology;
-import org.apache.stratos.messaging.event.topology.ApplicationInactivatedEvent;
+import org.apache.stratos.messaging.event.topology.ApplicationTerminatingEvent;
import org.apache.stratos.messaging.message.processor.MessageProcessor;
import org.apache.stratos.messaging.message.processor.topology.updater.TopologyUpdater;
import org.apache.stratos.messaging.util.Util;
@@ -48,14 +48,14 @@ public class ApplicationTerminatingMessageProcessor extends MessageProcessor {
public boolean process(String type, String message, Object object) {
Topology topology = (Topology) object;
- if (ApplicationInactivatedEvent.class.getName().equals(type)) {
+ if (ApplicationTerminatingEvent.class.getName().equals(type)) {
// Return if topology has not been initialized
if (!topology.isInitialized())
return false;
// Parse complete message and build event
- ApplicationInactivatedEvent event = (ApplicationInactivatedEvent) Util.
- jsonToObject(message, ApplicationInactivatedEvent.class);
+ ApplicationTerminatingEvent event = (ApplicationTerminatingEvent) Util.
+ jsonToObject(message, ApplicationTerminatingEvent.class);
TopologyUpdater.acquireWriteLockForApplication(event.getAppId());
@@ -76,7 +76,7 @@ public class ApplicationTerminatingMessageProcessor extends MessageProcessor {
}
}
- private boolean doProcess (ApplicationInactivatedEvent event, Topology topology) {
+ private boolean doProcess (ApplicationTerminatingEvent event, Topology topology) {
// Validate event against the existing topology
Application application = topology.getApplication(event.getAppId());
http://git-wip-us.apache.org/repos/asf/stratos/blob/4f59f4b8/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterTerminatedProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterTerminatedProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterTerminatedProcessor.java
index 0536011..98599d3 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterTerminatedProcessor.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterTerminatedProcessor.java
@@ -24,7 +24,7 @@ import org.apache.stratos.messaging.domain.topology.Cluster;
import org.apache.stratos.messaging.domain.topology.ClusterStatus;
import org.apache.stratos.messaging.domain.topology.Service;
import org.apache.stratos.messaging.domain.topology.Topology;
-import org.apache.stratos.messaging.event.topology.ClusterActivatedEvent;
+import org.apache.stratos.messaging.event.topology.ClusterTerminatedEvent;
import org.apache.stratos.messaging.message.filter.topology.TopologyClusterFilter;
import org.apache.stratos.messaging.message.filter.topology.TopologyServiceFilter;
import org.apache.stratos.messaging.message.processor.MessageProcessor;
@@ -48,15 +48,15 @@ public class ClusterTerminatedProcessor extends MessageProcessor {
Topology topology = (Topology) object;
- if (ClusterActivatedEvent.class.getName().equals(type)) {
+ if (ClusterTerminatedEvent.class.getName().equals(type)) {
// Return if topology has not been initialized
if (!topology.isInitialized()) {
return false;
}
// Parse complete message and build event
- ClusterActivatedEvent event = (ClusterActivatedEvent) Util.
- jsonToObject(message, ClusterActivatedEvent.class);
+ ClusterTerminatedEvent event = (ClusterTerminatedEvent) Util.
+ jsonToObject(message, ClusterTerminatedEvent.class);
TopologyUpdater.acquireWriteLockForCluster(event.getServiceName(), event.getClusterId());
try {
@@ -76,7 +76,7 @@ public class ClusterTerminatedProcessor extends MessageProcessor {
}
}
- private boolean doProcess(ClusterActivatedEvent event, Topology topology) {
+ private boolean doProcess(ClusterTerminatedEvent event, Topology topology) {
// Apply service filter
if (TopologyServiceFilter.getInstance().isActive()) {
@@ -118,10 +118,10 @@ public class ClusterTerminatedProcessor extends MessageProcessor {
}
} else {
// Apply changes to the topology
- if (!cluster.isStateTransitionValid(ClusterStatus.Active)) {
- log.error("Invalid State Transition from " + cluster.getStatus() + " to " + ClusterStatus.Active);
+ if (!cluster.isStateTransitionValid(ClusterStatus.Terminated)) {
+ log.error("Invalid State Transition from " + cluster.getStatus() + " to " + ClusterStatus.Terminated);
}
- cluster.setStatus(ClusterStatus.Active);
+ cluster.setStatus(ClusterStatus.Terminated);
}
http://git-wip-us.apache.org/repos/asf/stratos/blob/4f59f4b8/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterTerminatingProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterTerminatingProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterTerminatingProcessor.java
index 1ed2671..cd30618 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterTerminatingProcessor.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterTerminatingProcessor.java
@@ -24,7 +24,7 @@ import org.apache.stratos.messaging.domain.topology.Cluster;
import org.apache.stratos.messaging.domain.topology.ClusterStatus;
import org.apache.stratos.messaging.domain.topology.Service;
import org.apache.stratos.messaging.domain.topology.Topology;
-import org.apache.stratos.messaging.event.topology.ClusterActivatedEvent;
+import org.apache.stratos.messaging.event.topology.ClusterTerminatingEvent;
import org.apache.stratos.messaging.message.filter.topology.TopologyClusterFilter;
import org.apache.stratos.messaging.message.filter.topology.TopologyServiceFilter;
import org.apache.stratos.messaging.message.processor.MessageProcessor;
@@ -48,15 +48,15 @@ public class ClusterTerminatingProcessor extends MessageProcessor {
Topology topology = (Topology) object;
- if (ClusterActivatedEvent.class.getName().equals(type)) {
+ if (ClusterTerminatingEvent.class.getName().equals(type)) {
// Return if topology has not been initialized
if (!topology.isInitialized()) {
return false;
}
// Parse complete message and build event
- ClusterActivatedEvent event = (ClusterActivatedEvent) Util.
- jsonToObject(message, ClusterActivatedEvent.class);
+ ClusterTerminatingEvent event = (ClusterTerminatingEvent) Util.
+ jsonToObject(message, ClusterTerminatingEvent.class);
TopologyUpdater.acquireWriteLockForCluster(event.getServiceName(), event.getClusterId());
try {
@@ -76,7 +76,7 @@ public class ClusterTerminatingProcessor extends MessageProcessor {
}
}
- private boolean doProcess(ClusterActivatedEvent event, Topology topology) {
+ private boolean doProcess(ClusterTerminatingEvent event, Topology topology) {
// Apply service filter
if (TopologyServiceFilter.getInstance().isActive()) {
@@ -118,10 +118,10 @@ public class ClusterTerminatingProcessor extends MessageProcessor {
}
} else {
// Apply changes to the topology
- if (!cluster.isStateTransitionValid(ClusterStatus.Active)) {
- log.error("Invalid State Transition from " + cluster.getStatus() + " to " + ClusterStatus.Active);
+ if (!cluster.isStateTransitionValid(ClusterStatus.Terminating)) {
+ log.error("Invalid State Transition from " + cluster.getStatus() + " to " + ClusterStatus.Terminating);
}
- cluster.setStatus(ClusterStatus.Active);
+ cluster.setStatus(ClusterStatus.Terminating);
}
http://git-wip-us.apache.org/repos/asf/stratos/blob/4f59f4b8/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupTerminatedProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupTerminatedProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupTerminatedProcessor.java
index 5e96709..5a308ba 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupTerminatedProcessor.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupTerminatedProcessor.java
@@ -93,8 +93,8 @@ public class GroupTerminatedProcessor extends MessageProcessor {
}
} else {
// Apply changes to the topology
- if (!group.isStateTransitionValid(GroupStatus.Terminating)) {
- log.error("Invalid State Transition from " + group.getStatus() + " to " + GroupStatus.Active);
+ if (!group.isStateTransitionValid(GroupStatus.Terminated)) {
+ log.error("Invalid State Transition from " + group.getStatus() + " to " + GroupStatus.Terminated);
}
group.setStatus(GroupStatus.Terminated);
[38/50] [abbrv] git commit: refatcoring the monitors
Posted by im...@apache.org.
refatcoring the monitors
Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/55e3eff1
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/55e3eff1
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/55e3eff1
Branch: refs/heads/docker-grouping-merge
Commit: 55e3eff1fb0a8a341c1adc0f9122aaad33be0756
Parents: 062cd7b
Author: reka <rt...@gmail.com>
Authored: Wed Oct 29 15:40:54 2014 +0530
Committer: reka <rt...@gmail.com>
Committed: Wed Oct 29 15:40:54 2014 +0530
----------------------------------------------------------------------
.../monitor/ParentComponentMonitor.java | 10 +----
.../monitor/application/ApplicationMonitor.java | 41 ++++++++---------
.../autoscaler/monitor/group/GroupMonitor.java | 47 +++++++++-----------
3 files changed, 41 insertions(+), 57 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/stratos/blob/55e3eff1/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ParentComponentMonitor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ParentComponentMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ParentComponentMonitor.java
index f6857f7..298516c 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ParentComponentMonitor.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ParentComponentMonitor.java
@@ -55,15 +55,7 @@ public abstract class ParentComponentMonitor extends Monitor {
//Building the dependency for this monitor within the immediate children
dependencyTree = DependencyBuilder.getInstance().buildDependency(component);
}
-
- /**
- * Will monitor the immediate children upon any event triggers from parent/children
- *
- * @param statusEvent will be sent by parent/children with the current status
- */
- protected abstract void monitor(MonitorStatusEvent statusEvent);
-
-
+
/**
* This will start the child monitors based on the active of siblings according to start up order
*
http://git-wip-us.apache.org/repos/asf/stratos/blob/55e3eff1/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 337a5c5..35f4a70 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
@@ -22,7 +22,6 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.stratos.autoscaler.exception.DependencyBuilderException;
import org.apache.stratos.autoscaler.exception.TopologyInConsistentException;
-import org.apache.stratos.autoscaler.grouping.dependency.context.ApplicationContext;
import org.apache.stratos.autoscaler.monitor.AbstractClusterMonitor;
import org.apache.stratos.autoscaler.monitor.Monitor;
import org.apache.stratos.autoscaler.monitor.MonitorStatusEventBuilder;
@@ -32,11 +31,13 @@ import org.apache.stratos.autoscaler.monitor.events.MonitorScalingEvent;
import org.apache.stratos.autoscaler.monitor.events.MonitorStatusEvent;
import org.apache.stratos.autoscaler.monitor.events.MonitorTerminateAllEvent;
import org.apache.stratos.autoscaler.status.checker.StatusChecker;
-import org.apache.stratos.messaging.domain.topology.*;
+import org.apache.stratos.messaging.domain.topology.Application;
+import org.apache.stratos.messaging.domain.topology.ApplicationStatus;
+import org.apache.stratos.messaging.domain.topology.ClusterStatus;
+import org.apache.stratos.messaging.domain.topology.GroupStatus;
import org.apache.stratos.messaging.domain.topology.lifecycle.LifeCycleState;
-import org.apache.stratos.messaging.message.receiver.topology.TopologyManager;
-import java.util.*;
+import java.util.Collection;
/**
* ApplicationMonitor is to control the child monitors
@@ -107,7 +108,7 @@ public class ApplicationMonitor extends ParentComponentMonitor {
public Monitor findGroupMonitorWithId(String groupId) {
Monitor monitor;
monitor = findGroupMonitor(groupId, aliasToActiveMonitorsMap.values());
- if(monitor == null) {
+ if (monitor == null) {
monitor = findGroupMonitor(groupId, aliasToInActiveMonitorsMap.values());
}
return monitor;
@@ -145,28 +146,13 @@ public class ApplicationMonitor extends ParentComponentMonitor {
log.info(String.format("[ApplicationMonitor] %s " +
"state changes from %s to %s", id, this.status, status));
- this.status = status;
- //notify the children about the state change
- MonitorStatusEventBuilder.notifyChildren(this.parent, new ApplicationStatusEvent(status, appId));
+ this.status = status;
+ //notify the children about the state change
+ MonitorStatusEventBuilder.notifyChildren(this.parent, new ApplicationStatusEvent(status, appId));
}
@Override
public void onChildEvent(MonitorStatusEvent statusEvent) {
- monitor(statusEvent);
- }
-
- @Override
- public void onEvent(MonitorTerminateAllEvent terminateAllEvent) {
-
- }
-
- @Override
- public void onEvent(MonitorScalingEvent scalingEvent) {
-
- }
-
- @Override
- protected void monitor(MonitorStatusEvent statusEvent) {
String id = statusEvent.getId();
LifeCycleState status1 = statusEvent.getStatus();
//Events coming from parent are In_Active(in faulty detection), Scaling events, termination
@@ -191,6 +177,15 @@ public class ApplicationMonitor extends ParentComponentMonitor {
log.info("Executing the un-subscription request for the [monitor] " + id);
}
}
+ }
+
+ @Override
+ public void onEvent(MonitorTerminateAllEvent terminateAllEvent) {
+
+ }
+
+ @Override
+ public void onEvent(MonitorScalingEvent scalingEvent) {
}
}
http://git-wip-us.apache.org/repos/asf/stratos/blob/55e3eff1/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java
index 2fe5ae7..64cc28c 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java
@@ -25,7 +25,10 @@ import org.apache.stratos.autoscaler.exception.TopologyInConsistentException;
import org.apache.stratos.autoscaler.monitor.EventHandler;
import org.apache.stratos.autoscaler.monitor.MonitorStatusEventBuilder;
import org.apache.stratos.autoscaler.monitor.ParentComponentMonitor;
-import org.apache.stratos.autoscaler.monitor.events.*;
+import org.apache.stratos.autoscaler.monitor.events.GroupStatusEvent;
+import org.apache.stratos.autoscaler.monitor.events.MonitorScalingEvent;
+import org.apache.stratos.autoscaler.monitor.events.MonitorStatusEvent;
+import org.apache.stratos.autoscaler.monitor.events.MonitorTerminateAllEvent;
import org.apache.stratos.autoscaler.status.checker.StatusChecker;
import org.apache.stratos.messaging.domain.topology.ClusterStatus;
import org.apache.stratos.messaging.domain.topology.Group;
@@ -58,22 +61,6 @@ public class GroupMonitor extends ParentComponentMonitor implements EventHandler
@Override
public void onChildEvent(MonitorStatusEvent statusEvent) {
- monitor(statusEvent);
- }
-
- @Override
- public void onEvent(MonitorTerminateAllEvent terminateAllEvent) {
- this.terminateChildren = true;
-
- }
-
- @Override
- public void onEvent(MonitorScalingEvent scalingEvent) {
-
- }
-
- @Override
- protected void monitor(MonitorStatusEvent statusEvent) {
String id = statusEvent.getId();
LifeCycleState status1 = statusEvent.getStatus();
//Events coming from parent are In_Active(in faulty detection), Scaling events, termination
@@ -99,6 +86,16 @@ public class GroupMonitor extends ParentComponentMonitor implements EventHandler
log.info("Executing the un-subscription request for the [monitor] " + id);
}
}
+ }
+
+ @Override
+ public void onEvent(MonitorTerminateAllEvent terminateAllEvent) {
+ this.terminateChildren = true;
+
+ }
+
+ @Override
+ public void onEvent(MonitorScalingEvent scalingEvent) {
}
@@ -139,14 +136,14 @@ public class GroupMonitor extends ParentComponentMonitor implements EventHandler
log.info(String.format("[Monitor] %s is notifying the parent" +
"on its state change from %s to %s", id, this.status, status));
//if(this.status != status) {
- this.status = status;
- //notifying the parent
- if (status == GroupStatus.Inactive && !this.hasDependent) {
- log.info("[Group] " + this.id + "is not notifying the parent, " +
- "since it is identified as the independent unit");
- } else {
- MonitorStatusEventBuilder.handleGroupStatusEvent(this.parent, this.status, this.id);
- }
+ this.status = status;
+ //notifying the parent
+ if (status == GroupStatus.Inactive && !this.hasDependent) {
+ log.info("[Group] " + this.id + "is not notifying the parent, " +
+ "since it is identified as the independent unit");
+ } else {
+ MonitorStatusEventBuilder.handleGroupStatusEvent(this.parent, this.status, this.id);
+ }
//}
//notify the children about the state change
MonitorStatusEventBuilder.notifyChildren(this.parent, new GroupStatusEvent(status, getId()));
[40/50] [abbrv] git commit: fixing a NPE is ApplicationMonitor
Posted by im...@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/docker-grouping-merge
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
[27/50] [abbrv] git commit: change configuration of
metadataservice.xml
Posted by im...@apache.org.
change configuration of metadataservice.xml
Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/ae75efc3
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/ae75efc3
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/ae75efc3
Branch: refs/heads/docker-grouping-merge
Commit: ae75efc371f17d7c11db207c288cbf2e466bdf03
Parents: 7618c7b
Author: Udara Liyanage <ud...@wso2.com>
Authored: Tue Oct 28 16:36:58 2014 +0530
Committer: Udara Liyanage <ud...@wso2.com>
Committed: Tue Oct 28 16:36:58 2014 +0530
----------------------------------------------------------------------
.../distribution/src/main/conf/metadataservice.xml | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/stratos/blob/ae75efc3/products/stratos/modules/distribution/src/main/conf/metadataservice.xml
----------------------------------------------------------------------
diff --git a/products/stratos/modules/distribution/src/main/conf/metadataservice.xml b/products/stratos/modules/distribution/src/main/conf/metadataservice.xml
index 5e8bb1d..5073e24 100644
--- a/products/stratos/modules/distribution/src/main/conf/metadataservice.xml
+++ b/products/stratos/modules/distribution/src/main/conf/metadataservice.xml
@@ -18,6 +18,7 @@
under the License.
-->
<configuration>
+ <!--
<metadataservice>
<govenanceregistrytype>carbon</govenanceregistrytype>
<serverurl>https://localhost:9445/services/</serverurl>
@@ -30,8 +31,13 @@
<trustStore>repository/resources/security/wso2carbon.jks</trustStore>
<trustStorePassword>wso2carbon</trustStorePassword>
<trustStoreType>JKS</trustStoreType>
-
-
-
</metadataservice>
+ -->
+ <metadataService>
+ <baseUrl>https://localhost:9443/stratosmetadataservice/</baseUrl>
+ <username>admin</username>
+ <password>admin</password>
+ </metadataService>
+ <metadataClient>
+ </metadataClient>
</configuration>
[15/50] [abbrv] git commit: stopping transitions to self in
LifeCycleStateManager
Posted by im...@apache.org.
stopping transitions to self in LifeCycleStateManager
Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/4f6b5fe6
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/4f6b5fe6
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/4f6b5fe6
Branch: refs/heads/docker-grouping-merge
Commit: 4f6b5fe63f01c2767800edfb00c0e48d765c161a
Parents: 2f1b92b
Author: Isuru Haththotuwa <is...@apache.org>
Authored: Mon Oct 27 18:48:35 2014 +0530
Committer: Isuru Haththotuwa <is...@apache.org>
Committed: Mon Oct 27 18:48:47 2014 +0530
----------------------------------------------------------------------
.../lifecycle/LifeCycleStateManager.java | 19 +++++++++++++------
1 file changed, 13 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/stratos/blob/4f6b5fe6/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/lifecycle/LifeCycleStateManager.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/lifecycle/LifeCycleStateManager.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/lifecycle/LifeCycleStateManager.java
index f57edf8..db8d5d4 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/lifecycle/LifeCycleStateManager.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/lifecycle/LifeCycleStateManager.java
@@ -70,15 +70,22 @@ public class LifeCycleStateManager<T extends LifeCycleState> implements Serializ
}
/**
- * Changes the current state to nextState
+ * Changes the current state to nextState, if nextState is not as same as the current state
*
* @param nextState the next state to change
*/
- public void changeState (T nextState) {
-
- stateStack.push(nextState);
- log.info("Topology element [ " + identifier + " ]'s life Cycle State changed from [ " +
- getPreviousState() + " ] to [ " + getCurrentState() + " ]");
+ public synchronized void changeState (T nextState) {
+
+ if (getCurrentState() != nextState) {
+ stateStack.push(nextState);
+ log.info("Topology element [ " + identifier + " ]'s life Cycle State changed from [ " +
+ getPreviousState() + " ] to [ " + getCurrentState() + " ]");
+ } else {
+ if (log.isDebugEnabled()) {
+ log.debug("Topology element [ " + identifier +" ]'s life Cycle State has been " +
+ "already updated to [ " + nextState + " ]");
+ }
+ }
if (log.isDebugEnabled()) {
printStateTransitions(stateStack);
}
[37/50] [abbrv] git commit: fixing issue when terminating the cluster
Posted by im...@apache.org.
fixing issue when terminating the cluster
Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/062cd7b4
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/062cd7b4
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/062cd7b4
Branch: refs/heads/docker-grouping-merge
Commit: 062cd7b404e2b4c506de72399b487a85855786f4
Parents: fcd8a7c
Author: reka <rt...@gmail.com>
Authored: Wed Oct 29 15:32:45 2014 +0530
Committer: reka <rt...@gmail.com>
Committed: Wed Oct 29 15:34:22 2014 +0530
----------------------------------------------------------------------
.../topic/InstanceNotificationPublisher.java | 11 +
.../AutoscalerTopologyEventReceiver.java | 16 +-
.../monitor/ParentComponentMonitor.java | 312 ++-----------------
3 files changed, 45 insertions(+), 294 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/stratos/blob/062cd7b4/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/InstanceNotificationPublisher.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/InstanceNotificationPublisher.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/InstanceNotificationPublisher.java
index d745d79..80fa295 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/InstanceNotificationPublisher.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/InstanceNotificationPublisher.java
@@ -25,6 +25,7 @@ import org.apache.stratos.messaging.broker.publish.EventPublisher;
import org.apache.stratos.messaging.broker.publish.EventPublisherPool;
import org.apache.stratos.messaging.event.Event;
import org.apache.stratos.messaging.event.instance.notifier.InstanceCleanupClusterEvent;
+import org.apache.stratos.messaging.event.instance.notifier.InstanceCleanupMemberEvent;
import org.apache.stratos.messaging.util.Constants;
public class InstanceNotificationPublisher {
@@ -39,4 +40,14 @@ public class InstanceNotificationPublisher {
log.info(String.format("Publishing Instance Cleanup Event: [cluster] %s", clusterId));
publish(new InstanceCleanupClusterEvent(clusterId));
}
+
+ /**
+ * Publishing the instance termination notification to the instances
+ *
+ * @param memberId
+ */
+ public void sendInstanceCleanupEventForMember(String memberId) {
+ log.info(String.format("Publishing Instance Cleanup Event: [member] %s", memberId));
+ publish(new InstanceCleanupMemberEvent(memberId));
+ }
}
http://git-wip-us.apache.org/repos/asf/stratos/blob/062cd7b4/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 8c2d1a1..d66795c 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
@@ -206,22 +206,24 @@ public class AutoscalerTopologyEventReceiver implements Runnable {
log.info("[ClusterTerminatingEvent] Received: " + event.getClass());
ClusterTerminatingEvent clusterTerminatingEvent = (ClusterTerminatingEvent) event;
- String appId = clusterTerminatingEvent.getAppId();
String clusterId = clusterTerminatingEvent.getClusterId();
AbstractClusterMonitor clusterMonitor =
(AbstractClusterMonitor) AutoscalerContext.getInstance().getMonitor(clusterId);
//changing the status in the monitor, will notify its parent monitor
if (clusterMonitor != null) {
- clusterMonitor.setDestroyed(true);
- clusterMonitor.terminateAllMembers();
- clusterMonitor.setStatus(ClusterStatus.Terminating);
+ if (clusterMonitor.getStatus() == ClusterStatus.Active) {
+ // terminated gracefully
+ clusterMonitor.setStatus(ClusterStatus.Terminating);
+ InstanceNotificationPublisher.sendInstanceCleanupEventForCluster(clusterId);
+ } else {
+ clusterMonitor.setStatus(ClusterStatus.Terminating);
+ clusterMonitor.terminateAllMembers();
+ }
+
} else {
log.warn("No Cluster Monitor found for cluster id " + clusterId);
}
-
- //starting the status checker to decide on the status of it's parent
- //StatusChecker.getInstance().onClusterStatusChange(clusterId, appId);
}
});
http://git-wip-us.apache.org/repos/asf/stratos/blob/062cd7b4/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ParentComponentMonitor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ParentComponentMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ParentComponentMonitor.java
index 7ad0a43..f6857f7 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ParentComponentMonitor.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ParentComponentMonitor.java
@@ -44,12 +44,8 @@ import java.util.List;
public abstract class ParentComponentMonitor extends Monitor {
private static final Log log = LogFactory.getLog(ParentComponentMonitor.class);
- //id of the monitor, it can be alias or the id
- //protected String id;
- //The monitors dependency tree with all the startable/killable dependencies
+ //The monitors dependency tree with all the start-able/kill-able dependencies
protected DependencyTree dependencyTree;
- //Application id of this particular monitor
- //protected String appId;
public ParentComponentMonitor(ParentComponent component) throws DependencyBuilderException {
aliasToActiveMonitorsMap = new HashMap<String, Monitor>();
@@ -68,6 +64,11 @@ public abstract class ParentComponentMonitor extends Monitor {
protected abstract void monitor(MonitorStatusEvent statusEvent);
+ /**
+ * This will start the child monitors based on the active of siblings according to start up order
+ *
+ * @param idOfEvent parent id of the event which received
+ */
protected void onChildActivatedEvent(String idOfEvent) {
try {
//if the activated monitor is in in_active map move it to active map
@@ -89,7 +90,7 @@ public abstract class ParentComponentMonitor extends Monitor {
}
- protected void onChildTerminatingEvent(String idOfEvent) {
+ /*protected void onChildTerminatingEvent(String idOfEvent) {
//Check whether hasDependent true
if (!this.aliasToInActiveMonitorsMap.containsKey(idOfEvent)) {
this.aliasToInActiveMonitorsMap.put(idOfEvent, this.aliasToActiveMonitorsMap.remove(idOfEvent));
@@ -111,7 +112,7 @@ public abstract class ParentComponentMonitor extends Monitor {
} else {
log.warn("Inactive Monitor not found for the id " + idOfEvent);
}
- }
+ }*/
@Override
public void onParentEvent(MonitorStatusEvent statusEvent) {
@@ -146,6 +147,10 @@ public abstract class ParentComponentMonitor extends Monitor {
}
}
+ /**
+ *
+ * @param idOfEvent
+ */
protected void onChildInActiveEvent(String idOfEvent) {
List<ApplicationContext> terminationList;
Monitor monitor;
@@ -179,10 +184,12 @@ public abstract class ParentComponentMonitor extends Monitor {
if (monitor != null) {
if (monitor.hasActiveMonitors()) {
//it is a group
- StatusEventPublisher.sendGroupTerminatingEvent(this.appId, terminationContext.getId());
+ StatusEventPublisher.sendGroupTerminatingEvent(this.appId,
+ terminationContext.getId());
} else {
StatusEventPublisher.sendClusterTerminatingEvent(this.appId,
- ((AbstractClusterMonitor) monitor).getServiceId(), terminationContext.getId());
+ ((AbstractClusterMonitor) monitor).getServiceId(),
+ terminationContext.getId());
}
} else {
log.warn("The relevant [monitor] " + terminationContext.getId() +
@@ -191,8 +198,8 @@ public abstract class ParentComponentMonitor extends Monitor {
}
} else {
- log.warn("Wrong inActive event received from [Child] " + idOfEvent + " to the [parent]"
- + " where child is identified as a independent");
+ log.warn("Wrong inActive event received from [Child] " + idOfEvent +
+ " to the [parent]" + " where child is identified as a independent");
}
}
@@ -216,13 +223,14 @@ public abstract class ParentComponentMonitor extends Monitor {
*/
if (terminationList != null) {
for (ApplicationContext context1 : terminationList) {
- if (!this.aliasToInActiveMonitorsMap.containsKey(context1.getId())) {
- allDependentTerminated = false;
- } else if (this.aliasToActiveMonitorsMap.containsKey(context1.getId())) {
+ if (this.aliasToActiveMonitorsMap.containsKey(context1.getId())) {
log.warn("Dependent [monitor] " + context1.getId() + " not in the correct state");
allDependentTerminated = false;
- } else {
+ } else if (this.aliasToInActiveMonitorsMap.containsKey(context1.getId())) {
log.info("Waiting for the [dependent] " + context1.getId() + " to be terminated...");
+ allDependentTerminated = false;
+ } else {
+ allDependentTerminated = true;
}
}
}
@@ -251,11 +259,11 @@ public abstract class ParentComponentMonitor extends Monitor {
if ((terminationList != null && allDependentTerminated || terminationList == null) &&
(parentContexts != null && canStart || parentContexts == null)) {
//Find the non existent monitor by traversing dependency tree
-
try {
this.startDependencyOnTermination();
} catch (TopologyInConsistentException e) {
- e.printStackTrace();
+ //TODO revert the siblings and notify parent, change a flag for reverting/un-subscription
+ log.error("Error while starting the monitor upon termination" + e);
}
} else {
StatusChecker.getInstance().onChildStatusChange(idOfEvent, this.id, this.appId);
@@ -428,274 +436,4 @@ public abstract class ParentComponentMonitor extends Monitor {
}
}
}
-
-
- /*protected synchronized void startGroupMonitor(ParentComponentMonitor parent, GroupContext groupContext) {
- Thread th = null;
- //String groupId = group.getUniqueIdentifier();
- if (!this.aliasToActiveMonitorsMap.containsKey(groupId)) {
- if (log.isDebugEnabled()) {
- log.debug(String
- .format("Group monitor Adder has been added: [group] %s ",
- groupId));
- }
- th = new Thread(
- new GroupMonitorAdder(parent, groupId, this.appId));
- }
-
- if (th != null) {
- th.start();
- *//*try {
- th.join();
- } catch (InterruptedException ignore) {
- }*//*
-
- log.info(String
- .format("Group monitor thread has been started successfully: [group] %s ",
- groupId));
- }
- }
-*/
-
- /*private Group getGroupFromTopology(String groupId) throws TopologyInConsistentException {
- Application application = TopologyManager.getTopology().getApplication(this.appId);
- if(application != null) {
- Group group = application.getGroupRecursively(groupId);
- if(group != null) {
- return group;
- } else {
- String msg = "[Group] " + groupId + " cannot be found in the Topology";
- throw new TopologyInConsistentException(msg);
- }
- } else {
- String msg = "[Application] " + this.appId + " cannot be found in the Topology";
- throw new TopologyInConsistentException(msg);
- }
- }*/
-
- /*protected synchronized void startClusterMonitor(ParentComponentMonitor parent, ApplicationContext clusterContext) {
- Thread th = null;
- if (!this.aliasToActiveMonitorsMap.containsKey(clusterContext.getId())) {
- th = new Thread(
- new ClusterMonitorAdder(parent, clusterContext));
- if (log.isDebugEnabled()) {
- log.debug(String
- .format("Cluster monitor Adder has been added: [cluster] %s ",
- clusterContext.getClusterId()));
- }
- }
- if (th != null) {
- th.start();
- log.info(String
- .format("Cluster monitor thread has been started successfully: [cluster] %s ",
- clusterContext.getClusterId()));
- }
- }*/
-
-
- /*public Map<String, AbstractClusterMonitor> getClusterIdToClusterMonitorsMap() {
- return clusterIdToClusterMonitorsMap;
- }
-
- public void setClusterIdToClusterMonitorsMap(Map<String, AbstractClusterMonitor> clusterIdToClusterMonitorsMap) {
- this.clusterIdToClusterMonitorsMap = clusterIdToClusterMonitorsMap;
- }
-
- public void addAbstractMonitor(AbstractClusterMonitor monitor) {
- this.clusterIdToClusterMonitorsMap.put(monitor.getClusterId(), monitor);
- }
-
- public AbstractClusterMonitor getAbstractMonitor(String clusterId) {
- return this.clusterIdToClusterMonitorsMap.get(clusterId);
- }
-*/
-
-
- /*private class ClusterMonitorAdder implements Runnable {
- private Cluster cluster;
- private ParentComponentMonitor parent;
-
- public ClusterMonitorAdder(ParentComponentMonitor parent, Cluster cluster) {
- this.parent = parent;
- this.cluster = cluster;
- }
-
- public void run() {
- ClusterMonitor monitor = null;
- int retries = 5;
- boolean success = false;
- do {
- try {
- Thread.sleep(5000);
- } catch (InterruptedException e1) {
- }
- try {
- if (log.isDebugEnabled()) {
- log.debug("CLuster monitor is going to be started for [cluster] "
- + cluster.getClusterId());
- }
- monitor = AutoscalerUtil.getClusterMonitor(cluster);
- monitor.setParent(parent);
- //setting the status of cluster monitor w.r.t Topology cluster
- //if(cluster.getStatus() != Status.Created &&
- if(cluster.getStatus() != monitor.getStatus()) {
- //updating the status, so that it will notify the parent
- monitor.setStatus(cluster.getStatus());
- }
- //monitor.addObserver(parent);
- success = true;
- //TODO start the status checker
- } catch (PolicyValidationException e) {
- String msg = "Cluster monitor creation failed for cluster: " + cluster.getClusterId();
- log.warn(msg, e);
- retries--;
-
-
- } catch (PartitionValidationException e) {
- String msg = "Cluster monitor creation failed for cluster: " + cluster.getClusterId();
- log.warn(msg, e);
- retries--;
-
- }
-
- } while (!success && retries != 0);
-
-
- if (monitor == null) {
- String msg = "Cluster monitor creation failed, even after retrying for 5 times, "
- + "for cluster: " + cluster.getClusterId();
- log.error(msg);
- //TODO parent.notify();
- throw new RuntimeException(msg);
- }
-
- Thread th = new Thread(monitor);
- th.start();
-
- AutoscalerContext.getInstance().addMonitor(monitor);
- aliasToActiveMonitorsMap.put(cluster.getClusterId(), monitor);
- if (log.isInfoEnabled()) {
- log.info(String.format("Cluster monitor has been added successfully: [cluster] %s",
- cluster.getClusterId()));
- }
- }
- }
-*/
-
-
- /*private class GroupMonitorAdder implements Runnable {
- private ParentComponentMonitor parent;
- private String groupId;
- private String appId;
-
- public GroupMonitorAdder(ParentComponentMonitor parent, String groupId, String appId) {
- this.parent = parent;
- this.groupId = groupId;
- this.appId = appId;
- }
-
- public void run() {
- GroupMonitor monitor = null;
- int retries = 5;
- boolean success = false;
- do {
- try {
- Thread.sleep(5000);
- } catch (InterruptedException e1) {
- }
-
- try {
- if (log.isDebugEnabled()) {
- log.debug("Group monitor is going to be started for [group] "
- + groupId );
- }
- monitor = AutoscalerUtil.getGroupMonitor(groupId, appId);
- //setting the parent monitor
- monitor.setParent(parent);
- //setting the status of cluster monitor w.r.t Topology cluster
- //if(group.getStatus() != Status.Created &&
-
- //monitor.addObserver(parent);
- success = true;
- } catch (DependencyBuilderException e) {
- String msg = "Group monitor creation failed for group: " + groupId;
- log.warn(msg, e);
- retries--;
- } catch (TopologyInConsistentException e) {
- String msg = "Group monitor creation failed for group: " + groupId;
- log.warn(msg, e);
- retries--;
- }
- } while (!success && retries != 0);
-
- if (monitor == null) {
- String msg = "Group monitor creation failed, even after retrying for 5 times, "
- + "for group: " + groupId;
- log.error(msg);
- //TODO parent.notify(); as it got to failed
-
- throw new RuntimeException(msg);
- }
-
- aliasToActiveMonitorsMap.put(groupId, monitor);
- //parent.addObserver(monitor);
-
- if (log.isInfoEnabled()) {
- log.info(String.format("Group monitor has been added successfully: [group] %s",
- groupId));
- }
- }
- }
-
- private class LBClusterMonitorAdder implements Runnable {
- private Cluster cluster;
-
- public LBClusterMonitorAdder(Cluster cluster) {
- this.cluster = cluster;
- }
-
- public void run() {
- LbClusterMonitor monitor = null;
- int retries = 5;
- boolean success = false;
- do {
- try {
- Thread.sleep(5000);
- } catch (InterruptedException e1) {
- }
- try {
- monitor = AutoscalerUtil.getLBClusterMonitor(cluster);
- success = true;
-
- } catch (PolicyValidationException e) {
- String msg = "LB Cluster monitor creation failed for cluster: " + cluster.getClusterId();
- log.warn(msg, e);
- retries--;
-
- } catch (PartitionValidationException e) {
- String msg = "LB Cluster monitor creation failed for cluster: " + cluster.getClusterId();
- log.warn(msg, e);
- retries--;
- }
- } while (!success && retries <= 0);
-
- if (monitor == null) {
- String msg = "LB Cluster monitor creation failed, even after retrying for 5 times, "
- + "for cluster: " + cluster.getClusterId();
- log.error(msg);
- throw new RuntimeException(msg);
- }
-
- Thread th = new Thread(monitor);
- th.start();
- AutoscalerContext.getInstance().addLbMonitor(monitor);
- aliasToActiveMonitorsMap.put(cluster.getClusterId(), monitor);
- if (log.isInfoEnabled()) {
- log.info(String.format("LB Cluster monitor has been added successfully: [cluster] %s",
- cluster.getClusterId()));
- }
- }
- }*/
-
-
}
[12/50] [abbrv] git commit: fixing on member terminatiin status
checker
Posted by im...@apache.org.
fixing on member terminatiin status checker
Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/66aeb302
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/66aeb302
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/66aeb302
Branch: refs/heads/docker-grouping-merge
Commit: 66aeb302c2e61373ce38aace419a568701fe3462
Parents: 1b224bd
Author: reka <rt...@gmail.com>
Authored: Mon Oct 27 17:12:13 2014 +0530
Committer: reka <rt...@gmail.com>
Committed: Mon Oct 27 17:12:13 2014 +0530
----------------------------------------------------------------------
.../monitor/AbstractClusterMonitor.java | 6 +--
.../status/checker/StatusChecker.java | 46 ++++++++++++++------
2 files changed, 36 insertions(+), 16 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/stratos/blob/66aeb302/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/AbstractClusterMonitor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/AbstractClusterMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/AbstractClusterMonitor.java
index 838929c..588d2c4 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/AbstractClusterMonitor.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/AbstractClusterMonitor.java
@@ -234,11 +234,11 @@ abstract public class AbstractClusterMonitor extends Monitor implements Runnable
* If the cluster in_active and if it is a in_dependent cluster,
* then won't send the notification to parent.
*/
- if((status == ClusterStatus.Inactive && this.hasDependent)) {
- MonitorStatusEventBuilder.handleClusterStatusEvent(this.parent, this.status, this.clusterId);
- } else {
+ if(status == ClusterStatus.Inactive && !this.hasDependent) {
log.info("[Cluster] " + clusterId + "is not notifying the parent, " +
"since it is identified as the independent unit");
+ } else {
+ MonitorStatusEventBuilder.handleClusterStatusEvent(this.parent, this.status, this.clusterId);
}
}
http://git-wip-us.apache.org/repos/asf/stratos/blob/66aeb302/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java
index 6309e02..7b3e0ac 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java
@@ -73,20 +73,40 @@ public class StatusChecker {
public void onMemberTermination(String clusterId) {
ClusterMonitor monitor = (ClusterMonitor) AutoscalerContext.getInstance().getMonitor(clusterId);
- //TODO get Topology status
- boolean clusterMonitorHasMembers;
- clusterMonitorHasMembers = clusterMonitorHasMembers(monitor);
- if(clusterMonitorHasMembers) {
- //monitor.pause();
- // if cluster not having any members and if the cluster was in_active then send created Events
- //TODO
- StatusEventPublisher.sendClusterCreatedEvent(monitor.getAppId(), monitor.getServiceId(),
- monitor.getClusterId());
- } else {
- StatusEventPublisher.sendClusterTerminatedEvent(monitor.getAppId(), monitor.getServiceId(),
- monitor.getClusterId());
+ boolean clusterMonitorHasMembers = clusterMonitorHasMembers(monitor);
+ boolean clusterActive = clusterActive(monitor);
+
+ try {
+ TopologyManager.acquireReadLockForCluster(monitor.getServiceId(), monitor.getClusterId());
+ Service service = TopologyManager.getTopology().getService(monitor.getServiceId());
+ Cluster cluster;
+ if(service != null) {
+ cluster = service.getCluster(monitor.getClusterId());
+ if(cluster != null) {
+ if(!clusterMonitorHasMembers && cluster.getStatus() == ClusterStatus.Terminating) {
+ StatusEventPublisher.sendClusterTerminatedEvent(monitor.getAppId(), monitor.getServiceId(),
+ monitor.getClusterId());
+ } else {
+ log.info("Cluster has non terminated [members] and in the [status] "
+ + cluster.getStatus().toString());
+
+ /*if(!clusterActive && !(cluster.getStatus() == ClusterStatus.Inactive ||
+ cluster.getStatus() == ClusterStatus.Terminating)) {
+ cluster.getStatus()
+ StatusEventPublisher.sendClusterInActivateEvent(monitor.getAppId(),
+ monitor.getServiceId(), clusterId);
+
+ }*/
+ }
+ }
+ }
+
+
+ } finally {
+ TopologyManager.releaseReadLockForCluster(monitor.getServiceId(), monitor.getClusterId());
+
}
- // TODO if cluster was in terminating, then send terminated event.
+
}
private boolean clusterActive(AbstractClusterMonitor monitor) {
[47/50] [abbrv] Merge branch '4.0.0-grouping' into
docker-grouping-merge
Posted by im...@apache.org.
http://git-wip-us.apache.org/repos/asf/stratos/blob/17cc86eb/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java
----------------------------------------------------------------------
diff --cc components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java
index 80fc464,b7b5695..53b8e52
--- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java
+++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java
@@@ -23,25 -23,27 +23,35 @@@ import org.apache.axis2.context.Configu
import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.autoscaler.stub.*;
+import org.apache.stratos.autoscaler.stub.deployment.policy.DeploymentPolicy;
+import org.apache.stratos.cloud.controller.stub.CloudControllerServiceInvalidCartridgeTypeExceptionException;
+ import org.apache.stratos.autoscaler.deployment.policy.DeploymentPolicy;
+ import org.apache.stratos.autoscaler.stub.AutoScalerServiceInvalidPartitionExceptionException;
+ import org.apache.stratos.autoscaler.stub.AutoScalerServiceInvalidPolicyExceptionException;
+ import org.apache.stratos.cloud.controller.stub.*;
import org.apache.stratos.cloud.controller.stub.pojo.CartridgeConfig;
import org.apache.stratos.cloud.controller.stub.pojo.CartridgeInfo;
import org.apache.stratos.cloud.controller.stub.pojo.Property;
+ import org.apache.stratos.cloud.controller.stub.pojo.application.ApplicationContext;
import org.apache.stratos.manager.client.AutoscalerServiceClient;
import org.apache.stratos.manager.client.CloudControllerServiceClient;
+import org.apache.stratos.manager.deploy.cartridge.CartridgeDeploymentManager;
+ import org.apache.stratos.manager.composite.application.beans.ApplicationDefinition;
import org.apache.stratos.manager.deploy.service.Service;
import org.apache.stratos.manager.deploy.service.ServiceDeploymentManager;
import org.apache.stratos.manager.dto.Cartridge;
import org.apache.stratos.manager.dto.SubscriptionInfo;
+import org.apache.stratos.manager.exception.ADCException;
+import org.apache.stratos.manager.exception.DomainMappingExistsException;
+import org.apache.stratos.manager.exception.NotSubscribedException;
+import org.apache.stratos.manager.exception.ServiceDoesNotExistException;
+ import org.apache.stratos.manager.exception.*;
+ import org.apache.stratos.manager.grouping.definitions.ServiceGroupDefinition;
+ import org.apache.stratos.manager.grouping.manager.ServiceGroupingManager;
import org.apache.stratos.manager.manager.CartridgeSubscriptionManager;
import org.apache.stratos.manager.repository.RepositoryNotification;
+ import org.apache.stratos.manager.subscription.ApplicationSubscription;
import org.apache.stratos.manager.subscription.CartridgeSubscription;
import org.apache.stratos.manager.subscription.DataCartridgeSubscription;
import org.apache.stratos.manager.subscription.SubscriptionData;
@@@ -88,21 -87,103 +99,82 @@@ public class ServiceUtils
private static ServiceDeploymentManager serviceDeploymentManager = new ServiceDeploymentManager();
static void deployCartridge(CartridgeDefinitionBean cartridgeDefinitionBean, ConfigurationContext ctxt,
- String userName, String tenantDomain) throws RestAPIException {
+ String userName, String tenantDomain) throws RestAPIException {
- log.info("Starting to deploy a Cartridge [type] " + cartridgeDefinitionBean.type);
-
- CloudControllerServiceClient cloudControllerServiceClient = getCloudControllerServiceClient();
-
- if (cloudControllerServiceClient != null) {
-
- CartridgeConfig cartridgeConfig = PojoConverter.populateCartridgeConfigPojo(cartridgeDefinitionBean);
-
- if (cartridgeConfig == null) {
- throw new RestAPIException("Populated CartridgeConfig instance is null, cartridge deployment aborted");
- }
-
-
- // call CC
- try {
- cloudControllerServiceClient
- .deployCartridgeDefinition(cartridgeConfig);
- } catch (RemoteException e) {
- log.error(e.getMessage(), e);
- throw new RestAPIException(e.getMessage(), e);
- } catch (CloudControllerServiceInvalidCartridgeDefinitionExceptionException e) {
- String message = e.getFaultMessage().getInvalidCartridgeDefinitionException().getMessage();
- log.error(message, e);
- throw new RestAPIException(message, e);
- } catch (CloudControllerServiceInvalidIaasProviderExceptionException e) {
- String message = e.getFaultMessage().getInvalidIaasProviderException().getMessage();
- log.error(message, e);
- throw new RestAPIException(message, e);
- }
-
- log.info("Successfully deployed Cartridge [type] " + cartridgeDefinitionBean.type);
-
- }
+ log.info("Starting to deploy a Cartridge [type] "+ cartridgeDefinitionBean.type);
+
+ CartridgeConfig cartridgeConfig = PojoConverter.populateCartridgeConfigPojo(cartridgeDefinitionBean);
+ if (cartridgeConfig == null) {
+ throw new RestAPIException("Populated CartridgeConfig instance is null, cartridge deployment aborted");
+ }
+ try {
+ CartridgeDeploymentManager.getDeploymentManager(cartridgeDefinitionBean.deployerType).deploy(cartridgeConfig);
+ } catch (ADCException e) {
+ throw new RestAPIException(e.getMessage());
+ }
+ log.info("Successfully deployed Cartridge [type] "+ cartridgeDefinitionBean.type);
}
+
+
+ static void deployApplicationDefinition (ApplicationDefinition appDefinition, ConfigurationContext ctxt,
+ String userName, String tenantDomain)
+ throws RestAPIException {
+
+ // check if an application with same id already exists
+ // check if application with same appId / tenant already exists
+ CartridgeSubscriptionManager subscriptionMgr = new CartridgeSubscriptionManager();
+ int tenantId = ApplicationManagementUtil.getTenantId(ctxt);
+ String appId = appDefinition.getApplicationId();
+
+ try {
+ if (subscriptionMgr.getApplicationSubscription(appId, tenantId) != null) {
+ String msg = "Duplicate application appId: " + appId + " for tenant " + tenantId;
+ throw new RestAPIException(msg);
+ }
+ } catch (ApplicationSubscriptionException e1) {
+ throw new RestAPIException(e1);
+ }
+
+ ApplicationContext applicationContext = PojoConverter.convertApplicationBeanToApplicationContext(appDefinition);
+ applicationContext.setTenantId(ApplicationManagementUtil.getTenantId(ctxt));
+ applicationContext.setTenantDomain(tenantDomain);
+ applicationContext.setTeantAdminUsername(userName);
+
+ try {
+ CloudControllerServiceClient.getServiceClient().deployApplicationDefinition(applicationContext);
+
+ } catch (RemoteException e) {
+ throw new RestAPIException(e);
+ } catch (CloudControllerServiceInvalidIaasProviderExceptionException e) {
+ throw new RestAPIException(e);
+ } catch (CloudControllerServiceApplicationDefinitionExceptionException e) {
+ throw new RestAPIException(e);
+ }
+ }
+
+ static ApplicationSubscription getApplicationSubscriptions(String appId, ConfigurationContext ctxt) throws RestAPIException {
+ CartridgeSubscriptionManager subscriptionMgr = new CartridgeSubscriptionManager();
+ try {
+ return subscriptionMgr.getApplicationSubscription(appId, ApplicationManagementUtil.getTenantId(ctxt));
+ } catch (ApplicationSubscriptionException e) {
+ throw new RestAPIException(e);
+ }
+ }
+
+ static void unDeployApplication(String appId, ConfigurationContext ctxt,
+ String userName, String tenantDomain) throws RestAPIException {
+
+ try {
+ int tenantId = ApplicationManagementUtil.getTenantId(ctxt);
+ CloudControllerServiceClient.getServiceClient().undeployApplicationDefinition(appId, tenantId, tenantDomain);
+
+ } catch (CloudControllerServiceApplicationDefinitionExceptionException e) {
+ throw new RestAPIException(e);
+ } catch (RemoteException e) {
+ throw new RestAPIException(e);
+ }
+
+ }
@SuppressWarnings("unused")
private static DeploymentPolicy[] intersection(
@@@ -1307,245 -1399,110 +1439,351 @@@
}
+ static void deployServiceGroupDefinition (ServiceGroupDefinition serviceGroupDefinition) throws RestAPIException {
+
+ try {
+ serviceGropingManager.deployServiceGroupDefinition(serviceGroupDefinition);
+
+ } catch (InvalidServiceGroupException e) {
+ throw new RestAPIException(e);
+ } catch (ServiceGroupDefinitioException e) {
+ throw new RestAPIException(e);
+ } catch (ADCException e) {
+ throw new RestAPIException(e);
+ } catch (CloudControllerServiceUnregisteredCartridgeExceptionException e) {
+ throw new RestAPIException(e);
+ }
+
+ log.info("Successfully deployed the Service Group Definition with name " + serviceGroupDefinition.getName());
+ }
+
+ static ServiceGroupDefinition getServiceGroupDefinition (String serviceGroupDefinitionName) throws RestAPIException {
+
+ try {
+ return serviceGropingManager.getServiceGroupDefinition(serviceGroupDefinitionName);
+
+ } catch (ServiceGroupDefinitioException e) {
+ throw new RestAPIException(e);
+ } catch (ADCException e) {
+ throw new RestAPIException(e);
+ }
+ }
+
+ static void undeployServiceGroupDefinition (String serviceGroupDefinitionName) throws RestAPIException {
+
+ try {
+ serviceGropingManager.undeployServiceGroupDefinition(serviceGroupDefinitionName);
+
+ } catch (ServiceGroupDefinitioException e) {
+ throw new RestAPIException(e);
+ } catch (ADCException e) {
+ throw new RestAPIException(e);
+ }
+
+ log.info("Successfully undeployed the Service Group Definition with name " + serviceGroupDefinitionName);
+ }
+
+ public static ApplicationBean getApplicationInfo(String applicationId, ConfigurationContext configContext) {
+ ApplicationBean applicationBean = null;
+ try{
+ TopologyManager.acquireReadLockForApplication(applicationId);
+ Application application = TopologyManager.getTopology().getApplication(applicationId);
+ if(application == null){
+ return null;
+ }
+ applicationBean = PojoConverter.applicationToBean(application);
+
+ Map<String, ClusterDataHolder> topLevelClusterDataMap = application.getClusterDataMap();
+ for(Map.Entry<String, ClusterDataHolder> entry : topLevelClusterDataMap.entrySet()){
+ ClusterDataHolder clusterDataHolder = entry.getValue();
+ String clusterId = clusterDataHolder.getClusterId();
+ String serviceType = clusterDataHolder.getServiceType();
+ TopologyManager.acquireReadLockForCluster(serviceType, clusterId);
+ Cluster topLevelCluster;
+
+ try {
+ TopologyManager.acquireReadLockForCluster(serviceType, clusterId);
+ topLevelCluster = TopologyManager.getTopology().getService(serviceType).getCluster(clusterId);
+ }finally {
+ TopologyManager.releaseReadLockForCluster(serviceType, clusterId);
+ }
+ applicationBean.clusters.add(PojoConverter.populateClusterPojos(topLevelCluster));
+ }
+
+ Collection<Group> groups = application.getGroups();
+ for(Group group : groups){
+ GroupBean groupBean = PojoConverter.toGroupBean(group);
+ setSubGroups(group, groupBean);
+ applicationBean.addGroup(groupBean);
+ }
+ }finally {
+ TopologyManager.releaseReadLockForApplication(applicationId);
+ }
+
+
+ return applicationBean;
+ }
+
+ private static void setSubGroups(Group group, GroupBean groupBean) {
+ Collection<Group> subgroups = group.getGroups();
+ addClustersToGroupBean(group, groupBean);
+ for(Group subGroup : subgroups){
+ GroupBean subGroupBean = PojoConverter.toGroupBean(subGroup);
+
+ setSubGroups(subGroup, subGroupBean);
+ groupBean.addGroup(subGroupBean);
+ }
+ }
+
+ private static void addClustersToGroupBean(Group group, GroupBean groupBean) {
+ Map<String, ClusterDataHolder> clustersDatamap = group.getClusterDataMap();
+ for(Map.Entry<String, ClusterDataHolder> x : clustersDatamap.entrySet()){
+ String alias = x.getKey();
+ ClusterDataHolder clusterHolder = x.getValue();
+ Cluster topLevelCluster = TopologyManager.getTopology().getService(clusterHolder.getServiceType()).getCluster(clusterHolder.getClusterId());
+ groupBean.addCluster(PojoConverter.populateClusterPojos(topLevelCluster));
+ }
+ }
+
+
+
+ public static boolean deployKubernetesGroup(KubernetesGroup kubernetesGroupBean) throws RestAPIException {
+
+ AutoscalerServiceClient autoscalerServiceClient = getAutoscalerServiceClient();
+ if (autoscalerServiceClient != null) {
+ org.apache.stratos.autoscaler.stub.kubernetes.KubernetesGroup kubernetesGroup =
+ PojoConverter.convertToASKubernetesGroupPojo(kubernetesGroupBean);
+
+ try {
+ return autoscalerServiceClient.deployKubernetesGroup(kubernetesGroup);
+ } catch (RemoteException e) {
+ log.error(e.getMessage(), e);
+ throw new RestAPIException(e.getMessage(), e);
+ } catch (AutoScalerServiceInvalidKubernetesGroupExceptionException e) {
+ String message = e.getFaultMessage().getInvalidKubernetesGroupException().getMessage();
+ log.error(message, e);
+ throw new RestAPIException(message, e);
+ }
+ }
+ return false;
+ }
+
+ public static boolean deployKubernetesHost(String kubernetesGroupId, KubernetesHost kubernetesHostBean)
+ throws RestAPIException {
+
+ AutoscalerServiceClient autoscalerServiceClient = getAutoscalerServiceClient();
+ if (autoscalerServiceClient != null) {
+ org.apache.stratos.autoscaler.stub.kubernetes.KubernetesHost kubernetesHost =
+ PojoConverter.convertToASKubernetesHostPojo(kubernetesHostBean);
+
+ try {
+ return autoscalerServiceClient.deployKubernetesHost(kubernetesGroupId, kubernetesHost);
+ } catch (RemoteException e) {
+ log.error(e.getMessage(), e);
+ throw new RestAPIException(e.getMessage(), e);
+ } catch (AutoScalerServiceInvalidKubernetesHostExceptionException e) {
+ String message = e.getFaultMessage().getInvalidKubernetesHostException().getMessage();
+ log.error(message, e);
+ throw new RestAPIException(message, e);
+ } catch (AutoScalerServiceNonExistingKubernetesGroupExceptionException e) {
+ String message = e.getFaultMessage().getNonExistingKubernetesGroupException().getMessage();
+ log.error(message, e);
+ throw new RestAPIException(message, e);
+ }
+ }
+ return false;
+ }
+
+ public static boolean updateKubernetesMaster(KubernetesMaster kubernetesMasterBean) throws RestAPIException {
+
+ AutoscalerServiceClient autoscalerServiceClient = getAutoscalerServiceClient();
+ if (autoscalerServiceClient != null) {
+ org.apache.stratos.autoscaler.stub.kubernetes.KubernetesMaster kubernetesMaster =
+ PojoConverter.convertToASKubernetesMasterPojo(kubernetesMasterBean);
+
+ try {
+ return autoscalerServiceClient.updateKubernetesMaster(kubernetesMaster);
+ } catch (RemoteException e) {
+ log.error(e.getMessage(), e);
+ throw new RestAPIException(e.getMessage(), e);
+ } catch (AutoScalerServiceInvalidKubernetesMasterExceptionException e) {
+ String message = e.getFaultMessage().getInvalidKubernetesMasterException().getMessage();
+ log.error(message, e);
+ throw new RestAPIException(message, e);
+ } catch (AutoScalerServiceNonExistingKubernetesMasterExceptionException e) {
+ String message = e.getFaultMessage().getNonExistingKubernetesMasterException().getMessage();
+ log.error(message, e);
+ throw new RestAPIException(message, e);
+ }
+ }
+ return false;
+ }
+
+ public static KubernetesGroup[] getAvailableKubernetesGroups() throws RestAPIException {
+
+ AutoscalerServiceClient autoscalerServiceClient = getAutoscalerServiceClient();
+ if (autoscalerServiceClient != null) {
+ try {
+ org.apache.stratos.autoscaler.stub.kubernetes.KubernetesGroup[]
+ kubernetesGroups = autoscalerServiceClient.getAvailableKubernetesGroups();
+ return PojoConverter.populateKubernetesGroupsPojo(kubernetesGroups);
+
+ } catch (RemoteException e) {
+ log.error(e.getMessage(), e);
+ throw new RestAPIException(e.getMessage(), e);
+ }
+ }
+ return null;
+ }
+
+ public static KubernetesGroup getKubernetesGroup(String kubernetesGroupId) throws RestAPIException {
+
+ AutoscalerServiceClient autoscalerServiceClient = getAutoscalerServiceClient();
+ if (autoscalerServiceClient != null) {
+ try {
+ org.apache.stratos.autoscaler.stub.kubernetes.KubernetesGroup
+ kubernetesGroup = autoscalerServiceClient.getKubernetesGroup(kubernetesGroupId);
+ return PojoConverter.populateKubernetesGroupPojo(kubernetesGroup);
+
+ } catch (RemoteException e) {
+ log.error(e.getMessage(), e);
+ throw new RestAPIException(e.getMessage(), e);
+ } catch (AutoScalerServiceNonExistingKubernetesGroupExceptionException e) {
+ String message = e.getFaultMessage().getNonExistingKubernetesGroupException().getMessage();
+ log.error(message, e);
+ throw new RestAPIException(message, e);
+ }
+ }
+ return null;
+ }
+
+ public static boolean undeployKubernetesGroup(String kubernetesGroupId) throws RestAPIException {
+
+ AutoscalerServiceClient autoscalerServiceClient = getAutoscalerServiceClient();
+ if (autoscalerServiceClient != null) {
+ try {
+ return autoscalerServiceClient.undeployKubernetesGroup(kubernetesGroupId);
+
+ } catch (RemoteException e) {
+ log.error(e.getMessage(), e);
+ throw new RestAPIException(e.getMessage(), e);
+ } catch (AutoScalerServiceNonExistingKubernetesGroupExceptionException e) {
+ String message = e.getFaultMessage().getNonExistingKubernetesGroupException().getMessage();
+ log.error(message, e);
+ throw new RestAPIException(message, e);
+ }
+ }
+ return false;
+ }
+
+ public static boolean undeployKubernetesHost(String kubernetesHostId) throws RestAPIException {
+
+ AutoscalerServiceClient autoscalerServiceClient = getAutoscalerServiceClient();
+ if (autoscalerServiceClient != null) {
+ try {
+ return autoscalerServiceClient.undeployKubernetesHost(kubernetesHostId);
+
+ } catch (RemoteException e) {
+ log.error(e.getMessage(), e);
+ throw new RestAPIException(e.getMessage(), e);
+ } catch (AutoScalerServiceNonExistingKubernetesHostExceptionException e) {
+ String message = e.getFaultMessage().getNonExistingKubernetesHostException().getMessage();
+ log.error(message, e);
+ throw new RestAPIException(message, e);
+ }
+ }
+ return false;
+ }
+
+ public static KubernetesHost[] getKubernetesHosts(String kubernetesGroupId) throws RestAPIException {
+
+ AutoscalerServiceClient autoscalerServiceClient = getAutoscalerServiceClient();
+ if (autoscalerServiceClient != null) {
+ try {
+ org.apache.stratos.autoscaler.stub.kubernetes.KubernetesHost[]
+ kubernetesHosts = autoscalerServiceClient.getKubernetesHosts(kubernetesGroupId);
+
+ List<KubernetesHost> arrayList = PojoConverter.populateKubernetesHostsPojo(kubernetesHosts);
+ KubernetesHost[] array = new KubernetesHost[arrayList.size()];
+ array = arrayList.toArray(array);
+ return array;
+ } catch (RemoteException e) {
+ log.error(e.getMessage(), e);
+ throw new RestAPIException(e.getMessage(), e);
+ } catch (AutoScalerServiceNonExistingKubernetesGroupExceptionException e) {
+ String message = e.getFaultMessage().getNonExistingKubernetesGroupException().getMessage();
+ log.error(message, e);
+ throw new RestAPIException(message, e);
+ }
+ }
+ return null;
+ }
+
+ public static KubernetesMaster getKubernetesMaster(String kubernetesGroupId) throws RestAPIException {
+ AutoscalerServiceClient autoscalerServiceClient = getAutoscalerServiceClient();
+ if (autoscalerServiceClient != null) {
+ try {
+ org.apache.stratos.autoscaler.stub.kubernetes.KubernetesMaster
+ kubernetesMaster = autoscalerServiceClient.getKubernetesMaster(kubernetesGroupId);
+ return PojoConverter.populateKubernetesMasterPojo(kubernetesMaster);
+
+ } catch (RemoteException e) {
+ log.error(e.getMessage(), e);
+ throw new RestAPIException(e.getMessage(), e);
+ } catch (AutoScalerServiceNonExistingKubernetesGroupExceptionException e) {
+ String message = e.getFaultMessage().getNonExistingKubernetesGroupException().getMessage();
+ log.error(message, e);
+ throw new RestAPIException(message, e);
+ }
+ }
+ return null;
+ }
+
+ public static boolean updateKubernetesHost(KubernetesHost kubernetesHostBean) throws RestAPIException {
+ AutoscalerServiceClient autoscalerServiceClient = getAutoscalerServiceClient();
+ if (autoscalerServiceClient != null) {
+ org.apache.stratos.autoscaler.stub.kubernetes.KubernetesHost kubernetesHost =
+ PojoConverter.convertToASKubernetesHostPojo(kubernetesHostBean);
+ try {
+ return autoscalerServiceClient.updateKubernetesHost(kubernetesHost);
+ } catch (RemoteException e) {
+ log.error(e.getMessage(), e);
+ throw new RestAPIException(e.getMessage(), e);
+ } catch (AutoScalerServiceInvalidKubernetesHostExceptionException e) {
+ String message = e.getFaultMessage().getInvalidKubernetesHostException().getMessage();
+ log.error(message, e);
+ throw new RestAPIException(message, e);
+ } catch (AutoScalerServiceNonExistingKubernetesHostExceptionException e) {
+ String message = e.getFaultMessage().getNonExistingKubernetesHostException().getMessage();
+ log.error(message, e);
+ throw new RestAPIException(message, e);
+ }
+ }
+ return false;
+ }
+
+ public static void updateSubscriptionProperties(ConfigurationContext context, String alias, List<PropertyBean> property) throws RestAPIException {
+ AutoscalerServiceClient autoscalerServiceClient = getAutoscalerServiceClient();
+ if (autoscalerServiceClient != null) {
+ try {
+ Cluster cluster = TopologyClusterInformationModel.getInstance().getCluster(ApplicationManagementUtil.getTenantId(context)
+ , alias);
+ if (cluster == null) {
+ throw new RestAPIException("No matching cluster found for [alias] " + alias);
+ }
+ if (property != null) {
+ autoscalerServiceClient.updateClusterMonitor(cluster.getClusterId(), PojoConverter.getProperties(property));
+ }
+ } catch(AutoScalerServiceInvalidArgumentExceptionException e) {
+ String message = e.getFaultMessage().getInvalidArgumentException().getMessage();
+ log.error(message, e);
+ throw new RestAPIException(message, e);
+ } catch (RemoteException e) {
+ String msg = "Error while connecting to Autoscaler Service. "+e.getMessage();
+ log.error(msg, e);
+ throw new RestAPIException(e.getMessage(), e);
+ }
+ }
+
+ }
}
http://git-wip-us.apache.org/repos/asf/stratos/blob/17cc86eb/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/StratosAdmin.java
----------------------------------------------------------------------
diff --cc components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/StratosAdmin.java
index 226a4ab,44d42a5..f889e02
--- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/StratosAdmin.java
+++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/StratosAdmin.java
@@@ -29,10 -30,9 +30,12 @@@ import org.apache.stratos.manager.dto.C
import org.apache.stratos.manager.dto.SubscriptionInfo;
import org.apache.stratos.manager.exception.DomainMappingExistsException;
import org.apache.stratos.manager.exception.ServiceDoesNotExistException;
+ import org.apache.stratos.manager.grouping.definitions.ServiceGroupDefinition;
+ import org.apache.stratos.manager.subscription.ApplicationSubscription;
import org.apache.stratos.manager.subscription.CartridgeSubscription;
+import org.apache.stratos.manager.user.mgt.StratosUserManager;
+import org.apache.stratos.manager.user.mgt.beans.UserInfoBean;
+import org.apache.stratos.manager.user.mgt.exception.UserManagerException;
import org.apache.stratos.rest.endpoint.ServiceHolder;
import org.apache.stratos.rest.endpoint.Utils;
import org.apache.stratos.rest.endpoint.annotation.AuthorizationAction;
@@@ -45,10 -46,7 +49,11 @@@ import org.apache.stratos.rest.endpoint
import org.apache.stratos.rest.endpoint.bean.autoscaler.policy.deployment.DeploymentPolicy;
import org.apache.stratos.rest.endpoint.bean.cartridge.definition.CartridgeDefinitionBean;
import org.apache.stratos.rest.endpoint.bean.cartridge.definition.ServiceDefinitionBean;
+import org.apache.stratos.rest.endpoint.bean.kubernetes.KubernetesGroup;
+import org.apache.stratos.rest.endpoint.bean.kubernetes.KubernetesHost;
+import org.apache.stratos.rest.endpoint.bean.kubernetes.KubernetesMaster;
import org.apache.stratos.rest.endpoint.bean.repositoryNotificationInfoBean.Payload;
++import org.apache.stratos.rest.endpoint.bean.repositoryNotificationInfoBean.Repository;
import org.apache.stratos.rest.endpoint.bean.subscription.domain.SubscriptionDomainBean;
import org.apache.stratos.rest.endpoint.bean.topology.Cluster;
import org.apache.stratos.rest.endpoint.exception.RestAPIException;
@@@ -400,10 -515,10 +543,12 @@@ public class StratosAdmin extends Abstr
@Path("/cartridge/lb")
@Produces("application/json")
@Consumes("application/json")
- @AuthorizationAction("/permission/protected/manage/monitor/tenants")
+ @AuthorizationAction("/permission/admin/manage/view/cartridge")
public Response getAvailableLbCartridges() throws RestAPIException {
+ List<Cartridge> lbCartridges = ServiceUtils.getAvailableLbCartridges(false, getConfigContext());
+ return Response.ok().entity(lbCartridges.isEmpty() ? new Cartridge[0] : lbCartridges.toArray(new Cartridge[lbCartridges.size()])).build();
+ List<Cartridge> lbCartridges = ServiceUtils.getAvailableLbCartridges(false, getConfigContext());
+ return Response.ok().entity(lbCartridges.isEmpty() ? new Cartridge[0] : lbCartridges.toArray(new Cartridge[lbCartridges.size()])).build();
}
@GET
http://git-wip-us.apache.org/repos/asf/stratos/blob/17cc86eb/components/org.apache.stratos.rest.endpoint/src/main/webapp/stratos/WEB-INF/schemas/schema.xsd
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/stratos/blob/17cc86eb/components/pom.xml
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/stratos/blob/17cc86eb/features/manager/pom.xml
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/stratos/blob/17cc86eb/products/stratos/modules/distribution/src/assembly/bin.xml
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/stratos/blob/17cc86eb/products/stratos/modules/distribution/src/main/conf/mincheck.drl
----------------------------------------------------------------------
diff --cc products/stratos/modules/distribution/src/main/conf/mincheck.drl
index 0000000,105523d..ceeab48
mode 000000,100755..100755
--- a/products/stratos/modules/distribution/src/main/conf/mincheck.drl
+++ b/products/stratos/modules/distribution/src/main/conf/mincheck.drl
@@@ -1,0 -1,88 +1,84 @@@
+ /*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+ package org.apache.stratos.autoscaler.rule;
+
+ import org.apache.stratos.messaging.domain.topology.Service;
+ import org.apache.stratos.messaging.domain.topology.Cluster;
+ import org.apache.stratos.autoscaler.AutoscalerContext;
+ import org.apache.stratos.autoscaler.Constants;
+ import org.apache.stratos.autoscaler.policy.PolicyManager;
+ import org.apache.stratos.autoscaler.policy.model.AutoscalePolicy;
+ import org.apache.stratos.autoscaler.policy.model.RequestsInFlight;
+ import org.apache.stratos.autoscaler.policy.model.LoadThresholds;
+ import org.apache.stratos.autoscaler.client.cloud.controller.CloudControllerClient;
+ import org.apache.stratos.autoscaler.algorithm.AutoscaleAlgorithm;
+ import org.apache.stratos.autoscaler.algorithm.OneAfterAnother;
+ import org.apache.stratos.autoscaler.algorithm.RoundRobin;
+ import org.apache.stratos.autoscaler.PartitionContext;
+ import org.apache.stratos.messaging.message.receiver.topology.TopologyManager;
+ import org.apache.stratos.autoscaler.rule.AutoscalerRuleEvaluator;
+ import org.apache.commons.logging.Log;
+ import org.apache.stratos.autoscaler.deployment.policy.DeploymentPolicy;
+ import org.apache.stratos.autoscaler.partition.PartitionGroup;
+ import org.apache.stratos.cloud.controller.stub.deployment.partition.Partition;
+ import org.apache.stratos.cloud.controller.stub.pojo.MemberContext;
+
+ global org.apache.stratos.autoscaler.rule.RuleLog log;
+ global org.apache.stratos.autoscaler.policy.PolicyManager $manager;
+ global org.apache.stratos.autoscaler.AutoscalerContext $context;
+ global org.apache.stratos.autoscaler.rule.RuleTasksDelegator $delegator;
+ global org.apache.stratos.messaging.domain.topology.Topology $topology;
+ global java.util.Map partitionCtxts;
+ global java.lang.String clusterId;
+ global java.lang.String lbRef;
+ global java.lang.Boolean isPrimary;
+ global Integer primaryMemberCount;
-global java.lang.String serviceId;
-
-global org.apache.stratos.autoscaler.policy.model.AutoscalePolicy autoscalePolicy;
-
+
+ rule "Minimum Rule"
+ dialect "mvel"
+ when
+ $ctxt : PartitionContext ()
+ eval(log.debug("Running minimum rule: [network-partition] " + $ctxt.getNetworkPartitionId() + " [partition] " + $ctxt.getPartitionId()))
+ eval(log.debug("[min-check] [network-partition] " + $ctxt.getNetworkPartitionId() + " [partition] " + $ctxt.getPartitionId() + " Non terminated member count: " + $ctxt.getNonTerminatedMemberCount()))
+ eval(log.debug("[min-check] [network-partition] " + $ctxt.getNetworkPartitionId() + " [partition] " + $ctxt.getPartitionId() + " Minimum member count: " + $ctxt.getMinimumMemberCount()))
+ eval ( (isPrimary && (primaryMemberCount < $ctxt.getMinimumMemberCount() )) || ( !isPrimary && ($ctxt.getNonTerminatedMemberCount() < $ctxt.getMinimumMemberCount() )) )
+ then
+ if (isPrimary){
+ log.debug("[min-check] true [primary] true [primary member count] " + primaryMemberCount);
+ } else{
+ log.debug("[min-check] true [primary] false");
+ }
+ $delegator.delegateSpawn($ctxt, clusterId, lbRef, isPrimary);
+ end
+
+ rule "Terminate Obsoleted Instances"
+ dialect "mvel"
+ when
+ $ctxt : PartitionContext ()
+ eval(log.debug("Running obsolete instances rule: [partition] " + $ctxt.getPartitionId() + " [network-partition] " + $ctxt.getNetworkPartitionId()))
+ eval(log.debug("[obsolete-check] [network-partition] " + $ctxt.getNetworkPartitionId() + " [partition] " + $ctxt.getPartitionId() +" Obsolete member count: " + $ctxt.getObsoletedMembers().size()))
+ eval($ctxt.getObsoletedMembers().size() > 0)
+ memberId : String() from $ctxt.getObsoletedMembers()
+ eval(log.debug("[obsolete-check] [network-partition] " + $ctxt.getNetworkPartitionId() + " [partition] " + $ctxt.getPartitionId() + " Member id: " + memberId))
+ eval($ctxt.removeObsoleteMember(memberId))
+ then
+ $delegator.terminateObsoleteInstance(memberId);
+ end
+
http://git-wip-us.apache.org/repos/asf/stratos/blob/17cc86eb/products/stratos/modules/p2-profile-gen/pom.xml
----------------------------------------------------------------------
diff --cc products/stratos/modules/p2-profile-gen/pom.xml
index 54c20e6,91e9ed2..14c6eca
--- a/products/stratos/modules/p2-profile-gen/pom.xml
+++ b/products/stratos/modules/p2-profile-gen/pom.xml
@@@ -280,7 -205,9 +280,8 @@@
<featureArtifactDef>org.wso2.carbon:org.wso2.carbon.caching.feature:${carbon.version}</featureArtifactDef>
<featureArtifactDef>org.wso2.carbon:org.wso2.carbon.rm.server.feature:${carbon.version}</featureArtifactDef>
<featureArtifactDef>org.apache.stratos:org.apache.stratos.manager.feature:${project.version}</featureArtifactDef>
- <featureArtifactDef>org.apache.stratos:org.apache.stratos.cartridge.mgt.ui.feature:${project.version}</featureArtifactDef>
<featureArtifactDef>org.apache.stratos:org.apache.stratos.rest.endpoint.feature:${project.version}</featureArtifactDef>
+ <featureArtifactDef>org.apache.stratos:org.apache.stratos.metadataservice.feature:${project.version}</featureArtifactDef>
<featureArtifactDef>org.wso2.carbon:org.wso2.carbon.identity.authenticator.saml2.sso.server.feature:${carbon.platform.patch.version.4.2.1}</featureArtifactDef>
<featureArtifactDef>org.wso2.carbon:org.wso2.carbon.identity.authenticator.saml2.sso.ui.feature:${carbon.platform.patch.version.4.2.2}</featureArtifactDef>
<featureArtifactDef>org.wso2.carbon:org.wso2.carbon.identity.application.authentication.framework.server.feature:${carbon.platform.patch.version.4.2.1}</featureArtifactDef>
http://git-wip-us.apache.org/repos/asf/stratos/blob/17cc86eb/products/stratos/pom.xml
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/stratos/blob/17cc86eb/service-stubs/org.apache.stratos.cloud.controller.service.stub/pom.xml
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/stratos/blob/17cc86eb/tools/stratos-installer/conf/setup.conf
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/stratos/blob/17cc86eb/tools/stratos-installer/setup.sh
----------------------------------------------------------------------
diff --cc tools/stratos-installer/setup.sh
index 5a02de2,5035af9..ae88b32
--- a/tools/stratos-installer/setup.sh
+++ b/tools/stratos-installer/setup.sh
@@@ -557,10 -551,24 +572,24 @@@ if [[ ($profile = "default" && $config_
echo "Extracting ActiveMQ"
tar -xzf $activemq_pack -C $stratos_path
# disable amqp connector to prevent conflicts with openstack
- sed -r -i -e 's@^(\s*)(<transportConnector name="amqp".*\s*)$@\1<!--\2-->@g' $stratos_path/apache-activemq-5.9.1/conf/activemq.xml
+ ${SED} -r -i -e 's@^(\s*)(<transportConnector name="amqp".*\s*)$@\1<!--\2-->@g' $activemq_path/conf/activemq.xml
fi
+ if [[ ($profile = "default" && $config_greg = "true") ]]; then
+ echo "Extracting wso2 greg"
+ unzip -q $greg_pack_zip -d $stratos_path
+
+ fi
+
general_setup
+
+ if [[ ($profile = "default" && $config_greg = "true") ]]; then
+ echo "Running the GREG"
+ greg_setup
+
+ fi
+
+
if [[ $profile = "cc" ]]; then
cc_setup
elif [[ $profile = "as" ]]; then
[43/50] [abbrv] git commit: fixing the logic which decides cluster
inActive
Posted by im...@apache.org.
fixing the logic which decides cluster inActive
Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/b51b0b79
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/b51b0b79
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/b51b0b79
Branch: refs/heads/docker-grouping-merge
Commit: b51b0b793961bd9b3784a996730225a05988bd8f
Parents: 3c43277
Author: reka <rt...@gmail.com>
Authored: Wed Oct 29 17:29:41 2014 +0530
Committer: reka <rt...@gmail.com>
Committed: Wed Oct 29 17:29:50 2014 +0530
----------------------------------------------------------------------
.../health/AutoscalerHealthStatEventReceiver.java | 3 ++-
.../monitor/application/ApplicationMonitor.java | 2 +-
.../stratos/autoscaler/monitor/group/GroupMonitor.java | 2 +-
.../autoscaler/status/checker/StatusChecker.java | 12 ++++++------
4 files changed, 10 insertions(+), 9 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/stratos/blob/b51b0b79/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/health/AutoscalerHealthStatEventReceiver.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/health/AutoscalerHealthStatEventReceiver.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/health/AutoscalerHealthStatEventReceiver.java
index cf072f3..f192cee 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/health/AutoscalerHealthStatEventReceiver.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/health/AutoscalerHealthStatEventReceiver.java
@@ -656,8 +656,9 @@ public class AutoscalerHealthStatEventReceiver implements Runnable {
}
return;
}
+
//Check the clusterStatus as part of the member fault event
- StatusChecker.getInstance().onMemberFaultEvent(clusterId, partitionCtxt);
+ StatusChecker.getInstance().onMemberFaultEvent(clusterId, partitionId);
// terminate the faulty member
CloudControllerClient ccClient = CloudControllerClient.getInstance();
http://git-wip-us.apache.org/repos/asf/stratos/blob/b51b0b79/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 1ec7399..2bf85a6 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
@@ -170,7 +170,7 @@ public class ApplicationMonitor extends ParentComponentMonitor {
} else if (status1 == ClusterStatus.Terminated || status1 == GroupStatus.Terminated) {
//Check whether all dependent goes Terminated and then start them in parallel.
this.aliasToInActiveMonitorsMap.remove(id);
- if (this.status != ApplicationStatus.Terminating) {
+ if (this.status != ApplicationStatus.Terminating || this.status != ApplicationStatus.Terminated) {
onChildTerminatedEvent(id);
} else {
StatusChecker.getInstance().onChildStatusChange(id, this.id, this.appId);
http://git-wip-us.apache.org/repos/asf/stratos/blob/b51b0b79/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java
index 9b9695a..55f3b4e 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java
@@ -81,7 +81,7 @@ public class GroupMonitor extends ParentComponentMonitor implements EventHandler
} else if (status1 == ClusterStatus.Terminated || status1 == GroupStatus.Terminated) {
//Check whether all dependent goes Terminated and then start them in parallel.
this.aliasToInActiveMonitorsMap.remove(id);
- if (this.status != GroupStatus.Terminating) {
+ if (this.status != GroupStatus.Terminating || this.status != GroupStatus.Terminated) {
onChildTerminatedEvent(id);
} else {
StatusChecker.getInstance().onChildStatusChange(id, this.id, this.appId);
http://git-wip-us.apache.org/repos/asf/stratos/blob/b51b0b79/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java
index d2d8b44..3a925d1 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java
@@ -156,13 +156,13 @@ public class StatusChecker {
/**
* @param clusterId
- * @param partitionContext is to decide in which partition has less members while others have active members
+ * @param partitionId is to decide in which partition has less members while others have active members
*/
- public void onMemberFaultEvent(final String clusterId, final PartitionContext partitionContext) {
+ public void onMemberFaultEvent(final String clusterId, final String partitionId) {
Runnable group = new Runnable() {
public void run() {
ClusterMonitor monitor = (ClusterMonitor) AutoscalerContext.getInstance().getMonitor(clusterId);
- boolean clusterInActive = getClusterInActive(monitor, partitionContext);
+ boolean clusterInActive = getClusterInActive(monitor, partitionId);
String appId = monitor.getAppId();
if (clusterInActive) {
//if the monitor is dependent, temporarily pausing it
@@ -185,12 +185,12 @@ public class StatusChecker {
groupThread.start();
}
- private boolean getClusterInActive(AbstractClusterMonitor monitor, PartitionContext partitionContext) {
+ private boolean getClusterInActive(AbstractClusterMonitor monitor, String partitionId) {
boolean clusterInActive = false;
for (NetworkPartitionContext networkPartitionContext : monitor.getNetworkPartitionCtxts().values()) {
for (PartitionContext partition : networkPartitionContext.getPartitionCtxts().values()) {
- if (partitionContext.getPartitionId().equals(partition.getPartitionId()) &&
- partition.getActiveMemberCount() < partition.getMinimumMemberCount()) {
+ if (partitionId.equals(partition.getPartitionId()) &&
+ partition.getActiveMemberCount() <= partition.getMinimumMemberCount()) {
clusterInActive = true;
return clusterInActive;
}
[29/50] [abbrv] git commit: sending Cluster Terminated event when the
Cluster Monitor is not available/failed
Posted by im...@apache.org.
sending Cluster Terminated event when the Cluster Monitor is not available/failed
Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/128fe3e0
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/128fe3e0
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/128fe3e0
Branch: refs/heads/docker-grouping-merge
Commit: 128fe3e08b531f1353102282c0e6f17038902b66
Parents: 636d9bb
Author: Isuru Haththotuwa <is...@apache.org>
Authored: Tue Oct 28 21:26:51 2014 +0530
Committer: Isuru Haththotuwa <is...@apache.org>
Committed: Tue Oct 28 21:26:51 2014 +0530
----------------------------------------------------------------------
.../receiver/topology/AutoscalerTopologyEventReceiver.java | 5 +++++
1 file changed, 5 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/stratos/blob/128fe3e0/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 bff46c2..1423385 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
@@ -395,6 +395,11 @@ public class AutoscalerTopologyEventReceiver implements Runnable {
}
} 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());
}
}
[17/50] [abbrv] git commit: more cleanup of grouping pco artifacts
Posted by im...@apache.org.
more cleanup of grouping pco artifacts
Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/5efc0252
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/5efc0252
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/5efc0252
Branch: refs/heads/docker-grouping-merge
Commit: 5efc02521c90c08e0c9928f63242acb23c667910
Parents: d7d226c
Author: Martin Eppel <me...@cisco..com>
Authored: Mon Oct 27 19:44:28 2014 -0700
Committer: Martin Eppel <me...@cisco..com>
Committed: Mon Oct 27 19:46:59 2014 -0700
----------------------------------------------------------------------
.../autoscaler/ComplexApplicationContext.java | 916 -------------------
.../impl/CloudControllerServiceImpl.java | 1 -
.../controller/topology/TopologyBuilder.java | 109 +--
.../controller/topology/TopologyManager.java | 2 -
.../application/utils/ApplicationUtils.java | 2 -
.../messaging/domain/topology/Topology.java | 7 +-
.../util/CompositeApplicationBuilder.java | 226 -----
...ompositeApplicationCreatedEventListener.java | 26 -
...ompositeApplicationRemovedEventListener.java | 26 -
...ositeApplicationCreatedMessageProcessor.java | 98 --
...ositeApplicationRemovedMessageProcessor.java | 100 --
11 files changed, 10 insertions(+), 1503 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/stratos/blob/5efc0252/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/ComplexApplicationContext.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/ComplexApplicationContext.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/ComplexApplicationContext.java
deleted file mode 100644
index 84df0fb..0000000
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/ComplexApplicationContext.java
+++ /dev/null
@@ -1,916 +0,0 @@
-package org.apache.stratos.autoscaler;
-
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.messaging.domain.topology.*;
-import org.apache.stratos.messaging.domain.topology.util.CompositeApplicationBuilder;
-import org.apache.stratos.messaging.message.receiver.topology.TopologyManager;
-
-import java.util.*;
-
-
-public class ComplexApplicationContext {
-
- static {
- is_kill_all_enabled_flag = new HashMap<String, Boolean>();
- is_in_kill_all_transition = new HashSet<String>();
- }
-
- private static Map<String, Boolean> is_kill_all_enabled_flag;
- private static HashSet<String> is_in_kill_all_transition;
-
-
-
- private static final Log log = LogFactory.getLog(ComplexApplicationContext.class);
-
- // return value of true will bring up new instance (all startup dependencies are up and active)
- public static boolean checkStartupDependencies (String clusterId) {
- String serviceType = "undefined";
- if (log.isDebugEnabled()) {
- log.debug("checkStartupDependenciesY: serviceType " + serviceType + " + clusterId "+ clusterId);
- }
- return checkServiceDependencies (serviceType, clusterId, false);
- }
-
-
- public boolean checkStartupDependencies (String serviceType, String clusterId) {
- if (log.isDebugEnabled()) {
- log.debug("checkStartupDependenciesY: serviceType " + serviceType + " + clusterId "+ clusterId);
- }
- return checkServiceDependencies (serviceType, clusterId, false);
- }
-
-
- // return false will terminate instances
- public boolean checkKillDependencies (String clusterId) {
- String serviceType = "undefined";
- if (log.isDebugEnabled()) {
- log.debug("checkKillDependenciesY: serviceType " + serviceType + " + clusterId "+ clusterId);
- }
- return checkKillTerminateDependencies (serviceType, clusterId, true);
- }
-
- public boolean checkKillDependencies (String serviceType, String clusterId) {
- if (log.isDebugEnabled()) {
- log.debug("checkKillDependenciesY: serviceType " + serviceType + " + clusterId "+ clusterId);
- }
- return checkKillTerminateDependencies (serviceType, clusterId, true);
- }
-
-
- public static boolean checkServiceDependencies(String serviceType, String clusterId, boolean kill_flag) {
-
-
- if (log.isDebugEnabled()) {
- log.debug("ServiceGroupContext:checkServiceDependencies for service with XY " +
- " serviceType " + serviceType +
- " clusterId: " + clusterId + " kill_flag: " + kill_flag);
- }
-
- CompositeApplicationBuilder builder = new CompositeApplicationBuilder();
- CompositeApplication complexApplication = builder.buildCompositeApplication(TopologyManager.getTopology(), null);
-
-
- // no app configured
- if (complexApplication == null) {
- return true;
- }
-
- String aServiceId = serviceType;
- if (log.isDebugEnabled()) {
- log.debug("checking dependencies for service alias " + aServiceId);
- }
-
- if (aServiceId == null) {
- if (log.isDebugEnabled()) {
- log.debug("invalid serviceType null for cluster " + clusterId + "skipping dependency check (returning true)");
- }
- return true;
- }
-
- List<GroupTemp> service_type_groupTemps = complexApplication.findAllGroupsForServiceType(serviceType);
-
- String clusterGroupFromClusterId = extractClusterGroupFromClusterId(clusterId);
-
- if (clusterGroupFromClusterId == null) {
- if (log.isDebugEnabled()) {
- log.debug("cluster id " + clusterId + " has incompatible name to extract group, skipping dependency check (return true)");
- }
- }
-
- for (GroupTemp service_type_groupTemp : service_type_groupTemps) {
- // check if cluster is in the group
- if (log.isDebugEnabled()) {
- log.debug(" checking if cluster " + clusterId + " is in the group " + service_type_groupTemp.getAlias() +
- "extracted group from clusterId is " + clusterGroupFromClusterId);
- }
- if (service_type_groupTemp.getAlias().equals(clusterGroupFromClusterId)) {
- boolean result_flag = checkServiceDependenciesForServiceType (serviceType, clusterId, kill_flag, service_type_groupTemp);
- if (log.isDebugEnabled()) {
- log.debug("cluster is " + clusterId + " is in the group " + service_type_groupTemp.getAlias() + " and startup dependency check is " + result_flag);
- }
- return result_flag;
- }
- }
-
- if (log.isDebugEnabled()) {
- log.debug("no matching group found for cluster " + clusterId + " skipping dependency check (return true)" );
- }
-
- return true;
-
- }
-
- public static boolean checkServiceDependenciesForServiceType(String serviceType, String clusterId, boolean kill_flag, GroupTemp home_groupTemp) {
-
- String aServiceId = serviceType;
-
- if (home_groupTemp == null) {
- if (log.isDebugEnabled()) {
- log.debug(" lone cluster without group " + aServiceId + "skip checking and return true (no dependency check)" );
- }
- return true;
- }
-
-
- if (ComplexApplicationContext.isInKillAllTransition(getKillInTransitionKey(serviceType, home_groupTemp.getAlias()))) {
- if (log.isDebugEnabled()) {
- log.debug(" subscribable " + aServiceId + " is inKillAll transition, not spawning a new instance" );
- }
- return false;
- } else {
- if (log.isDebugEnabled()) {
- log.debug(" subscribable " + aServiceId + " is not inKillAll transition, continue with dependenciy check" );
- }
- }
-
- Map<String, String> downstreamDependencies = home_groupTemp.getDownStreamDependenciesAsMap(aServiceId);
-
-
- if (downstreamDependencies == null || downstreamDependencies.size() == 0) {
- if (log.isDebugEnabled()) {
- log.debug("serviceType " + aServiceId + " has no dependencies, returning true (no kill)");
- }
- return true;
- }
-
- if (log.isDebugEnabled()) {
- StringBuffer buf = new StringBuffer();
- buf.append("downstreamdependencies list: [ ");
-
-
- Set<String> downstream_keys = downstreamDependencies.keySet();
- for (String c : downstream_keys) {
- String d = downstreamDependencies.get(c);
- buf.append(c + ", in group: ").append(downstreamDependencies.get(d));
- }
-
- buf.append("] ").append(" serviceId ").append(aServiceId);
- log.debug(buf.toString());
- }
-
-
- List<String> in_active_downstreams = getServiceSet_StateInActive(downstreamDependencies);
- if (in_active_downstreams.size() > 0) {
- if (log.isDebugEnabled()) {
- log.debug("found inactive downstream dependencies for serviceType " + aServiceId + " returning false");
- for (String in_active : in_active_downstreams) {
- log.debug("inactive downstream dependency " + in_active + " for " + aServiceId);
- }
- }
-
- return false;
- }
-
- if (log.isDebugEnabled()) {
- log.debug("returning true for dependency check on serviceType " + serviceType);
- }
- return true;
- }
-
- // return false will terminate instances
- public boolean checkKillTerminateDependencies (String serviceType, String clusterId, boolean kill_flag) {
- if (log.isDebugEnabled()) {
- log.debug("ServiceGroupContext:checkKillTerminateDependencies for service with X " +
- " serviceType " + serviceType +
- " clusterId: " + clusterId + " kill_flag: " + kill_flag);
- }
-
- if (log.isDebugEnabled()) {
- log.debug("getting app from builder ");
- }
-
- CompositeApplicationBuilder builder = new CompositeApplicationBuilder();
- CompositeApplication complexApplication = builder.buildCompositeApplication(TopologyManager.getTopology(), null);
-
- String aServiceId = serviceType;
- if (log.isDebugEnabled()) {
- log.debug("checking dependencies for service alias " +
- aServiceId);
- }
-
- if (aServiceId == null) {
- if (log.isDebugEnabled()) {
- log.debug("invalid serviceType null for cluster " + clusterId + "skipping dependency check (returning true)");
- }
- return true;
- }
-
-
- // no app configured, don't terminate
- if (complexApplication == null) {
- return true;
- }
-
- List<GroupTemp> service_type_groupTemps = complexApplication.findAllGroupsForServiceType(serviceType);
-
- String clusterGroupFromClusterId = extractClusterGroupFromClusterId(clusterId);
-
- if (clusterGroupFromClusterId == null) {
- if (log.isDebugEnabled()) {
- log.debug("cluster id " + clusterId + " has incompatible name to extract group, skipping terminate dependency check (return true)");
- }
- }
-
- for (GroupTemp service_type_groupTemp : service_type_groupTemps) {
- // check if cluster is in the group
- if (log.isDebugEnabled()) {
- log.debug(" checking if cluster " + clusterId + " is in the group " + service_type_groupTemp.getAlias() +
- "extracted group from clusterId is " + clusterGroupFromClusterId);
- }
- if (service_type_groupTemp.getAlias().equals(clusterGroupFromClusterId)) {
- boolean result_flag = checkKillTerminateDependenciesForServiceType (serviceType, clusterId, kill_flag,
- service_type_groupTemp, complexApplication);
- if (log.isDebugEnabled()) {
- log.debug("cluster is " + clusterId + " is in the group " + service_type_groupTemp.getAlias() + " and kill dependency check is " + result_flag);
- }
- return result_flag;
- }
- }
-
- if (log.isDebugEnabled()) {
- log.debug("no matching group found for cluster " + clusterId + " skipping terminate dependency check (return true)" );
- }
-
- return true;
- }
-
- // return false will terminate instances
- public boolean checkKillTerminateDependenciesForServiceType (String serviceType, String clusterId, boolean kill_flag,
- GroupTemp home_groupTemp, CompositeApplication complexApplication ) {
-
- String aServiceId = serviceType;
-
- if (home_groupTemp == null) {
- if (log.isDebugEnabled()) {
- log.debug(" lone cluster without top level group " + aServiceId + "skip checking and return true (no kill)" );
- }
- return true;
- } else if (home_groupTemp.findGroup(aServiceId) == null) {
- if (log.isDebugEnabled()) {
- log.debug(" lone cluster without group " + aServiceId + "skip checking and return true (no kill)" );
- }
- return true;
- }
-
-
- //Group home_group = complexApplication.getTop_level().findGroup(aServiceId);
-
- if (log.isDebugEnabled()) {
- log.debug("checking downstream dependencies for " + aServiceId );
- }
- Map<String, String> downstreamDependencies = null;
- downstreamDependencies = home_groupTemp.getDownStreamDependenciesAsMap(aServiceId);
- if (log.isDebugEnabled()) {
- StringBuffer buf = new StringBuffer();
- buf.append("downstreamdependencies list: [ ");
-
- if (downstreamDependencies != null && downstreamDependencies.keySet().size() > 0) {
- Set<String> downstream_keys = downstreamDependencies.keySet();
- for (String c : downstream_keys) {
- String d = downstreamDependencies.get(c);
- buf.append(c + ", in group: ").append(d).append(" ");
- }
- buf.append("] ").append(" serviceId ").append(aServiceId);
- } else {
- buf.append(" downstreamDependencies is null ");
- }
- log.debug(buf.toString());
- }
-
-
-
- if (log.isDebugEnabled()) {
- log.debug("checking upstream dependencies for " + aServiceId );
- }
- // 2. get upstream dependencies
- Map<String, String> upstreamDependencies = home_groupTemp.getUpstreamDependenciesAsMap(aServiceId);
-
- if (log.isDebugEnabled()) {
- StringBuffer buf = new StringBuffer();
- buf.append("upstreamdependencies list: [ ");
-
- if (upstreamDependencies != null && upstreamDependencies.keySet().size() > 0) {
- Set<String> upstream_keys = upstreamDependencies.keySet();
- for (String c : upstream_keys) {
- String d = upstreamDependencies.get(c);
- buf.append(c + ", in group: ").append(upstreamDependencies.get(d)).append(" ");
- }
-
- buf.append("] ").append(" serviceId ").append(aServiceId);
- } else {
- buf.append(" upstreamDependencies is null ");
- }
- log.debug(buf.toString());
- }
-;
- List<String> in_active_upstreams = this.getServiceSet_StateInActive(upstreamDependencies);
-
- if (log.isDebugEnabled()) {
- log.debug("getting list of InActive upstream dependencies for " + aServiceId + " with size of " + in_active_upstreams.size());
- }
-
- String kill_behavior = Dependencies.KILL_UNDEFINED;
- // return false if instances should be terminated, true if not
- for (String serviceTypeAlias : in_active_upstreams) {
- String gr_alias = upstreamDependencies.get(serviceTypeAlias);
- GroupTemp gr = complexApplication.getGroupFromGroupAlias(gr_alias);
- if (gr != null) {
-
- kill_behavior = gr.getDependencies().getKill_behavior();
- if (kill_behavior.equals(Dependencies.KILL_ALL)) {
- if (ComplexApplicationContext.isKillAllEnabled(gr.getAlias())) {
- if (log.isDebugEnabled()) {
- log.debug(" isKillAllEnabled is enabled on upstream (kill) for group " + gr.getAlias() + ", disabling kilAll and preventing " +
- " serviceType " + aServiceId + " in group " + gr.getAlias() +
- " to spin up a new instance (setting killAllTransitionFlag) ");
- }
- // adding to the killalltransition flag
- // building key from alias + group alias
- ComplexApplicationContext.setKillAllTransitionFlag(getKillInTransitionKey(serviceTypeAlias,gr.getAlias()));
- // building key from alias + group alias
- ComplexApplicationContext.setKillAllTransitionFlag(getKillInTransitionKey(aServiceId, home_groupTemp.getAlias()));
- return false;
- } else {
- if (log.isDebugEnabled()) {
- log.debug(" isKillAllEnabled is disabled on upstream (no kill) for group " + gr.getAlias() );
- }
- return true;
- }
- } else if (kill_behavior.equals(Dependencies.KILL_DEPENDENTS)) {
- if (log.isDebugEnabled()) {
- log.debug(" continue to check upstream for kill_flag " + kill_behavior + " for group " + gr.getAlias() );
- }
- // continue to check
- } else if (kill_behavior.equals(Dependencies.KILL_NONE)) {
- if (log.isDebugEnabled()) {
- log.debug(" continue to check upstream for kill_flag " + kill_behavior + " for group " + gr.getAlias() );
- }
- // continue to check
- } else {
- if (log.isDebugEnabled()) {
- log.debug(" continue to check upstream for invalide kill_flag " + kill_behavior + " for group " + gr.getAlias() );
- }
- //continue to check
- }
- } else {
- // skip
- if (log.isDebugEnabled()) {
- log.debug(" no group found for " + serviceTypeAlias + " while loopig over in_active_upstreams" );
- }
- }
-
- }
-
- // check kill_all_enabled flag
- Map<String, String> all = complexApplication.getAllInPathOfAsMap(aServiceId, home_groupTemp);
- String [] group_with_kill_all_aliases = home_groupTemp.findAllGroupsWithKill2(all, Dependencies.KILL_ALL);
- // "persistent flag for each group"
- this.updateEnableKillAllFlag(all, group_with_kill_all_aliases);
-
- //List<String> in_active_downstreams = this.getClusterSet_StateInActive(dependeciesAliasArray);jj
- List<String> in_active_downstreams = this.getServiceSet_StateInActive(downstreamDependencies);
-
- if (log.isDebugEnabled()) {
- log.debug("getting list of InActive downstream dependencies for " + aServiceId + " with size of " + in_active_downstreams.size());
- }
-
- kill_behavior = Dependencies.KILL_UNDEFINED;
- for (String alias : in_active_downstreams) {
- GroupTemp gr = home_groupTemp.findGroup(alias);
- if (gr !=null) {
- kill_behavior = gr.getDependencies().getKill_behavior();
- if (kill_behavior.equals(Dependencies.KILL_ALL) ) {
- if (log.isDebugEnabled()) {
- log.debug(" return true on downstream for kill_flag " + kill_behavior + " for group " + gr.getAlias() );
- }
- if (ComplexApplicationContext.isKillAllEnabled(gr.getAlias())) {
- if (log.isDebugEnabled()) {
- log.debug(" isKillAllEnabled is enabled on downstream (kill) for group " + gr.getAlias() +
- " setting killAllTransitionFlag for" + alias);
- }
- // adding to the killalltransition flag
- ComplexApplicationContext.setKillAllTransitionFlag(alias);
- return false;
- } else {
- if (log.isDebugEnabled()) {
- log.debug(" isKillAllEnabled is disabled on downstream (no kill) for group " + gr.getAlias() );
- }
- return true;
- }
- } else if (kill_behavior.equals(Dependencies.KILL_DEPENDENTS)) {
- if (log.isDebugEnabled()) {
- //log.debug(" continue downstream for kill_flag " + kill_behavior + " for group " + gr.getAlias() );
- log.debug(" downstream service(s) is inactive for aServiceId " + aServiceId +
- " returning false (kill) and terminating cluster members" );
- }
- return false;
- } else if (kill_behavior.equals(Dependencies.KILL_NONE)) {
- if (log.isDebugEnabled()) {
- log.debug(" continue downstream to check for kill_flag " + kill_behavior + " for group " + gr.getAlias() );
- }
- // continue to check
- } else {
- if (log.isDebugEnabled()) {
- log.debug(" continue downstream to check for invalide kill_flag " + kill_behavior + " for group " + gr.getAlias() );
- }
- //continue to check
- }
- } else {
- // skip
- if (log.isDebugEnabled()) {
- log.debug(" no group found for " + alias + " while loopig over in_active_downstreams" );
- }
- }
-
- }
-
- // this cluster
- GroupTemp gr = home_groupTemp.findGroup(aServiceId);
- if (gr == null) {
- if (log.isDebugEnabled()) {
- log.debug(" cluster without group, should not reach this code ? for " + aServiceId );
- }
- return true;
- }
-
- kill_behavior = gr.getDependencies().getKill_behavior();
-
- if (kill_behavior.equals(Dependencies.KILL_DEPENDENTS)) {
- if (log.isDebugEnabled()) {
- log.debug(Dependencies.KILL_DEPENDENTS + " check if any downstream cluster is inactive for aServiceId " + aServiceId );
- }
- if (in_active_downstreams.size() > 0) {
- if (log.isDebugEnabled()) {
- log.debug(" downstream cluster(s) is inactive for aServiceId " + aServiceId +
- " returning false (kill) and terminating cluster members" );
- }
- return false;
- } else {
- if (log.isDebugEnabled()) {
- log.debug(" no downstream cluster(s) is inactive for aServiceId " + aServiceId +
- " returning true (no kill)" );
- }
- return true;
- }
- }
-
-
- if (log.isDebugEnabled()) {
- log.debug("returning true (no kill) for down and upstream dependency check on clusterId " + aServiceId);
- }
- return true;
- }
-
-
- private static boolean hasClusterActiveMember (Cluster cluster) {
- boolean flag = false;
- if(cluster.isLbCluster()){
- if (log.isDebugEnabled()) {
- log.debug("cluster member is lbCluster, not checking " + cluster);
- }
- }else{
- if (log.isDebugEnabled()) {
- log.debug("checking member acitve for " +
- " clusterId: " + cluster.getClusterId() +
- " serviceId: " + cluster.getServiceName());
- }
-
- Collection<Member> members = cluster.getMembers();
- for (Member member:members) {
- if (log.isDebugEnabled()) {
- log.debug("listing members while checking if active" +
- member.getMemberId() +
- " private Ip: " + member.getMemberIp() +
- " public Ip:" + member.getMemberPublicIp() +
- " member state: " + member.getStatus());
- }
- if (member.getStatus().equals(MemberStatus.Activated)) {
- log.debug("member ACTIVE found :" + member.getMemberId());
- flag = true;
- break;
- }
- }
-
- }
- return flag;
- }
-
-
-
- private static String extractAlias(String clusterId) {
- String [] s = clusterId.split("\\.");
- if (log.isDebugEnabled()) {
- log.debug("clusterId alias is " + clusterId + " size: " + s.length);
- }
- if (s.length == 0) {
- return null;
- }
- if (log.isDebugEnabled()) {
- log.debug("clusterId alias is " + clusterId + " alias: " + s[0]);
- }
- return s[0];
- }
-
- private static String extractClusterGroupFromClusterId(String clusterId) {
- String sub1 = extractAlias(clusterId);
- if (sub1 == null) {
- return null;
- }
-
- String [] s = sub1.split("-");
- if (log.isDebugEnabled()) {
- log.debug("clusterGroup alias is " + sub1 + " size: " + s.length);
- }
- if (s.length == 0) {
- return null;
- }
- if (log.isDebugEnabled()) {
- log.debug("cluster " + clusterId + " is in group " + s[0]);
- }
- return s[0];
- }
-
-
-
- private void updateEnableKillAllFlag(Map<String, String>all_dependencies, String [] group_with_kill_all_aliases) {
- if (log.isDebugEnabled()) {
- log.debug("updating enable_kill_flag ");
- }
- if (group_with_kill_all_aliases == null) {
- return;
- }
- //if (isClusterSet_StateActive(all_dependencies)) { //
- if (isServiceSet_StateActive(all_dependencies)) {
- for (String alias : group_with_kill_all_aliases) {
- ComplexApplicationContext.setKillAllEnabled(alias);
- if (log.isDebugEnabled()) {
- log.debug("enable enable_kill_flag for subscribable" + alias);
- }
- }
- //} else if (isClusterSet_StateInActive(all_dependencies)) {
- } else if (isServiceSet_StateInActive(all_dependencies)) {
- for (String alias : group_with_kill_all_aliases) {
- ComplexApplicationContext.resetKillAllEnabled(alias);
- if (log.isDebugEnabled()) {
- log.debug("disable enable_kill_flag for subscribable" + alias);
- }
- }
-
- // resetting killalltransition flag for all subscribables
- Set<String> key_set = all_dependencies.keySet();
- for (String serviceTypeAlias : key_set) {
- String group_alias = all_dependencies.get(serviceTypeAlias);
- ComplexApplicationContext.resetKillAllTransitionFlag(getKillInTransitionKey(serviceTypeAlias, group_alias));
- if (log.isDebugEnabled()) {
- log.debug("resetting enable_kill_flag, is_in_kill_all_transition for subscribable " + serviceTypeAlias + " in group " + group_alias);
- }
- }
-
- } else {
- // do nothing
- if (log.isDebugEnabled()) {
- log.debug("leaving enable_kill_flag, is_in_kill_all_transition unchanged ");
- }
- }
-
- }
-
- private static String getKillInTransitionKey(String serviceTypeAlias, String gr_alias) {
- return serviceTypeAlias + gr_alias;
- }
-
-
- private boolean isServiceSet_StateActive(Map<String, String>serviceTypes) {
- List<String> result = getServiceSet_StateActive(serviceTypes);
- if (result.size() == serviceTypes.size()) {
- return true;
- }
-
- return false;
- }
-
- private boolean isServiceSet_StateInActive(Map<String, String> serviceTypes) {
- List<String> result = getServiceSet_StateInActive(serviceTypes);
- if (result.size() == serviceTypes.size()) {
- return true;
- }
-
- return false;
- }
-
-
- private static List<String> getServiceSet_StateInActive(Map<String, String> serviceTypesMap) {
- List<String> result = new ArrayList<String> ();
-
- if (log.isDebugEnabled()) {
- log.debug("checking ServiceSet_StateInActive " + serviceTypesMap.size());
- }
-
- if (serviceTypesMap == null) {
- if (log.isDebugEnabled()) {
- log.debug("skipping getting set of InActive services, serviceTypes is null ");
- }
- return result;
- }
-
- if (log.isDebugEnabled()) {
- log.debug("getting set of InActive clusters for serviceTypes (length)" + serviceTypesMap.size());
- }
-
-
- Collection<Service> services = TopologyManager.getTopology().getServices();
-
- Set<String> serviceTypes = serviceTypesMap.keySet();
-
- for (String serviceType : serviceTypes) {
- boolean hasServiceFound = false;
- for(Service service : services) {
- String serviceTypeGroup = serviceTypesMap.get(serviceType);
- if (log.isDebugEnabled()) {
- log.debug("checking inactive state for service " + service.getServiceName() +
- " with nr_of_clusters: " + service.getClusters().size() +
- " against serviceType " + serviceType + " in group " + serviceTypeGroup);
- }
- if (serviceType.equals(service.getServiceName())) {
- // matching service type - check if has active cluster
- if (log.isDebugEnabled()) {
- log.debug("matching service types, checking clusters for service " + serviceType);
- }
- hasServiceFound = true;
- Collection<Cluster> clusters = service.getClusters();
- boolean hasClusterWithActiveMember = false;
- if (clusters.size() > 0) {
- // at least one cluster has to exist for service to exist
- if (log.isDebugEnabled()) {
- log.debug("service " + service.getServiceName() + " has at least 1 cluster ");
- }
- for (Cluster cluster : clusters) {
- String clusterGroup = extractClusterGroupFromClusterId(cluster.getClusterId());
- if (log.isDebugEnabled()) {
- log.debug("checking (inactive) cluster state for " + cluster.getClusterId() + " (in group " + clusterGroup + ")" +
- " and serviceType " + serviceType + " (in group " + serviceTypeGroup + ")");
- }
- // TODO if (hasClusterActiveMember (cluster)) {
- // check group cluster is in
-
- if (clusterGroup != null && clusterGroup.equals(serviceTypeGroup)) {
- if (hasClusterActiveMember (cluster)) {
- hasClusterWithActiveMember = true;
- if (log.isDebugEnabled()) {
- log.debug("found active cluster for service " + cluster.getClusterId() + " in group " + serviceTypeGroup);
- }
- break;
- }
- }
- }
- } else {
- if (log.isDebugEnabled()) {
- log.debug("service " + service.getServiceName() + " in group " + serviceTypeGroup + " has no cluster, adding as inactive service ");
- hasClusterWithActiveMember = false;
- }
- }
-
- if (!hasClusterWithActiveMember) {
- result.add(serviceType);
- if (log.isDebugEnabled()) {
- log.debug("service has not a clutser with active member, adding " + serviceType + " as inactive");
- }
- }
- } else {
- if (log.isDebugEnabled()) {
- log.debug("service mismatch between " + service.getServiceName() + " and servicetype " + serviceType + " continue to search ");
- }
- }
-
- }
- // covers the case that service hasn't be deployed yet
- if (!hasServiceFound) {
- result.add(serviceType);
- if (log.isDebugEnabled()) {
- log.debug("no matching service found for " + serviceType + " adding as inactive");
- }
- }
- }
-
- return result;
- }
-
-
- private List<String> getServiceSet_StateActive (Map<String, String> serviceTypesMap) {
- List<String> result = new ArrayList<String> ();
-
- if (log.isDebugEnabled()) {
- log.debug("checking ServiceSet_StateActive " + serviceTypesMap.size());
- }
-
- if (serviceTypesMap == null) {
- if (log.isDebugEnabled()) {
- log.debug("skipping getting set of Active services, serviceTypes is null ");
- }
- return result;
- }
-
- if (log.isDebugEnabled()) {
- log.debug("getting set of Active clusters for serviceTypes (length)" + serviceTypesMap.size());
- }
-
-
- Collection<Service> services = TopologyManager.getTopology().getServices();
-
- Set<String> serviceTypes = serviceTypesMap.keySet();
-
- for (String serviceType : serviceTypes) {
- boolean hasServiceFound = false;
- for(Service service : services) {
- String serviceTypeGroup = serviceTypesMap.get(serviceType);
- if (log.isDebugEnabled()) {
- log.debug("checking active state for service " + service.getServiceName() +
- " with nr_of_clusters: " + service.getClusters().size() +
- " against serviceType " + serviceType + " in group " + serviceTypeGroup);
- }
- if (serviceType.equals(service.getServiceName())) {
- // matching service type - check if has active cluster
- if (log.isDebugEnabled()) {
- log.debug("matching service types, checking clusters for service " + serviceType);
- }
- hasServiceFound = true;
- Collection<Cluster> clusters = service.getClusters();
- boolean hasClusterWithActiveMember = false;
- if (clusters.size() > 0) {
- // at least one cluster has to exist for service to exist
- if (log.isDebugEnabled()) {
- log.debug("service " + service.getServiceName() + " has at least 1 cluster ");
- }
- for (Cluster cluster : clusters) {
- String clusterGroup = extractClusterGroupFromClusterId(cluster.getClusterId());
- if (log.isDebugEnabled()) {
- log.debug("checking (active) cluster state for " + cluster.getClusterId() + " (in group " + clusterGroup + ")" +
- " and serviceType " + serviceType + " (in group " + serviceTypeGroup + ")");
- }
-
- if (clusterGroup != null && clusterGroup.equals(serviceTypeGroup) && hasClusterActiveMember (cluster)) {
- hasClusterWithActiveMember = true;
- if (log.isDebugEnabled()) {
- log.debug("found active cluster for service " + cluster.getClusterId() + " in group " + serviceTypeGroup +
- " , adding as active service");
- }
- result.add(serviceType);
- break;
- }
- }
- } else {
- if (log.isDebugEnabled()) {
- log.debug("service " + service.getServiceName() + " has no cluster, skipping service ");
- hasClusterWithActiveMember = false;
- }
- }
-
- if (!hasClusterWithActiveMember) {;
- if (log.isDebugEnabled()) {
- log.debug("service has not a clutser with active member, skipping " + serviceType + " as active service");
- }
- }
- } else {
- if (log.isDebugEnabled()) {
- log.debug("service mismatch between " + service.getServiceName() + " and servicetype " + serviceType + " continue to search ");
- }
- }
-
- }
- // covers the case that service hasn't be deployed yet
- if (!hasServiceFound) {
- if (log.isDebugEnabled()) {
- log.debug("no matching service found for " + serviceType + " skipping as active service");
- }
- }
- }
-
- return result;
- }
-
- /*
- * get a list of clusters based on the subscription alias name
- */
- private List<Cluster> getClusters (String [] clusterAliases) {
- List<Cluster> clusters = new ArrayList<Cluster>();
-
- for (String alias : clusterAliases) {
- Cluster cluster = getClusterFromAlias(alias);
- if (cluster != null) {
- clusters.add(cluster);
- } else {
- if (log.isDebugEnabled()) {
- log.debug("getting a (inactive) cluster retrieved as null for alias " + alias);
- }
- }
- }
- return clusters;
- }
-
- /*
- * get a cluster based on the subscription alias name
- */
- private Cluster getClusterFromAlias(String findClusterId) {
- Cluster result = null;
- Collection<Service> services = TopologyManager.getTopology().getServices();
- for(Service service : services) {
- // extract list of clusters, clusterId -> alias
- if (log.isDebugEnabled()) {
- log.debug("ServiceGroupContext:calculateKillBehaviorFlag:service:" + service.getServiceName());
- }
-
- for(Cluster cluster : service.getClusters()) {
- String clusterId = cluster.getClusterId();
- String clusterIdAlias = this.extractAlias(clusterId);
- if (log.isDebugEnabled()) {
- log.debug("looping over cluster " + clusterId +
- " extracted alias " + clusterIdAlias);
- }
-
- if (clusterIdAlias != null && findClusterId.equals(clusterIdAlias)) {
- return cluster;
- } else {
- if (log.isDebugEnabled()) {
- log.debug(" ignoring cluster " + clusterId + " in cluster check for " + findClusterId);
- }
- }
-
- }
- }
- return result;
- }
-
- private static void setKillAllEnabled(String groupId ) {
- ComplexApplicationContext.is_kill_all_enabled_flag.put(groupId, true);
- }
-
- private static void resetKillAllEnabled(String groupId ) {
- // all cartridges are terminated after kill_all
- ComplexApplicationContext.is_kill_all_enabled_flag.put(groupId, false);
- }
-
- private static void resetKillAllTransitionFlag(String alias) {
- ComplexApplicationContext.is_in_kill_all_transition.remove(alias);
- }
-
- private static void setKillAllTransitionFlag(String alias) {
- ComplexApplicationContext.is_in_kill_all_transition.add(alias);
- }
-
- public static synchronized Boolean isKillAllEnabled(String groupId) {
- Boolean flag = false;
- if (ComplexApplicationContext.is_kill_all_enabled_flag == null) {
- if (log.isDebugEnabled()) {
- log.debug(" creating new is_kill_all_enabled_flag");
- }
- ComplexApplicationContext.is_kill_all_enabled_flag = new HashMap<String, Boolean>();
- }
- flag = ComplexApplicationContext.is_kill_all_enabled_flag.get(groupId);
- if (flag == null) {
- if (log.isDebugEnabled()) {
- log.debug(" is_kill_all_enabled_flag not initialized for " + groupId + " initializing with true");
- }
-
- ComplexApplicationContext.setKillAllEnabled(groupId);
- flag = ComplexApplicationContext.is_kill_all_enabled_flag.get(groupId);
- }
- return flag;
- }
-
-
- public static synchronized Boolean isInKillAllTransition(String key) {
- if (ComplexApplicationContext.is_in_kill_all_transition == null) {
- if (log.isDebugEnabled()) {
- log.debug(" creating new is_in_kill_all_transition");
- }
- ComplexApplicationContext.is_in_kill_all_transition = new HashSet<String>();
- }
- if (ComplexApplicationContext.is_in_kill_all_transition.contains(key)) {
- return true;
- }
- return false;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/5efc0252/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java
index 0b322f8..6a337ba 100644
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java
@@ -44,7 +44,6 @@ import org.apache.stratos.cloud.controller.util.CloudControllerConstants;
import org.apache.stratos.cloud.controller.util.CloudControllerUtil;
import org.apache.stratos.cloud.controller.validate.interfaces.PartitionValidator;
import org.apache.stratos.messaging.domain.topology.Application;
-import org.apache.stratos.messaging.domain.topology.ConfigCompositeApplication;
import org.apache.stratos.messaging.domain.topology.Member;
import org.apache.stratos.messaging.domain.topology.MemberStatus;
import org.apache.stratos.messaging.util.Constants;
http://git-wip-us.apache.org/repos/asf/stratos/blob/5efc0252/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java
index f4606b8..e715130 100644
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java
@@ -30,7 +30,6 @@ import org.apache.stratos.cloud.controller.registry.RegistryManager;
import org.apache.stratos.cloud.controller.runtime.FasterLookUpDataHolder;
import org.apache.stratos.cloud.controller.util.CloudControllerUtil;
import org.apache.stratos.messaging.domain.topology.*;
-import org.apache.stratos.messaging.domain.topology.util.CompositeApplicationBuilder;
import org.apache.stratos.messaging.event.application.status.*;
import org.apache.stratos.messaging.event.application.status.AppStatusApplicationActivatedEvent;
import org.apache.stratos.messaging.event.application.status.AppStatusApplicationCreatedEvent;
@@ -65,6 +64,7 @@ public class TopologyBuilder {
log.warn(String.format("Cartridge list is empty"));
return;
}
+
try {
TopologyManager.acquireWriteLock();
@@ -99,7 +99,7 @@ public class TopologyBuilder {
public static void handleServiceRemoved(List<Cartridge> cartridgeList) {
Topology topology = TopologyManager.getTopology();
- for (Cartridge cartridge : cartridgeList) {
+ for (Cartridge cartridge : cartridgeList) {
if (topology.getService(cartridge.getType()).getClusters().size() == 0) {
if (topology.serviceExists(cartridge.getType())) {
try {
@@ -286,27 +286,6 @@ public class TopologyBuilder {
return;
}
- //grouping
-
- if (log.isDebugEnabled()) {
- log.debug("checking group id in ToplogyBuilder for member started event");
- }
-
- CompositeApplicationBuilder builder = new CompositeApplicationBuilder();
- String appAlias = "compositeApplicationAlias";
- CompositeApplication app = builder.buildCompositeApplication(topology, appAlias);
- if (app != null) {
- if (log.isDebugEnabled()) {
- log.debug("TopologyBuilder found composite app for " + appAlias);
- }
- String clusterId = instanceStartedEvent.getClusterId();
- String groupAlias = app.extractClusterGroupFromClusterId(clusterId);
- instanceStartedEvent.setGroupId(groupAlias);
- if (log.isDebugEnabled()) {
- log.debug("TopologyBuilder setting groupAlias " + groupAlias + " for instance started event for cluster " + clusterId);
- }
- }
-
try {
TopologyManager.acquireWriteLock();
// try update lifecycle state
@@ -348,23 +327,6 @@ public class TopologyBuilder {
return;
}
- // grouping
-
- CompositeApplicationBuilder builder = new CompositeApplicationBuilder();
- String appAlias = "compositeApplicationAlias";
- CompositeApplication app = builder.buildCompositeApplication(topology, appAlias);
- if (app != null) {
- if (log.isDebugEnabled()) {
- log.debug("TopologyBuilder found composite app for member activated " + appAlias);
- }
- String clusterId = instanceActivatedEvent.getClusterId();
- String groupAlias = app.extractClusterGroupFromClusterId(clusterId);
- instanceActivatedEvent.setGroupId(groupAlias);
- if (log.isDebugEnabled()) {
- log.debug("TopologyBuilder setting groupAlias " + groupAlias + " for instance activated event for cluster " + clusterId);
- }
- }
-
Member member = cluster.getMember(instanceActivatedEvent.getMemberId());
@@ -437,27 +399,7 @@ public class TopologyBuilder {
return;
}
- //grouping
-
- if (log.isDebugEnabled()) {
- log.debug("checking group id in ToplogyBuilder for member started event");
- }
-
- CompositeApplicationBuilder builder = new CompositeApplicationBuilder();
- String appAlias = "compositeApplicationAlias";
- CompositeApplication app = builder.buildCompositeApplication(topology, appAlias);
- if (app != null) {
- if (log.isDebugEnabled()) {
- log.debug("TopologyBuilder found composite app for " + appAlias);
- }
- String clusterId = instanceReadyToShutdownEvent.getClusterId();
- String groupAlias = app.extractClusterGroupFromClusterId(clusterId);
- instanceReadyToShutdownEvent.setGroupId(groupAlias);
- if (log.isDebugEnabled()) {
- log.debug("TopologyBuilder setting groupAlias " + groupAlias + " for instance ready shutdown event for cluster " + clusterId);
- }
- }
-
+
Member member = cluster.getMember(instanceReadyToShutdownEvent.getMemberId());
if (member == null) {
log.warn(String.format("Member %s does not exist",
@@ -521,28 +463,6 @@ public class TopologyBuilder {
}
- //grouping
-
- if (log.isDebugEnabled()) {
- log.debug("checking group id in ToplogyBuilder for member started event");
- }
-
- CompositeApplicationBuilder builder = new CompositeApplicationBuilder();
- String appAlias = "compositeApplicationAlias";
- CompositeApplication app = builder.buildCompositeApplication(topology, appAlias);
- if (app != null) {
- if (log.isDebugEnabled()) {
- log.debug("TopologyBuilder found composite app for " + appAlias);
- }
- String clusterId = instanceMaintenanceModeEvent.getClusterId();
-
- String groupAlias = app.extractClusterGroupFromClusterId(clusterId);
- instanceMaintenanceModeEvent.setGroupId(groupAlias);
- if (log.isDebugEnabled()) {
- log.debug("TopologyBuilder setting groupAlias " + groupAlias + " for instance ready shutdown event for cluster " + clusterId);
- }
- }
-
MemberMaintenanceModeEvent memberMaintenanceModeEvent = new MemberMaintenanceModeEvent(
instanceMaintenanceModeEvent.getServiceName(),
instanceMaintenanceModeEvent.getClusterId(),
@@ -591,27 +511,6 @@ public class TopologyBuilder {
return;
}
- //grouping
-
- if (log.isDebugEnabled()) {
- log.debug("checking group id in ToplogyBuilder for member started event");
- }
-
- CompositeApplicationBuilder builder = new CompositeApplicationBuilder();
- String appAlias = "compositeApplicationAlias";
- CompositeApplication app = builder.buildCompositeApplication(topology, appAlias);
-
- String groupAlias = null;
- if (app != null) {
- if (log.isDebugEnabled()) {
- log.debug("TopologyBuilder found composite app for " + appAlias);
- }
- groupAlias = app.extractClusterGroupFromClusterId(clusterId);
- if (log.isDebugEnabled()) {
- log.debug("TopologyBuilder setting groupAlias " + groupAlias + " for member terminated event for cluster " + clusterId);
- }
- }
-
try {
TopologyManager.acquireWriteLock();
properties = member.getProperties();
@@ -620,6 +519,8 @@ public class TopologyBuilder {
} finally {
TopologyManager.releaseWriteLock();
}
+ /* @TODO leftover from grouping_poc*/
+ String groupAlias = null;
TopologyEventPublisher.sendMemberTerminatedEvent(serviceName, clusterId, networkPartitionId, partitionId, memberId, properties, groupAlias);
}
http://git-wip-us.apache.org/repos/asf/stratos/blob/5efc0252/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyManager.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyManager.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyManager.java
index bc07404..9862b9a 100644
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyManager.java
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyManager.java
@@ -81,8 +81,6 @@ public class TopologyManager {
log.debug("Topology not found in registry, creating new");
}
topology = new Topology();
- } else {
- topology.getConfigCompositeApplication();
}
if (log.isDebugEnabled()) {
log.debug("Topology initialized");
http://git-wip-us.apache.org/repos/asf/stratos/blob/5efc0252/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/utils/ApplicationUtils.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/utils/ApplicationUtils.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/utils/ApplicationUtils.java
index 4dbf251..15d9d44 100644
--- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/utils/ApplicationUtils.java
+++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/utils/ApplicationUtils.java
@@ -8,8 +8,6 @@ import org.apache.commons.logging.LogFactory;
import org.apache.stratos.manager.exception.InvalidCartridgeAliasException;
import org.apache.stratos.messaging.broker.publish.EventPublisher;
import org.apache.stratos.messaging.broker.publish.EventPublisherPool;
-import org.apache.stratos.messaging.event.topology.CompositeApplicationCreatedEvent;
-import org.apache.stratos.messaging.event.topology.CompositeApplicationRemovedEvent;
import org.apache.stratos.messaging.util.Constants;
http://git-wip-us.apache.org/repos/asf/stratos/blob/5efc0252/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Topology.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Topology.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Topology.java
index 76d73fe..ddd5ffa 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Topology.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Topology.java
@@ -38,7 +38,7 @@ public class Topology implements Serializable {
private Map<String, Service> serviceMap;
//Grouping
private Map<String, CompositeApplication> compositeApplicationMap;
- private Map<String, ConfigCompositeApplication> configCompositeApplicationMap;
+ // grouping_poc private Map<String, ConfigCompositeApplication> configCompositeApplicationMap;
// Key: Application.id
private Map<String, Application> applicationMap;
@@ -48,7 +48,7 @@ public class Topology implements Serializable {
public Topology() {
this.serviceMap = new HashMap<String, Service>();
this.compositeApplicationMap = new HashMap<String, CompositeApplication>();
- this.configCompositeApplicationMap = new HashMap<String, ConfigCompositeApplication>();
+ // grouping_poc this.configCompositeApplicationMap = new HashMap<String, ConfigCompositeApplication>();
this.applicationMap = new HashMap<String, Application>();
}
@@ -124,6 +124,7 @@ public class Topology implements Serializable {
this.compositeApplicationMap.remove(alias);
}
+ /* grouping_poc
public Collection<ConfigCompositeApplication> getConfigCompositeApplication() {
if (this.configCompositeApplicationMap == null) {
@@ -188,6 +189,8 @@ public class Topology implements Serializable {
public void setConfigCompositeApplicationMap(Map<String, ConfigCompositeApplication> configCompositeApplicationMap) {
this.configCompositeApplicationMap = configCompositeApplicationMap;
}
+
+ */
public void setInitialized(boolean initialized) {
this.initialized = initialized;
http://git-wip-us.apache.org/repos/asf/stratos/blob/5efc0252/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/util/CompositeApplicationBuilder.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/util/CompositeApplicationBuilder.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/util/CompositeApplicationBuilder.java
deleted file mode 100644
index e29fdbb..0000000
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/util/CompositeApplicationBuilder.java
+++ /dev/null
@@ -1,226 +0,0 @@
-package org.apache.stratos.messaging.domain.topology.util;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.messaging.domain.topology.*;
-
-import java.util.*;
-
-
-
-public class CompositeApplicationBuilder {
-
- private Map<String, GroupTemp> groups = null;
- private Map<String, Cartridge> cartridgesTypes = null;
-
- private List<ConfigGroup> configGroupArray = null;
- private List<ConfigCartridge> configCartridgeArray = null;
-
- private static Log log = LogFactory.getLog(CompositeApplicationBuilder.class);
-
- public CompositeApplication buildCompositeApplication(Topology topology, String appAlias) {
- if (log.isDebugEnabled()) {
- log.debug("buildCompositeApplication configComplexApplication with topology " + topology);
- }
- Collection<ConfigCompositeApplication> configComplexApplications = topology.getConfigCompositeApplication();
- CompositeApplication complexApplication = new CompositeApplication();
- if (configComplexApplications.size() > 0) {
- ConfigCompositeApplication [] complexConfigAppArray = new ConfigCompositeApplication[configComplexApplications.size()];
- complexConfigAppArray = configComplexApplications.toArray(complexConfigAppArray);
-
- // assuming only 1 complex app is configured
-
- ConfigCompositeApplication configComplexApplication = complexConfigAppArray[0];
- if (log.isDebugEnabled()) {
- log.debug("buildCompositeApplication configComplexApplication" + configComplexApplication);
- }
- if (configComplexApplication!= null) {
- if (log.isDebugEnabled()) {
- log.debug("buildCompositeApplication configComplexApplication" + configComplexApplication);
- }
- setConfigConfiguration(configComplexApplication);
-
- GroupTemp top_level = this.buildApplication();
- if (top_level != null) {
- if (log.isDebugEnabled()) {
- log.debug("ServiceGroupContext:configComplexApplication toplevel is " + top_level.getAlias());
- }
- } else {
- if (log.isDebugEnabled()) {
- log.debug("buildCompositeApplication toplevel is null");
- }
- }
- if (top_level == null) {
- log.debug("buildCompositeApplication top level group is null ...");
- return null;
- } else {
- log.debug("buildCompositeApplication setting top level group " + top_level.getAlias());
- //complexApplication.setTop_level(top_level);
- complexApplication.setAll_groups(this.groups);
- return complexApplication;
- }
- } else {
- log.debug("buildCompositeApplication configComplexApplication is null");
- }
- } else {
- log.debug("buildCompositeApplication configComplexApplications is null");
- return null;
- }
- return null;
- }
-
-
-
- public GroupTemp buildApplication() {
-
- for (ConfigGroup configGroup : configGroupArray) {
- log.debug("deploying group " + configGroup.getAlias());
- GroupTemp realGroupTemp = new GroupTemp(configGroup.getAlias());
- groups.put(realGroupTemp.getAlias(), realGroupTemp);
- }
-
-
- for (ConfigCartridge configCartridge : configCartridgeArray) {
- log.debug("deploying cartridge component " + configCartridge.getAlias());
- Cartridge realCartridge = new Cartridge(configCartridge.getAlias());
- cartridgesTypes.put(realCartridge.getAlias(), realCartridge);
- }
-
- // building groups
- // this should be done when reading the topology event in autoscaler
- log.debug("converting group configuration to groups and assembling application");
- for (ConfigGroup configGroup : configGroupArray) {
- GroupTemp assembleGroupTemp = groups.get(configGroup.getAlias());
- Map<String, Cartridge> groupCartridges = new HashMap<String, Cartridge>();
- log.debug("converting configuration for group " + assembleGroupTemp.getAlias());
- for (String key : configGroup.getSubscribables()) {
- GroupTemp realgroup = groups.get(key);
- if (realgroup != null) {
- // try cartridges
- assembleGroupTemp.add(realgroup);
- realgroup.setParent(assembleGroupTemp);
- realgroup.setHomeGroup(assembleGroupTemp);
- } else {
- Cartridge realcartridge_type = cartridgesTypes.get(key);
- if (realcartridge_type != null) {
- // create a copy of the cartridge type
- Cartridge groupCartridge = new Cartridge(realcartridge_type.getAlias());
- groupCartridge.setCartridgeId(getCartridgeId(assembleGroupTemp.getAlias(), realcartridge_type.getAlias()));
- assembleGroupTemp.add(groupCartridge);
- groupCartridge.setParent(assembleGroupTemp);
- groupCartridge.setHomeGroup(assembleGroupTemp); // TODO need to consolidate parent / home group
- groupCartridges.put(groupCartridge.getAlias(), groupCartridge);
- if (log.isDebugEnabled()) {
- log.debug("added new cartrdige of type " + groupCartridge.getAlias() + " and cartrdigeId " + groupCartridge.getCartridgeId() +
- " to group " + assembleGroupTemp.getAlias());
- }
- } else {
- log.debug("Error: no group, cartridge found for alias: " + key);
- }
- }
- }
- // build dependencies
- log.debug("building dependencies for group " + assembleGroupTemp.getAlias());
- Dependencies real_dependencies = buildDependency(configGroup, groups, groupCartridges);
- assembleGroupTemp.setDependencies(real_dependencies);
- real_dependencies.setGroupTemp(assembleGroupTemp);
- }
-
- GroupTemp application = getTopLevelGroup();
- log.debug("top level group is: " + application.getAlias());
-
- return application;
- }
-
- public GroupTemp getTopLevelGroup () {
- String alias = null;
- for (ConfigGroup configGroup : configGroupArray) {
- alias = configGroup.getAlias();
- boolean isTopLevelGroup = true;
- log.debug("checking if group " + alias + " is a sub component");
- for (ConfigGroup configGroupInner : configGroupArray) {
- for (String key : configGroupInner.getSubscribables()) {
- log.debug("in group " + configGroupInner.getAlias() );
- if (key.equals(alias)) {
- log.debug("found group " + alias + " as sub component in " + configGroupInner.getAlias());
- isTopLevelGroup = false;
- break;
- }
- }
- }
- if (isTopLevelGroup) {
- log.debug("is top level group: " + alias);
- break;
- }
- }
- GroupTemp application = groups.get(alias);
- log.debug("top level group is: " + alias);
- return application;
- }
-
- public Dependencies buildDependency(ConfigGroup configGroup, Map<String, GroupTemp> groups, Map<String, Cartridge> groupCartridges) {
-
- // building dependencies
- ConfigDependencies config_dep = configGroup.getDependencies();
- Dependencies real_dependencies = new Dependencies();
- if (config_dep != null) {
- String kill_behavior = config_dep.getKill_behavior();
- real_dependencies.setKill_behavior(kill_behavior);
- List<ConfigDependencies.Pair> startup_order = config_dep.getStartup_order();
- for (ConfigDependencies.Pair pair: startup_order) {
- String key = pair.getKey();
- String value = pair.getValue();
- //check groups
- GroupTemp gr = groups.get(value);
- log.debug("checking dependency for key " + key + " /val: " + value + " in groups");
- if (gr != null) {
- real_dependencies.addDependency(key, gr);
- } else {
- log.debug("checking dependency for key " + key + " /val: " + value + " in group cartridges");
- Cartridge cr = groupCartridges.get(value);
- if (cr != null) {
- real_dependencies.addDependency(key, cr);
- if (log.isDebugEnabled()) {
- log.debug("adding group cartridge " + cr.getCartridgeId()+ " as dependency");
- }
- } else {
- cr = this.cartridgesTypes.get(value);
- if (cr != null) {
- real_dependencies.addDependency(key, cr);
- if (log.isDebugEnabled()) {
- log.debug("adding a lone cartridge " + cr.getAlias() + " as dependency");
- }
- } else {
- log.debug("error retrieving group with name " + key);
- }
- }
- }
-
- }
- }
- return real_dependencies;
- }
-
- private void setConfigConfiguration(ConfigCompositeApplication configApp) {
- this.groups = new HashMap<String, GroupTemp>();
- this.cartridgesTypes = new HashMap<String, Cartridge>();
-
- if (configApp.getComponents() != null) {
- configGroupArray = configApp.getComponents();
- } else {
- configGroupArray = new ArrayList<ConfigGroup>();
- }
-
- if (configApp.getCartridges() != null) {
- configCartridgeArray = configApp.getCartridges();
- } else {
- configCartridgeArray = new ArrayList<ConfigCartridge>();
- }
-
- }
-
- private String getCartridgeId (String homeGroupId, String cartridgeType) {
- String id = homeGroupId +":"+ cartridgeType;
- return id;
- }
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/5efc0252/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/CompositeApplicationCreatedEventListener.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/CompositeApplicationCreatedEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/CompositeApplicationCreatedEventListener.java
deleted file mode 100644
index 6c3aa7a..0000000
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/CompositeApplicationCreatedEventListener.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.stratos.messaging.listener.topology;
-
-import org.apache.stratos.messaging.listener.EventListener;
-
-public abstract class CompositeApplicationCreatedEventListener extends EventListener {
-
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/5efc0252/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/CompositeApplicationRemovedEventListener.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/CompositeApplicationRemovedEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/CompositeApplicationRemovedEventListener.java
deleted file mode 100644
index 04dce2b..0000000
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/CompositeApplicationRemovedEventListener.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.stratos.messaging.listener.topology;
-
-import org.apache.stratos.messaging.listener.EventListener;
-
-public abstract class CompositeApplicationRemovedEventListener extends EventListener {
-
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/5efc0252/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/CompositeApplicationCreatedMessageProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/CompositeApplicationCreatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/CompositeApplicationCreatedMessageProcessor.java
deleted file mode 100644
index 1b4faa5..0000000
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/CompositeApplicationCreatedMessageProcessor.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.stratos.messaging.message.processor.topology;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.messaging.domain.topology.ConfigCompositeApplication;
-import org.apache.stratos.messaging.domain.topology.Topology;
-import org.apache.stratos.messaging.event.topology.CompositeApplicationCreatedEvent;
-import org.apache.stratos.messaging.message.processor.MessageProcessor;
-import org.apache.stratos.messaging.util.Util;
-import org.apache.stratos.messaging.domain.topology.CompositeApplication;
-import org.apache.stratos.messaging.domain.topology.util.CompositeApplicationBuilder;
-
-//Grouping
-public class CompositeApplicationCreatedMessageProcessor extends MessageProcessor {
-
- private static final Log log = LogFactory.getLog(CompositeApplicationCreatedMessageProcessor.class);
- private MessageProcessor nextProcessor;
-
- @Override
- public void setNext(MessageProcessor nextProcessor) {
- this.nextProcessor = nextProcessor;
- }
-
- @Override
- public boolean process(String type, String message, Object object) {
- Topology topology = (Topology) object;
-
- if (log.isDebugEnabled()) {
- log.debug("processing application event of type " + type +
- " / topology:" + topology + " msg: " + message);
- }
-
- if (CompositeApplicationCreatedEvent.class.getName().equals(type)) {
- // Return if topology has not been initialized
- if (!topology.isInitialized()) {
-
- if (log.isDebugEnabled()) {
- log.debug("topology is not initialized .... need to add check ... Grouping");
- }
-
- //return false;
- }
-
- // Parse complete message and build event
- CompositeApplicationCreatedEvent event =
- (CompositeApplicationCreatedEvent) Util.jsonToObject(message, CompositeApplicationCreatedEvent.class);
-
- if (log.isDebugEnabled()) {
- log.debug("processing application created event with application id: " + event.getApplicationAlias());
- }
-
- // Validate event against the existing topology
- if (topology.compositeApplicationExists(event.getApplicationAlias())) {
- if (log.isWarnEnabled()) {
- log.warn(String.format("CompositeApplication already created: [com app] %s", event.getApplicationAlias()));
- }
- } else {
-
- ConfigCompositeApplication configApp = event.getCompositeApplication();
- String alias = "compositeApplicationAlias";
- if (log.isInfoEnabled()) {
- log.info("adding ConfigCompositeApplication with alias " + alias + " to topology");
- }
- topology.addConfigCompositeApplication(alias, configApp);
- }
-
- // Notify event listeners
- notifyEventListeners(event);
- return true;
-
- } else {
- if (nextProcessor != null) {
- // ask the next processor to take care of the message.
- return nextProcessor.process(type, message, topology);
- } else {
- throw new RuntimeException(String.format("Failed to process message using available message processors: [type] %s [body] %s", type, message));
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/5efc0252/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/CompositeApplicationRemovedMessageProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/CompositeApplicationRemovedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/CompositeApplicationRemovedMessageProcessor.java
deleted file mode 100644
index 2bb688a..0000000
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/CompositeApplicationRemovedMessageProcessor.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.stratos.messaging.message.processor.topology;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.messaging.domain.topology.ConfigCompositeApplication;
-import org.apache.stratos.messaging.domain.topology.Service;
-import org.apache.stratos.messaging.domain.topology.Topology;
-import org.apache.stratos.messaging.event.topology.CompositeApplicationCreatedEvent;
-import org.apache.stratos.messaging.event.topology.CompositeApplicationRemovedEvent;
-import org.apache.stratos.messaging.message.processor.MessageProcessor;
-import org.apache.stratos.messaging.util.Util;
-import org.apache.stratos.messaging.domain.topology.CompositeApplication;
-import org.apache.stratos.messaging.domain.topology.util.CompositeApplicationBuilder;
-
-//Grouping
-public class CompositeApplicationRemovedMessageProcessor extends MessageProcessor {
-
- private static final Log log = LogFactory.getLog(CompositeApplicationRemovedMessageProcessor.class);
- private MessageProcessor nextProcessor;
-
- @Override
- public void setNext(MessageProcessor nextProcessor) {
- this.nextProcessor = nextProcessor;
- }
-
- @Override
- public boolean process(String type, String message, Object object) {
- Topology topology = (Topology) object;
-
- if (log.isDebugEnabled()) {
- log.debug("processing application event of type " + type +
- " / topology:" + topology + " msg: " + message);
- }
-
- if (CompositeApplicationRemovedEvent.class.getName().equals(type)) {
- // Return if topology has not been initialized
-
- if (!topology.isInitialized()) {
-
- if (log.isDebugEnabled()) {
- log.debug("topology is not initialized .... need to add check ... Grouping");
- }
- //return false;
- }
-
- // Parse complete message and build event
- CompositeApplicationRemovedEvent event =
- (CompositeApplicationRemovedEvent) Util.jsonToObject(message, CompositeApplicationRemovedEvent.class);
-
- if (log.isDebugEnabled()) {
- log.debug("processing application removed event with application id: " + event.getApplicationAlias());
- }
-
- // Validate event against the existing topology
- if (topology.configCompositeApplicationExists(event.getApplicationAlias())) {
- topology.removeAllConfigCompositeApplication();
- if (log.isDebugEnabled()) {
- log.debug("CompositeApplication exists, removing all ConfigCompositeApplication" + event.getApplicationAlias()) ;
- }
- } else {
- topology.removeAllConfigCompositeApplication();
- if (log.isWarnEnabled()) {
- log.warn("ConfigCompositeApplication " + event.getApplicationAlias() + " does not exist, removing all ") ;
- }
- }
-
-
-
- // Notify event listeners
- notifyEventListeners(event);
- return true;
-
- } else {
- if (nextProcessor != null) {
- // ask the next processor to take care of the message.
- return nextProcessor.process(type, message, topology);
- } else {
- throw new RuntimeException(String.format("Failed to process message using available message processors: [type] %s [body] %s", type, message));
- }
- }
- }
-}
[18/50] [abbrv] git commit: fixing issues while terminatnig the child
and adding life cycle check for group events
Posted by im...@apache.org.
fixing issues while terminatnig the child and adding life cycle check for group events
Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/7b4e3264
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/7b4e3264
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/7b4e3264
Branch: refs/heads/docker-grouping-merge
Commit: 7b4e326440287071d6271f9583caa2c1d947fe26
Parents: 5efc025
Author: reka <rt...@gmail.com>
Authored: Tue Oct 28 10:00:21 2014 +0530
Committer: reka <rt...@gmail.com>
Committed: Tue Oct 28 10:00:50 2014 +0530
----------------------------------------------------------------------
.../grouping/topic/StatusEventPublisher.java | 82 +++++++++++++++++---
.../AutoscalerTopologyEventReceiver.java | 12 ++-
.../stratos/autoscaler/monitor/Monitor.java | 9 ++-
.../monitor/ParentComponentMonitor.java | 11 ++-
.../monitor/application/ApplicationMonitor.java | 3 +-
.../monitor/cluster/ClusterMonitor.java | 6 +-
.../autoscaler/monitor/group/GroupMonitor.java | 3 +-
.../status/checker/StatusChecker.java | 27 +++++--
8 files changed, 118 insertions(+), 35 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/stratos/blob/7b4e3264/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/StatusEventPublisher.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/StatusEventPublisher.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/StatusEventPublisher.java
index ee75f74..fece506 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/StatusEventPublisher.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/StatusEventPublisher.java
@@ -4,7 +4,7 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.stratos.messaging.broker.publish.EventPublisher;
import org.apache.stratos.messaging.broker.publish.EventPublisherPool;
-import org.apache.stratos.messaging.domain.topology.ClusterDataHolder;
+import org.apache.stratos.messaging.domain.topology.*;
import org.apache.stratos.messaging.event.Event;
import org.apache.stratos.messaging.event.application.status.*;
import org.apache.stratos.messaging.event.application.status.AppStatusApplicationActivatedEvent;
@@ -14,6 +14,7 @@ import org.apache.stratos.messaging.event.application.status.AppStatusApplicatio
import org.apache.stratos.messaging.event.application.status.AppStatusClusterActivatedEvent;
import org.apache.stratos.messaging.event.application.status.AppStatusClusterInactivateEvent;
import org.apache.stratos.messaging.event.application.status.AppStatusGroupActivatedEvent;
+import org.apache.stratos.messaging.message.receiver.topology.TopologyManager;
import org.apache.stratos.messaging.util.Constants;
import java.util.Set;
@@ -83,9 +84,25 @@ public class StatusEventPublisher {
" [group]: " + groupId);
}
- AppStatusGroupActivatedEvent groupActivatedEvent = new AppStatusGroupActivatedEvent(appId, groupId);
+ try {
+ TopologyManager.acquireReadLockForApplication(appId);
+ Application application = TopologyManager.getTopology().getApplication(appId);
+ if(application != null) {
+ Group group = application.getGroupRecursively(groupId);
+ if(group.getStatus().getNextStates().contains(GroupStatus.Active)) {
+ AppStatusGroupActivatedEvent groupActivatedEvent =
+ new AppStatusGroupActivatedEvent(appId, groupId);
+
+ publishEvent(groupActivatedEvent);
+ } else {
+ log.warn("Active is not in the possible state list of [group] " + groupId);
+ }
+ }
+ } finally {
+ TopologyManager.releaseReadLockForApplication(appId);
+ }
+
- publishEvent(groupActivatedEvent);
}
public static void sendGroupInActivateEvent(String appId, String groupId) {
@@ -94,11 +111,25 @@ public class StatusEventPublisher {
log.info("Publishing Group in-activate event for [application]: " + appId +
" [group]: " + groupId);
}
+ try {
+ TopologyManager.acquireReadLockForApplication(appId);
+ Application application = TopologyManager.getTopology().getApplication(appId);
+ if(application != null) {
+ Group group = application.getGroupRecursively(groupId);
+ if(group.getStatus().getNextStates().contains(GroupStatus.Inactive)) {
+ AppStatusGroupInactivateEvent appStatusGroupInactivateEvent= new
+ AppStatusGroupInactivateEvent(appId, groupId);
+
+ publishEvent(appStatusGroupInactivateEvent);
+ } else {
+ log.warn("InActive is not in the possible state list of [group] " + groupId);
+ }
+ }
+ } finally {
+ TopologyManager.releaseReadLockForApplication(appId);
+ }
- AppStatusGroupInactivateEvent appStatusGroupInactivateEvent= new
- AppStatusGroupInactivateEvent(appId, groupId);
- publishEvent(appStatusGroupInactivateEvent);
}
public static void sendGroupTerminatingEvent(String appId, String groupId) {
@@ -107,9 +138,22 @@ public class StatusEventPublisher {
log.info("Publishing Group terminating event for [application]: " + appId +
" [group]: " + groupId);
}
-
- AppStatusGroupTerminatingEvent groupInTerminatingEvent = new AppStatusGroupTerminatingEvent(appId, groupId);
- publishEvent(groupInTerminatingEvent);
+ try {
+ TopologyManager.acquireReadLockForApplication(appId);
+ Application application = TopologyManager.getTopology().getApplication(appId);
+ if(application != null) {
+ Group group = application.getGroupRecursively(groupId);
+ if(group.getStatus().getNextStates().contains(GroupStatus.Terminating)) {
+ AppStatusGroupTerminatingEvent groupInTerminatingEvent =
+ new AppStatusGroupTerminatingEvent(appId, groupId);
+ publishEvent(groupInTerminatingEvent);
+ } else {
+ log.warn("Terminating is not in the possible state list of [group] " + groupId);
+ }
+ }
+ } finally {
+ TopologyManager.releaseReadLockForApplication(appId);
+ }
}
public static void sendGroupTerminatedEvent(String appId, String groupId) {
@@ -119,8 +163,24 @@ public class StatusEventPublisher {
" [group]: " + groupId);
}
- AppStatusGroupTerminatedEvent groupInTerminatedEvent = new AppStatusGroupTerminatedEvent(appId, groupId);
- publishEvent(groupInTerminatedEvent);
+ try {
+ TopologyManager.acquireReadLockForApplication(appId);
+ Application application = TopologyManager.getTopology().getApplication(appId);
+ if(application != null) {
+ Group group = application.getGroupRecursively(groupId);
+ if(group.getStatus().getNextStates().contains(GroupStatus.Terminated)) {
+ AppStatusGroupTerminatedEvent groupInTerminatedEvent =
+ new AppStatusGroupTerminatedEvent(appId, groupId);
+ publishEvent(groupInTerminatedEvent);
+ } else {
+ log.warn("Terminated is not in the possible state list of [group] " + groupId);
+ }
+ }
+ } finally {
+ TopologyManager.releaseReadLockForApplication(appId);
+ }
+
+
}
public static void sendApplicationActivatedEvent(String appId) {
http://git-wip-us.apache.org/repos/asf/stratos/blob/7b4e3264/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 89fe51f..9109d50 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
@@ -210,7 +210,13 @@ public class AutoscalerTopologyEventReceiver implements Runnable {
(AbstractClusterMonitor) AutoscalerContext.getInstance().getMonitor(clusterId);
//changing the status in the monitor, will notify its parent monitor
- clusterMonitor.setStatus(ClusterStatus.Terminating);
+ if (clusterMonitor != null) {
+ clusterMonitor.setDestroyed(true);
+ clusterMonitor.terminateAllMembers();
+ clusterMonitor.setStatus(ClusterStatus.Terminating);
+ } else {
+ log.warn("No Cluster Monitor found for cluster id " + clusterId);
+ }
//starting the status checker to decide on the status of it's parent
//StatusChecker.getInstance().onClusterStatusChange(clusterId, appId);
@@ -251,7 +257,9 @@ public class AutoscalerTopologyEventReceiver implements Runnable {
GroupMonitor monitor = (GroupMonitor) appMonitor.findGroupMonitorWithId(groupId);
//changing the status in the monitor, will notify its parent monitor
- monitor.setStatus(GroupStatus.Active);
+ if(monitor != null) {
+ monitor.setStatus(GroupStatus.Active);
+ }
}
});
http://git-wip-us.apache.org/repos/asf/stratos/blob/7b4e3264/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/Monitor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/Monitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/Monitor.java
index 2088351..9ef7d73 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/Monitor.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/Monitor.java
@@ -75,13 +75,14 @@ public abstract class Monitor implements EventHandler {
public boolean hasActiveMonitors() {
boolean hasMonitor = false;
- if(this.aliasToActiveMonitorsMap != null && !this.aliasToActiveMonitorsMap.isEmpty()) {
+ if ((this.aliasToActiveMonitorsMap != null && !this.aliasToActiveMonitorsMap.isEmpty()) ||
+ (this.aliasToInActiveMonitorsMap != null && !this.aliasToInActiveMonitorsMap.isEmpty())) {
hasMonitor = true;
}
return hasMonitor;
}
- public boolean hasMonitors () {
+ public boolean hasMonitors() {
return this.aliasToActiveMonitorsMap != null || this.aliasToInActiveMonitorsMap != null;
}
@@ -96,8 +97,8 @@ public abstract class Monitor implements EventHandler {
public boolean hasInDependentChild() {
boolean hasInDepChild = false;
- for(Monitor monitor : this.aliasToActiveMonitorsMap.values()) {
- if(!monitor.isDependent()) {
+ for (Monitor monitor : this.aliasToActiveMonitorsMap.values()) {
+ if (!monitor.isDependent()) {
hasInDepChild = true;
break;
}
http://git-wip-us.apache.org/repos/asf/stratos/blob/7b4e3264/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ParentComponentMonitor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ParentComponentMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ParentComponentMonitor.java
index 9f3417d..6aa76b6 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ParentComponentMonitor.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ParentComponentMonitor.java
@@ -116,7 +116,7 @@ public abstract class ParentComponentMonitor extends Monitor {
List<ApplicationContext> terminationList;
Monitor monitor;
//Temporarily move the group/cluster to inactive list
- this.aliasToInActiveMonitorsMap.put(idOfEvent, this.aliasToActiveMonitorsMap.remove(idOfEvent));
+ //this.aliasToInActiveMonitorsMap.put(idOfEvent, this.aliasToActiveMonitorsMap.remove(idOfEvent));
if(this.hasDependent) {
//need to notify the parent
@@ -171,18 +171,20 @@ public abstract class ParentComponentMonitor extends Monitor {
context.setTerminated(true);
terminationList = this.dependencyTree.getTerminationDependencies(idOfEvent);
+
+
/**
* Make sure that all the dependents have been terminated properly to start the recovery
*/
if (terminationList != null) {
for (ApplicationContext context1 : terminationList) {
- if (this.aliasToInActiveMonitorsMap.containsKey(context1.getId())) {
+ if (!this.aliasToInActiveMonitorsMap.containsKey(context1.getId())) {
allDependentTerminated = false;
} else if (this.aliasToActiveMonitorsMap.containsKey(context1.getId())) {
log.warn("Dependent [monitor] " + context1.getId() + " not in the correct state");
allDependentTerminated = false;
} else {
- allDependentTerminated = true;
+ log.info("Waiting for the [dependent] " + context1.getId() + " to be terminated...");
}
}
}
@@ -213,11 +215,12 @@ public abstract class ParentComponentMonitor extends Monitor {
//Find the non existent monitor by traversing dependency tree
try {
- this.startDependency();
+ this.startDependencyOnTermination();
} catch (TopologyInConsistentException e) {
e.printStackTrace();
}
} else {
+ StatusChecker.getInstance().onChildStatusChange(idOfEvent, this.id, this.appId);
log.info("Waiting for the dependent of [monitor] " + idOfEvent
+ " to be terminated");
}
http://git-wip-us.apache.org/repos/asf/stratos/blob/7b4e3264/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 45530c5..66044ef 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
@@ -179,8 +179,7 @@ public class ApplicationMonitor extends ParentComponentMonitor {
} else if (status1 == ClusterStatus.Terminated || status1 == GroupStatus.Terminated) {
//Check whether all dependent goes Terminated and then start them in parallel.
this.aliasToInActiveMonitorsMap.remove(id);
- if (this.status != ApplicationStatus.Terminating && !this.aliasToInActiveMonitorsMap.isEmpty() &&
- !this.aliasToActiveMonitorsMap.isEmpty()) {
+ if (this.status != ApplicationStatus.Terminating) {
onChildTerminatedEvent(id);
} else {
StatusChecker.getInstance().onChildStatusChange(id, this.id, this.appId);
http://git-wip-us.apache.org/repos/asf/stratos/blob/7b4e3264/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 557fedb..a089fc6 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
@@ -72,12 +72,12 @@ public class ClusterMonitor extends AbstractClusterMonitor {
@Override
public void run() {
while (!isDestroyed()) {
- if (log.isDebugEnabled()) {
- log.debug("Cluster monitor is running.. " + this.toString());
- }
try {
if ((this.status.getCode() <= ClusterStatus.Active.getCode()) ||
(this.status == ClusterStatus.Inactive && !hasDependent)) {
+ if (log.isDebugEnabled()) {
+ log.debug("Cluster monitor is running.. " + this.toString());
+ }
monitor();
} else {
if (log.isDebugEnabled()) {
http://git-wip-us.apache.org/repos/asf/stratos/blob/7b4e3264/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java
index 3123782..dff0bba 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java
@@ -94,8 +94,7 @@ public class GroupMonitor extends ParentComponentMonitor implements EventHandler
} else if (status1 == ClusterStatus.Terminated || status1 == GroupStatus.Terminated) {
//Check whether all dependent goes Terminated and then start them in parallel.
this.aliasToInActiveMonitorsMap.remove(id);
- if (this.status != GroupStatus.Terminating && !this.aliasToInActiveMonitorsMap.isEmpty() &&
- !this.aliasToActiveMonitorsMap.isEmpty()) {
+ if (this.status != GroupStatus.Terminating) {
onChildTerminatedEvent(id);
} else {
StatusChecker.getInstance().onChildStatusChange(id, this.id, this.appId);
http://git-wip-us.apache.org/repos/asf/stratos/blob/7b4e3264/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java
index 7b3e0ac..acf6d71 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java
@@ -289,8 +289,8 @@ public class StatusChecker {
//send the in activation event
if (parent instanceof Application) {
//send application activated event
- log.info("sending app in-active : " + appId);
- StatusEventPublisher.sendApplicationInactivatedEvent(appId);
+ log.warn("Application can't be in in-active : " + appId);
+ //StatusEventPublisher.sendApplicationInactivatedEvent(appId);
} else if (parent instanceof Group) {
//send activation to the parent
log.info("sending group in-active: " + parent.getUniqueIdentifier());
@@ -301,9 +301,22 @@ public class StatusChecker {
groupStatus == GroupStatus.Terminated && clusterStatus == ClusterStatus.Terminated) {
//send the terminated event
if (parent instanceof Application) {
- //send application activated event
- log.info("sending app terminated: " + appId);
- StatusEventPublisher.sendApplicationTerminatedEvent(appId, parent.getClusterDataRecursively());
+ //validating the life cycle
+ try {
+ TopologyManager.acquireReadLockForApplication(appId);
+ Application application = TopologyManager.getTopology().getApplication(appId);
+ if(application.getStatus().equals(ApplicationStatus.Terminating)) {
+ log.info("sending app terminated: " + appId);
+ StatusEventPublisher.sendApplicationTerminatedEvent(appId, parent.getClusterDataRecursively());
+ } else {
+ log.info("[Application] " + appId + " is in the [status] " +
+ application.getStatus().toString() + ". Hence not sending terminated event");
+ }
+
+ } finally {
+ TopologyManager.releaseReadLockForApplication(appId);
+ }
+
//StatusEventPublisher.sendApp(appId);
} else if (parent instanceof Group) {
//send activation to the parent
@@ -316,8 +329,8 @@ public class StatusChecker {
//send the terminated event
if (parent instanceof Application) {
//send application activated event
- log.info("sending app terminating: " + appId);
- StatusEventPublisher.sendApplicationTerminatingEvent(appId);
+ log.warn("Application can't be in terminating: " + appId);
+ //StatusEventPublisher.sendApplicationTerminatingEvent(appId);
//StatusEventPublisher.sendApp(appId);
} else if (parent instanceof Group) {
//send activation to the parent
[24/50] [abbrv] git commit: add delete application to metadata service
Posted by im...@apache.org.
add delete application to metadata service
Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/c9478208
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/c9478208
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/c9478208
Branch: refs/heads/docker-grouping-merge
Commit: c947820858960606a5d7b3c5e90c5086aadbdabb
Parents: 4bca87e
Author: Udara Liyanage <ud...@wso2.com>
Authored: Tue Oct 28 10:45:47 2014 +0530
Committer: Udara Liyanage <ud...@wso2.com>
Committed: Tue Oct 28 13:22:27 2014 +0530
----------------------------------------------------------------------
.../defaults/DefaultMetaDataServiceClient.java | 11 +++++++++
.../client/defaults/MetaDataServiceClient.java | 2 ++
.../metadata/client/rest/DefaultRestClient.java | 2 ++
.../registry/CarbonRegistry.java | 25 +++++++++++++++++++-
.../metadataservice/registry/DataStore.java | 1 +
.../metadataservice/registry/GRegRegistry.java | 4 ++++
.../metadataservice/services/MetaDataAdmin.java | 22 +++++++++++++++++
7 files changed, 66 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/stratos/blob/c9478208/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/defaults/DefaultMetaDataServiceClient.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/defaults/DefaultMetaDataServiceClient.java b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/defaults/DefaultMetaDataServiceClient.java
index fbebab9..ff7ac4a 100644
--- a/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/defaults/DefaultMetaDataServiceClient.java
+++ b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/defaults/DefaultMetaDataServiceClient.java
@@ -96,6 +96,17 @@ public class DefaultMetaDataServiceClient implements MetaDataServiceClient {
return gson.fromJson(responseContent, PropertyBean.class);
}
+ public void deleteApplicationProperties(String appId) throws MetaDataServiceClientException{
+ StringBuilder applicationPath = new StringBuilder(baseUrl).append("application/").append(appId);
+ HttpResponse response;
+ try {
+ response = restClient.doDelete(String.valueOf(applicationPath));
+ } catch (RestClientException e) {
+ String msg= "Error occured while deleting application";
+ throw new MetaDataServiceClientException(msg, e);
+ }
+ }
+
private String readResponseContent(HttpResponse response) throws IOException {
BufferedReader reader = new BufferedReader(new InputStreamReader(response.getEntity().getContent(), "UTF-8"));
http://git-wip-us.apache.org/repos/asf/stratos/blob/c9478208/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/defaults/MetaDataServiceClient.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/defaults/MetaDataServiceClient.java b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/defaults/MetaDataServiceClient.java
index 8fdb9a7..4703e77 100644
--- a/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/defaults/MetaDataServiceClient.java
+++ b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/defaults/MetaDataServiceClient.java
@@ -60,6 +60,8 @@ public interface MetaDataServiceClient {
*/
public org.apache.stratos.metadata.client.beans.PropertyBean getProperty(String appId, String clusterID, String propertyKey) throws MetaDataServiceClientException;
+ public void deleteApplicationProperties(String applicationId) throws MetaDataServiceClientException;
+
/**
* Shutdown the MetaDataServiceClient. Should be called once after using the client.
*/
http://git-wip-us.apache.org/repos/asf/stratos/blob/c9478208/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/rest/DefaultRestClient.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/rest/DefaultRestClient.java b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/rest/DefaultRestClient.java
index 160ca15..d3a3f7f 100644
--- a/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/rest/DefaultRestClient.java
+++ b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/rest/DefaultRestClient.java
@@ -122,6 +122,7 @@ public class DefaultRestClient implements RestClient {
public HttpResponse doGet(String resourcePath) throws RestClientException {
HttpGet get = new HttpGet(resourcePath);
+ setAuthHeader(get);
try {
return httpClient.execute(get);
@@ -138,6 +139,7 @@ public class DefaultRestClient implements RestClient {
public HttpResponse doDelete(String resourcePath) throws RestClientException {
HttpDelete delete = new HttpDelete(resourcePath);
+ setAuthHeader(delete);
try {
return httpClient.execute(delete);
http://git-wip-us.apache.org/repos/asf/stratos/blob/c9478208/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/registry/CarbonRegistry.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/registry/CarbonRegistry.java b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/registry/CarbonRegistry.java
index e9d590d..89250b3 100644
--- a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/registry/CarbonRegistry.java
+++ b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/registry/CarbonRegistry.java
@@ -18,6 +18,7 @@
*/
package org.apache.stratos.metadataservice.registry;
+import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.stratos.metadataservice.definition.NewProperty;
@@ -102,7 +103,29 @@ public class CarbonRegistry extends AbstractAdmin implements DataStore {
}
/**
- * Add properties to clustor
+ * Delete the resource identified by the applicationId, if exist.
+ * @param applicationId ID of the application.
+ * @return True if resource exist and able to delete, else false.
+ * @throws RegistryException
+ */
+ public boolean deleteApplication(String applicationId) throws RegistryException {
+ if(StringUtils.isEmpty(applicationId)){
+ throw new IllegalArgumentException("Application ID can not be null");
+ }
+ Registry tempRegistry = getGovernanceUserRegistry();
+ String resourcePath = mainResource + applicationId;
+
+ if(tempRegistry.resourceExists(resourcePath)){
+ tempRegistry.delete(resourcePath);
+ log.info(String.format("Application removed from registry %s", applicationId));
+ return true;
+ }
+
+ return false;
+ }
+
+ /**
+ * Add properties to cluster
* @param applicationName
* @param clusterId
* @param properties
http://git-wip-us.apache.org/repos/asf/stratos/blob/c9478208/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/registry/DataStore.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/registry/DataStore.java b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/registry/DataStore.java
index 0ad8459..33f3229 100644
--- a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/registry/DataStore.java
+++ b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/registry/DataStore.java
@@ -36,4 +36,5 @@ public interface DataStore {
public void addPropertyToCluster(String applicationId, String clusterId, NewProperty property) throws RegistryException;
+ public boolean deleteApplication(String applicationId) throws RegistryException;
}
http://git-wip-us.apache.org/repos/asf/stratos/blob/c9478208/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/registry/GRegRegistry.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/registry/GRegRegistry.java b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/registry/GRegRegistry.java
index ffe38f1..c2ba22e 100644
--- a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/registry/GRegRegistry.java
+++ b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/registry/GRegRegistry.java
@@ -102,4 +102,8 @@ public class GRegRegistry implements DataStore {
}
+ public boolean deleteApplication(String applicationId) {
+ return false;
+ }
+
}
http://git-wip-us.apache.org/repos/asf/stratos/blob/c9478208/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/services/MetaDataAdmin.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/services/MetaDataAdmin.java b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/services/MetaDataAdmin.java
index 55887a3..e88bc2a 100644
--- a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/services/MetaDataAdmin.java
+++ b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/services/MetaDataAdmin.java
@@ -162,5 +162,27 @@ public class MetaDataAdmin {
return Response.created(url).build();
}
+ @DELETE
+ @Path("application/{application_id}")
+ @Produces("application/json")
+ @Consumes("application/json")
+ @AuthorizationAction("/permission/protected/manage/monitor/tenants")
+ public Response deleteApplicationProperties(@PathParam("application_id") String applicationId)
+ throws RestAPIException {
+
+ try {
+ boolean deleted = registry.deleteApplication(applicationId);
+ if(!deleted){
+ log.warn(String.format("Either no metadata is associated with given appId %s Or resources could not be deleted", applicationId));
+ }
+ } catch (RegistryException e) {
+ String msg= "Resource attached with appId could not be deleted";
+ log.error(msg, e);
+ throw new RestAPIException(" ", e);
+ }
+
+ return Response.ok().build();
+ }
+
}
[49/50] [abbrv] Merge branch '4.0.0-grouping' into
docker-grouping-merge
Posted by im...@apache.org.
http://git-wip-us.apache.org/repos/asf/stratos/blob/17cc86eb/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java
----------------------------------------------------------------------
diff --cc components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java
index 227790a,6e003b1..3d7be2a
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java
@@@ -20,13 -20,12 +20,10 @@@ package org.apache.stratos.cloud.contro
import com.google.common.collect.ImmutableSet;
import com.google.common.net.InetAddresses;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.cloud.controller.application.parser.DefaultApplicationParser;
import org.apache.stratos.cloud.controller.concurrent.PartitionValidatorCallable;
- import org.apache.stratos.cloud.controller.concurrent.ScheduledThreadExecutor;
import org.apache.stratos.cloud.controller.concurrent.ThreadExecutor;
import org.apache.stratos.cloud.controller.deployment.partition.Partition;
import org.apache.stratos.cloud.controller.exception.*;
@@@ -44,15 -42,8 +40,16 @@@ import org.apache.stratos.cloud.control
import org.apache.stratos.cloud.controller.topology.TopologyManager;
import org.apache.stratos.cloud.controller.util.CloudControllerConstants;
import org.apache.stratos.cloud.controller.util.CloudControllerUtil;
+import org.apache.stratos.cloud.controller.util.PodActivationWatcher;
import org.apache.stratos.cloud.controller.validate.interfaces.PartitionValidator;
+import org.apache.stratos.common.constants.StratosConstants;
+import org.apache.stratos.kubernetes.client.KubernetesApiClient;
+import org.apache.stratos.kubernetes.client.exceptions.KubernetesClientException;
+import org.apache.stratos.kubernetes.client.model.Label;
+import org.apache.stratos.kubernetes.client.model.Pod;
+import org.apache.stratos.kubernetes.client.model.ReplicationController;
+import org.apache.stratos.kubernetes.client.model.Service;
+ import org.apache.stratos.messaging.domain.topology.Application;
import org.apache.stratos.messaging.domain.topology.Member;
import org.apache.stratos.messaging.domain.topology.MemberStatus;
import org.apache.stratos.messaging.util.Constants;
@@@ -77,61 -67,67 +74,62 @@@ import java.util.concurrent.Future
*/
public class CloudControllerServiceImpl implements CloudControllerService {
- private static final Log LOG = LogFactory
- private static final Log log = LogFactory
- .getLog(CloudControllerServiceImpl.class);
- private FasterLookUpDataHolder dataHolder = FasterLookUpDataHolder
- .getInstance();
-
- public CloudControllerServiceImpl() {
- // acquire serialized data from registry
- acquireData();
- }
-
- private void acquireData() {
-
- Object obj = RegistryManager.getInstance().retrieve();
- if (obj != null) {
- try {
- Object dataObj = Deserializer
- .deserializeFromByteArray((byte[]) obj);
- if (dataObj instanceof FasterLookUpDataHolder) {
- FasterLookUpDataHolder serializedObj = (FasterLookUpDataHolder) dataObj;
- FasterLookUpDataHolder currentData = FasterLookUpDataHolder
- .getInstance();
-
- // assign necessary data
- currentData.setClusterIdToContext(serializedObj.getClusterIdToContext());
- currentData.setMemberIdToContext(serializedObj.getMemberIdToContext());
- currentData.setClusterIdToMemberContext(serializedObj.getClusterIdToMemberContext());
- currentData.setCartridges(serializedObj.getCartridges());
++ private static final Log log = LogFactory
+ .getLog(CloudControllerServiceImpl.class);
+ private FasterLookUpDataHolder dataHolder = FasterLookUpDataHolder
+ .getInstance();
+
+ public CloudControllerServiceImpl() {
+ // acquire serialized data from registry
+ acquireData();
+ }
+
+ private void acquireData() {
+
+ Object obj = RegistryManager.getInstance().retrieve();
+ if (obj != null) {
+ try {
+ Object dataObj = Deserializer
+ .deserializeFromByteArray((byte[]) obj);
+ if (dataObj instanceof FasterLookUpDataHolder) {
+ FasterLookUpDataHolder serializedObj = (FasterLookUpDataHolder) dataObj;
+ FasterLookUpDataHolder currentData = FasterLookUpDataHolder
+ .getInstance();
+
+ // assign necessary data
+ currentData.setClusterIdToContext(serializedObj.getClusterIdToContext());
+ currentData.setMemberIdToContext(serializedObj.getMemberIdToContext());
+ currentData.setClusterIdToMemberContext(serializedObj.getClusterIdToMemberContext());
+ currentData.setCartridges(serializedObj.getCartridges());
+ currentData.setKubClusterIdToKubClusterContext(serializedObj.getKubClusterIdToKubClusterContext());
+ currentData.setServiceGroups(serializedObj.getServiceGroups());
- if(LOG.isDebugEnabled()) {
+ if(log.isDebugEnabled()) {
+
- LOG.debug("Cloud Controller Data is retrieved from registry.");
++ log.debug("Cloud Controller Data is retrieved from registry.");
+ }
+ } else {
- if(LOG.isDebugEnabled()) {
++ if(log.isDebugEnabled()) {
+
- LOG.debug("Cloud Controller Data cannot be found in registry.");
++ log.debug("Cloud Controller Data cannot be found in registry.");
+ }
+ }
+ } catch (Exception e) {
- log.debug("Cloud Controller Data is retrieved from registry.");
- }
- } else {
- if(log.isDebugEnabled()) {
-
- log.debug("Cloud Controller Data cannot be found in registry.");
- }
- }
- } catch (Exception e) {
+ String msg = "Unable to acquire data from Registry. Hence, any historical data will not get reflected.";
- LOG.warn(msg, e);
++ log.warn(msg, e);
+ }
- String msg = "Unable to acquire data from Registry. Hence, any historical data will not get reflected.";
- log.warn(msg, e);
- }
+ }
+ }
- }
+ public void deployCartridgeDefinition(CartridgeConfig cartridgeConfig) throws InvalidCartridgeDefinitionException,
+ InvalidIaasProviderException {
- }
-
-
- public void deployCartridgeDefinition(CartridgeConfig cartridgeConfig) throws InvalidCartridgeDefinitionException,
- InvalidIaasProviderException {
- if (cartridgeConfig == null) {
- String msg = "Invalid Cartridge Definition: Definition is null.";
- log.error(msg);
- throw new IllegalArgumentException(msg);
-
- }
+ handleNullObject(cartridgeConfig, "Invalid Cartridge Definition: Definition is null.");
- if(LOG.isDebugEnabled()){
- LOG.debug("Cartridge definition: " + cartridgeConfig.toString());
+ if(log.isDebugEnabled()){
+ log.debug("Cartridge definition: " + cartridgeConfig.toString());
}
Cartridge cartridge = null;
@@@ -140,10 -135,10 +138,10 @@@
cartridge = CloudControllerUtil.toCartridge(cartridgeConfig);
} catch (Exception e) {
String msg =
- "Invalid Cartridge Definition: Cartridge Type: " +
- cartridgeConfig.getType()+
- ". Cause: Cannot instantiate a Cartridge Instance with the given Config. "+e.getMessage();
+ "Invalid Cartridge Definition: Cartridge Type: " +
+ cartridgeConfig.getType()+
+ ". Cause: Cannot instantiate a Cartridge Instance with the given Config. "+e.getMessage();
- LOG.error(msg, e);
+ log.error(msg, e);
throw new InvalidCartridgeDefinitionException(msg, e);
}
@@@ -191,79 -185,212 +189,207 @@@
}
private void populateNewCartridge(Cartridge cartridge,
- Cartridge cartridgeToBeRemoved) {
-
- List<IaasProvider> newIaasProviders = cartridge.getIaases();
- Map<String, IaasProvider> oldPartitionToIaasMap = cartridgeToBeRemoved.getPartitionToIaasProvider();
-
- for (String partitionId : oldPartitionToIaasMap.keySet()) {
- IaasProvider oldIaasProvider = oldPartitionToIaasMap.get(partitionId);
- if (newIaasProviders.contains(oldIaasProvider)) {
- if (log.isDebugEnabled()) {
+ Cartridge cartridgeToBeRemoved) {
+
+ List<IaasProvider> newIaasProviders = cartridge.getIaases();
+ Map<String, IaasProvider> oldPartitionToIaasMap = cartridgeToBeRemoved.getPartitionToIaasProvider();
+
+ for (Entry<String, IaasProvider> entry : oldPartitionToIaasMap.entrySet()) {
+ if (entry == null) {
+ continue;
+ }
+ String partitionId = entry.getKey();
+ IaasProvider oldIaasProvider = entry.getValue();
+ if (newIaasProviders.contains(oldIaasProvider)) {
- if (LOG.isDebugEnabled()) {
- LOG.debug("Copying a partition from the Cartridge that is undeployed, to the new Cartridge. "
++ if (log.isDebugEnabled()) {
+ log.debug("Copying a partition from the Cartridge that is undeployed, to the new Cartridge. "
- + "[partition id] : "+partitionId+" [cartridge type] "+cartridge.getType() );
- }
- cartridge.addIaasProvider(partitionId, newIaasProviders.get(newIaasProviders.indexOf(oldIaasProvider)));
- }
- }
-
- }
+ + "[partition id] : "+partitionId+" [cartridge type] "+cartridge.getType() );
+ }
+ cartridge.addIaasProvider(partitionId, newIaasProviders.get(newIaasProviders.indexOf(oldIaasProvider)));
+ }
+ }
+
+ }
- public void undeployCartridgeDefinition(String cartridgeType) throws InvalidCartridgeTypeException {
+ public void undeployCartridgeDefinition(String cartridgeType) throws InvalidCartridgeTypeException {
Cartridge cartridge = null;
if((cartridge = dataHolder.getCartridge(cartridgeType)) != null) {
if (dataHolder.getCartridges().remove(cartridge)) {
- // invalidate partition validation cache
- dataHolder.removeFromCartridgeTypeToPartitionIds(cartridgeType);
-
- if (log.isDebugEnabled()) {
- log.debug("Partition cache invalidated for cartridge "+cartridgeType);
- }
-
+ // invalidate partition validation cache
+ dataHolder.removeFromCartridgeTypeToPartitionIds(cartridgeType);
+
- if (LOG.isDebugEnabled()) {
- LOG.debug("Partition cache invalidated for cartridge "+cartridgeType);
++ if (log.isDebugEnabled()) {
++ log.debug("Partition cache invalidated for cartridge "+cartridgeType);
+ }
+
persist();
-
+
// sends the service removed event
List<Cartridge> cartridgeList = new ArrayList<Cartridge>();
cartridgeList.add(cartridge);
TopologyBuilder.handleServiceRemoved(cartridgeList);
-
+
- if(LOG.isInfoEnabled()) {
- LOG.info("Successfully undeployed the Cartridge definition: " + cartridgeType);
+ if(log.isInfoEnabled()) {
+ log.info("Successfully undeployed the Cartridge definition: " + cartridgeType);
}
return;
}
}
String msg = "Cartridge [type] "+cartridgeType+" is not a deployed Cartridge type.";
- LOG.error(msg);
+ log.error(msg);
throw new InvalidCartridgeTypeException(msg);
}
-
++
+ public void deployServiceGroup(ServiceGroup servicegroup) throws InvalidServiceGroupException {
-
- if (servicegroup == null) {
++
++ if (servicegroup == null) {
+ String msg = "Invalid ServiceGroup Definition: Definition is null.";
+ log.error(msg);
+ throw new IllegalArgumentException(msg);
+
+ }
-
- if(log.isDebugEnabled()) {
++
++ if(log.isDebugEnabled()) {
+ log.debug("CloudControllerServiceImpl:deployServiceGroup:" + servicegroup.getName());
+ }
-
- String [] subGroups = servicegroup.getCartridges();
-
+
- if(log.isDebugEnabled()) {
++ String [] subGroups = servicegroup.getCartridges();
++
++
++ if(log.isDebugEnabled()) {
+ log.debug("CloudControllerServiceImpl:deployServiceGroup:subGroups" + subGroups);
+ if (subGroups != null) {
- log.debug("CloudControllerServiceImpl:deployServiceGroup:subGroups:size" + subGroups.length);
++ log.debug("CloudControllerServiceImpl:deployServiceGroup:subGroups:size" + subGroups.length);
+ } else {
- log.debug("CloudControllerServiceImpl:deployServiceGroup:subGroups: is null");
++ log.debug("CloudControllerServiceImpl:deployServiceGroup:subGroups: is null");
+ }
+ }
-
-
- Dependencies dependencies = servicegroup.getDependencies();
-
- if(log.isDebugEnabled()) {
++
++
++ Dependencies dependencies = servicegroup.getDependencies();
++
++ if(log.isDebugEnabled()) {
+ log.debug("CloudControllerServiceImpl:deployServiceGroup:dependencies" + dependencies);
+ }
-
- if (dependencies != null) {
- String [] startupOrders = dependencies.getStartupOrders();
-
- if(log.isDebugEnabled()) {
- log.debug("CloudControllerServiceImpl:deployServiceGroup:startupOrders" + startupOrders);
-
- if (startupOrders != null) {
- log.debug("CloudControllerServiceImpl:deployServiceGroup:startupOrder:size" + startupOrders.length);
- } else {
- log.debug("CloudControllerServiceImpl:deployServiceGroup:startupOrder: is null");
- }
- }
- }
-
- dataHolder.addServiceGroup(servicegroup);
-
- this.persist();
-
++
++ if (dependencies != null) {
++ String [] startupOrders = dependencies.getStartupOrders();
++
++ if(log.isDebugEnabled()) {
++ log.debug("CloudControllerServiceImpl:deployServiceGroup:startupOrders" + startupOrders);
++
++ if (startupOrders != null) {
++ log.debug("CloudControllerServiceImpl:deployServiceGroup:startupOrder:size" + startupOrders.length);
++ } else {
++ log.debug("CloudControllerServiceImpl:deployServiceGroup:startupOrder: is null");
++ }
++ }
++ }
++
++ dataHolder.addServiceGroup(servicegroup);
++
++ this.persist();
++
+ }
-
++
+ public void undeployServiceGroup(String name) throws InvalidServiceGroupException {
- if(log.isDebugEnabled()) {
++ if(log.isDebugEnabled()) {
+ log.debug("CloudControllerServiceImpl:undeployServiceGroup: " + name);
+ }
-
++
+ ServiceGroup serviceGroup = null;
-
++
+ serviceGroup = dataHolder.getServiceGroup(name);
-
++
+ if (serviceGroup != null) {
+ if (dataHolder.getServiceGroups().remove(serviceGroup)) {
+ persist();
+ if(log.isInfoEnabled()) {
+ log.info("Successfully undeployed the Service Group definition: " + serviceGroup);
+ }
+ return;
+ }
- }
-
++ }
++
+ String msg = "ServiceGroup " + name + " is not a deployed Service Group definition";
+ log.error(msg);
+ throw new InvalidServiceGroupException(msg);
-
++
+ }
-
++
+ @Override
+ public ServiceGroup getServiceGroup (String name) throws InvalidServiceGroupException {
-
- if(log.isDebugEnabled()) {
++
++ if(log.isDebugEnabled()) {
+ log.debug("getServiceGroupDefinition:" + name);
+ }
-
- ServiceGroup serviceGroup = this.dataHolder.getServiceGroup(name);
-
- if (serviceGroup == null) {
- if(log.isDebugEnabled()) {
++
++ ServiceGroup serviceGroup = this.dataHolder.getServiceGroup(name);
++
++ if (serviceGroup == null) {
++ if(log.isDebugEnabled()) {
+ log.debug("getServiceGroupDefinition: no entry found for service group " + name);
+ }
- String msg = "ServiceGroup " + name + " is not a deployed Service Group definition";
- throw new InvalidServiceGroupException(msg);
- }
-
- return serviceGroup;
++ String msg = "ServiceGroup " + name + " is not a deployed Service Group definition";
++ throw new InvalidServiceGroupException(msg);
++ }
++
++ return serviceGroup;
+ }
-
++
+ public String [] getServiceGroupSubGroups (String name) throws InvalidServiceGroupException {
- ServiceGroup serviceGroup = this.getServiceGroup(name);
- if (serviceGroup == null) {
- throw new InvalidServiceGroupException("Invalid ServiceGroup " + serviceGroup);
- }
-
- return serviceGroup.getSubGroups();
++ ServiceGroup serviceGroup = this.getServiceGroup(name);
++ if (serviceGroup == null) {
++ throw new InvalidServiceGroupException("Invalid ServiceGroup " + serviceGroup);
++ }
++
++ return serviceGroup.getSubGroups();
+ }
-
++
+ /**
- *
++ *
+ */
+ public String [] getServiceGroupCartridges (String name) throws InvalidServiceGroupException {
- ServiceGroup serviceGroup = this.getServiceGroup(name);
- if (serviceGroup == null) {
- throw new InvalidServiceGroupException("Invalid ServiceGroup " + serviceGroup);
- }
- String [] cs = serviceGroup.getCartridges();
- return cs;
-
++ ServiceGroup serviceGroup = this.getServiceGroup(name);
++ if (serviceGroup == null) {
++ throw new InvalidServiceGroupException("Invalid ServiceGroup " + serviceGroup);
++ }
++ String [] cs = serviceGroup.getCartridges();
++ return cs;
++
+ }
-
++
+ public Dependencies getServiceGroupDependencies (String name) throws InvalidServiceGroupException {
- ServiceGroup serviceGroup = this.getServiceGroup(name);
- if (serviceGroup == null) {
- throw new InvalidServiceGroupException("Invalid ServiceGroup " + serviceGroup);
- }
- return serviceGroup.getDependencies();
++ ServiceGroup serviceGroup = this.getServiceGroup(name);
++ if (serviceGroup == null) {
++ throw new InvalidServiceGroupException("Invalid ServiceGroup " + serviceGroup);
++ }
++ return serviceGroup.getDependencies();
+ }
-
+
@Override
public MemberContext startInstance(MemberContext memberContext) throws
- UnregisteredCartridgeException, InvalidIaasProviderException {
+ UnregisteredCartridgeException, InvalidIaasProviderException {
- if(LOG.isDebugEnabled()) {
- LOG.debug("CloudControllerServiceImpl:startInstance");
- if(log.isDebugEnabled()) {
++ if(log.isDebugEnabled()) {
+ log.debug("CloudControllerServiceImpl:startInstance");
- }
+ }
- if (memberContext == null) {
- String msg = "Instance start-up failed. Member is null.";
- log.error(msg);
- throw new IllegalArgumentException(msg);
- }
+ handleNullObject(memberContext, "Instance start-up failed. Member is null.");
String clusterId = memberContext.getClusterId();
Partition partition = memberContext.getPartition();
- if(log.isDebugEnabled()) {
- log.debug("Received an instance spawn request : " + memberContext.toString());
+ if(LOG.isDebugEnabled()) {
+ LOG.debug("Received an instance spawn request : " + memberContext);
}
+ ComputeService computeService = null;
Template template = null;
- if (partition == null) {
- String msg =
- "Instance start-up failed. Specified Partition is null. " +
- memberContext.toString();
- log.error(msg);
- throw new IllegalArgumentException(msg);
- }
+ handleNullObject(partition, "Instance start-up failed. Specified Partition is null. " +
+ memberContext);
String partitionId = partition.getId();
ClusterContext ctxt = dataHolder.getClusterContext(clusterId);
@@@ -287,21 -418,21 +413,21 @@@
IaasProvider iaasProvider = cartridge.getIaasProviderOfPartition(partitionId);
if (iaasProvider == null) {
- if (LOG.isDebugEnabled()) {
- LOG.debug("IaasToPartitionMap "+cartridge.hashCode()
- if (log.isDebugEnabled()) {
++ if (log.isDebugEnabled()) {
+ log.debug("IaasToPartitionMap "+cartridge.hashCode()
- + " for cartridge "+cartridgeType+ " and for partition: "+partitionId);
- }
- String msg = "Instance start-up failed. "
- + "There's no IaaS provided for the partition: "
- + partitionId
- + " and for the Cartridge type: "
- + cartridgeType
- + ". Only following "
- + "partitions can be found in this Cartridge: "
- + cartridge.getPartitionToIaasProvider().keySet()
- .toString() + ". " + memberContext.toString()
- + ". ";
+ + " for cartridge "+cartridgeType+ " and for partition: "+partitionId);
+ }
+ String msg = "Instance start-up failed. "
+ + "There's no IaaS provided for the partition: "
+ + partitionId
+ + " and for the Cartridge type: "
+ + cartridgeType
+ + ". Only following "
+ + "partitions can be found in this Cartridge: "
+ + cartridge.getPartitionToIaasProvider().keySet()
+ .toString() + ". " + memberContext.toString()
+ + ". ";
- LOG.fatal(msg);
+ log.fatal(msg);
throw new InvalidIaasProviderException(msg);
}
String type = iaasProvider.getType();
@@@ -393,16 -589,16 +519,16 @@@
}
- private void createVolumeAndSetInClusterContext(Volume volume,
- IaasProvider iaasProvider) {
- // iaas cannot be null at this state #startInstance method
- Iaas iaas = iaasProvider.getIaas();
- int sizeGB = volume.getSize();
- String snapshotId = volume.getSnapshotId();
+ private void createVolumeAndSetInClusterContext(Volume volume,
+ IaasProvider iaasProvider) {
+ // iaas cannot be null at this state #startInstance method
+ Iaas iaas = iaasProvider.getIaas();
+ int sizeGB = volume.getSize();
+ String snapshotId = volume.getSnapshotId();
if(StringUtils.isNotEmpty(volume.getVolumeId())){
// volumeID is specified, so not creating additional volumes
- if(LOG.isDebugEnabled()){
- LOG.debug("Volume creation is skipping since a volume ID is specified. [Volume ID]" + volume.getVolumeId());
+ if(log.isDebugEnabled()){
+ log.debug("Volume creation is skipping since a volume ID is specified. [Volume ID]" + volume.getVolumeId());
}
volume.setId(volume.getVolumeId());
}else{
@@@ -415,52 -611,53 +541,52 @@@
private StringBuilder getPersistencePayload(ClusterContext ctx, Iaas iaas) {
- StringBuilder persistencePayload = new StringBuilder();
- if(isPersistenceMappingAvailable(ctx)){
- for(Volume volume : ctx.getVolumes()){
- if(log.isDebugEnabled()){
+ StringBuilder persistencePayload = new StringBuilder();
+ if(isPersistenceMappingAvailable(ctx)){
+ for(Volume volume : ctx.getVolumes()){
- if(LOG.isDebugEnabled()){
- LOG.debug("Adding persistence mapping " + volume.toString());
++ if(log.isDebugEnabled()){
+ log.debug("Adding persistence mapping " + volume.toString());
- }
+ }
if(persistencePayload.length() != 0) {
- persistencePayload.append("|");
+ persistencePayload.append("|");
}
-
- persistencePayload.append(iaas.getIaasDevice(volume.getDevice()));
- persistencePayload.append("|");
+
+ persistencePayload.append(iaas.getIaasDevice(volume.getDevice()));
+ persistencePayload.append("|");
persistencePayload.append(volume.getId());
persistencePayload.append("|");
persistencePayload.append(volume.getMappingPath());
- }
- }
+ }
+ }
- if(LOG.isDebugEnabled()){
- LOG.debug("Persistence payload is" + persistencePayload.toString());
+ if(log.isDebugEnabled()){
+ log.debug("Persistence payload is" + persistencePayload.toString());
}
- System.out.println("****** " + persistencePayload);
- return persistencePayload;
- }
+ return persistencePayload;
+ }
- private boolean isPersistenceMappingAvailable(ClusterContext ctx) {
- return ctx.getVolumes() != null && ctx.isVolumeRequired();
- }
+ private boolean isPersistenceMappingAvailable(ClusterContext ctx) {
+ return ctx.getVolumes() != null && ctx.isVolumeRequired();
+ }
- private void addToPayload(StringBuilder payload, String name, String value) {
- payload.append(",");
+ private void addToPayload(StringBuilder payload, String name, String value) {
+ payload.append(",");
payload.append(name+"=" + value);
}
/**
- * Persist data in registry.
- */
- private void persist() {
- try {
- RegistryManager.getInstance().persist(
- dataHolder);
- } catch (RegistryException e) {
-
- String msg = "Failed to persist the Cloud Controller data in registry. Further, transaction roll back also failed.";
- log.fatal(msg);
- throw new CloudControllerException(msg, e);
- }
- }
+ * Persist data in registry.
+ */
+ private void persist() {
+ try {
+ RegistryManager.getInstance().persist(
+ dataHolder);
+ } catch (RegistryException e) {
+
+ String msg = "Failed to persist the Cloud Controller data in registry. Further, transaction roll back also failed.";
- LOG.fatal(msg);
++ log.fatal(msg);
+ throw new CloudControllerException(msg, e);
+ }
+ }
private String generateMemberId(String clusterId) {
UUID memberId = UUID.randomUUID();
@@@ -468,19 -665,23 +594,19 @@@
}
@Override
- public void terminateInstance(String memberId) throws InvalidMemberException, InvalidCartridgeTypeException
+ public void terminateInstance(String memberId) throws InvalidMemberException, InvalidCartridgeTypeException
{
- if(memberId == null) {
- String msg = "Termination failed. Null member id.";
- log.error(msg);
- throw new IllegalArgumentException(msg);
- }
-
+ handleNullObject(memberId, "Termination failed. Null member id.");
+
MemberContext ctxt = dataHolder.getMemberContextOfMemberId(memberId);
-
+
if(ctxt == null) {
String msg = "Termination failed. Invalid Member Id: "+memberId;
- LOG.error(msg);
+ log.error(msg);
throw new InvalidMemberException(msg);
}
-
+
ThreadExecutor exec = ThreadExecutor.getInstance();
exec.execute(new InstanceTerminator(ctxt));
@@@ -507,16 -708,16 +633,16 @@@
// these will never be null, since we do not add null values for these.
Cartridge cartridge = dataHolder.getCartridge(cartridgeType);
- LOG.info("Starting to terminate an instance with member id : " + memberId +
+ log.info("Starting to terminate an instance with member id : " + memberId +
- " in partition id: " + partitionId + " of cluster id: " + clusterId +
- " and of cartridge type: " + cartridgeType);
+ " in partition id: " + partitionId + " of cluster id: " + clusterId +
+ " and of cartridge type: " + cartridgeType);
if (cartridge == null) {
String msg =
- "Termination of Member Id: " + memberId + " failed. " +
- "Cannot find a matching Cartridge for type: " +
- cartridgeType;
+ "Termination of Member Id: " + memberId + " failed. " +
+ "Cannot find a matching Cartridge for type: " +
+ cartridgeType;
- LOG.error(msg);
+ log.error(msg);
throw new InvalidCartridgeTypeException(msg);
}
@@@ -524,12 -725,9 +650,12 @@@
if (nodeId == null) {
String msg =
- "Termination failed. Cannot find a node id for Member Id: " +
- memberId;
+ "Termination failed. Cannot find a node id for Member Id: " +
+ memberId;
+
+ // log information
+ logTermination(ctxt);
- LOG.error(msg);
+ log.error(msg);
throw new InvalidMemberException(msg);
}
@@@ -543,8 -741,8 +669,8 @@@
} catch (Exception e) {
String msg =
- "Instance termination failed. "+ctxt.toString();
+ "Instance termination failed. "+ctxt.toString();
- LOG.error(msg, e);
+ log.error(msg, e);
throw new CloudControllerException(msg, e);
}
@@@ -556,9 -754,10 +682,10 @@@
private MemberContext memberContext;
private IaasProvider iaasProvider;
private String cartridgeType;
+ NodeMetadata node;
- public JcloudsInstanceCreator(MemberContext memberContext, IaasProvider iaasProvider,
- String cartridgeType) {
- public IpAllocator(MemberContext memberContext, IaasProvider iaasProvider,
- String cartridgeType, NodeMetadata node) {
++ public IpAllocator(MemberContext memberContext, IaasProvider iaasProvider,
++ String cartridgeType, NodeMetadata node) {
this.memberContext = memberContext;
this.iaasProvider = iaasProvider;
this.cartridgeType = cartridgeType;
@@@ -769,9 -889,9 +897,9 @@@
} catch (Exception e) {
String msg = "Error occurred while allocating an ip address. " + memberContext.toString();
- LOG.error(msg, e);
+ log.error(msg, e);
throw new CloudControllerException(msg, e);
- }
+ }
}
@@@ -813,71 -937,65 +941,71 @@@
* @param nodeId
* @return will return the IaaSProvider
*/
- private IaasProvider terminate(IaasProvider iaasProvider,
- String nodeId, MemberContext ctxt) {
- Iaas iaas = iaasProvider.getIaas();
- if (iaas == null) {
-
- try {
- iaas = CloudControllerUtil.getIaas(iaasProvider);
- } catch (InvalidIaasProviderException e) {
- String msg =
- "Instance termination failed. " +ctxt.toString() +
- ". Cause: Unable to build Iaas of this " + iaasProvider.toString();
- log.error(msg, e);
- throw new CloudControllerException(msg, e);
- }
-
- }
-
- //detach volumes if any
- detachVolume(iaasProvider, ctxt);
-
- // destroy the node
- iaasProvider.getComputeService().destroyNode(nodeId);
-
- // release allocated IP address
- if (ctxt.getAllocatedIpAddress() != null) {
+ private IaasProvider terminate(IaasProvider iaasProvider,
+ String nodeId, MemberContext ctxt) {
+ Iaas iaas = iaasProvider.getIaas();
+ if (iaas == null) {
+
+ try {
+ iaas = CloudControllerUtil.getIaas(iaasProvider);
+ } catch (InvalidIaasProviderException e) {
+ String msg =
+ "Instance termination failed. " +ctxt.toString() +
+ ". Cause: Unable to build Iaas of this " + iaasProvider.toString();
- LOG.error(msg, e);
++ log.error(msg, e);
+ throw new CloudControllerException(msg, e);
+ }
+
+ }
+
+ //detach volumes if any
+ detachVolume(iaasProvider, ctxt);
+
+ // destroy the node
+ iaasProvider.getComputeService().destroyNode(nodeId);
+
+ // release allocated IP address
+ if (ctxt.getAllocatedIpAddress() != null) {
iaas.releaseAddress(ctxt.getAllocatedIpAddress());
- }
-
- log.info("Member is terminated: "+ctxt.toString());
- return iaasProvider;
- }
-
- private void detachVolume(IaasProvider iaasProvider, MemberContext ctxt) {
- String clusterId = ctxt.getClusterId();
- ClusterContext clusterCtxt = dataHolder.getClusterContext(clusterId);
- if (clusterCtxt.getVolumes() != null) {
- for (Volume volume : clusterCtxt.getVolumes()) {
- try {
- String volumeId = volume.getId();
- if (volumeId == null) {
- return;
- }
- Iaas iaas = iaasProvider.getIaas();
- iaas.detachVolume(ctxt.getInstanceId(), volumeId);
- } catch (ResourceNotFoundException ignore) {
- if(log.isDebugEnabled()) {
- log.debug(ignore);
- }
- }
- }
- }
- }
-
- private void logTermination(MemberContext memberContext) {
-
+ }
+
- LOG.info("Member is terminated: "+ctxt.toString());
++ log.info("Member is terminated: "+ctxt.toString());
+ return iaasProvider;
+ }
+
+ private void detachVolume(IaasProvider iaasProvider, MemberContext ctxt) {
+ String clusterId = ctxt.getClusterId();
+ ClusterContext clusterCtxt = dataHolder.getClusterContext(clusterId);
+ if (clusterCtxt.getVolumes() != null) {
+ for (Volume volume : clusterCtxt.getVolumes()) {
+ try {
+ String volumeId = volume.getId();
+ if (volumeId == null) {
+ return;
+ }
+ Iaas iaas = iaasProvider.getIaas();
+ iaas.detachVolume(ctxt.getInstanceId(), volumeId);
+ } catch (ResourceNotFoundException ignore) {
- if(LOG.isDebugEnabled()) {
- LOG.debug(ignore);
++ if(log.isDebugEnabled()) {
++ log.debug(ignore);
+ }
+ }
+ }
+ }
+ }
+
+ private void logTermination(MemberContext memberContext) {
+
+ if (memberContext == null) {
+ return;
+ }
+
+ String partitionId = memberContext.getPartition() == null ? null : memberContext.getPartition().getId();
+
//updating the topology
- TopologyBuilder.handleMemberTerminated(memberContext.getCartridgeType(),
- memberContext.getClusterId(), memberContext.getNetworkPartitionId(),
- memberContext.getPartition().getId(), memberContext.getMemberId());
+ TopologyBuilder.handleMemberTerminated(memberContext.getCartridgeType(),
+ memberContext.getClusterId(), memberContext.getNetworkPartitionId(),
+ partitionId, memberContext.getMemberId());
//publishing data
CartridgeInstanceDataPublisher.publish(memberContext.getMemberId(),
@@@ -1290,474 -1393,29 +1418,498 @@@
return dataHolder.getClusterContext(clusterId);
}
+ @Override
+ public MemberContext[] startContainers(ContainerClusterContext containerClusterContext)
+ throws UnregisteredCartridgeException {
+
+ if(LOG.isDebugEnabled()) {
+ LOG.debug("CloudControllerServiceImpl:startContainers");
+ }
+
+ handleNullObject(containerClusterContext, "Container start-up failed. ContainerClusterContext is null.");
+
+ String clusterId = containerClusterContext.getClusterId();
+ handleNullObject(clusterId, "Container start-up failed. Cluster id is null.");
+
+ if(LOG.isDebugEnabled()) {
+ LOG.debug("Received a container spawn request : " + containerClusterContext.toString());
+ }
+
+ ClusterContext ctxt = dataHolder.getClusterContext(clusterId);
+ handleNullObject(ctxt, "Container start-up failed. Invalid cluster id. " + containerClusterContext.toString());
+
+ String cartridgeType = ctxt.getCartridgeType();
+
+ Cartridge cartridge = dataHolder.getCartridge(cartridgeType);
+
+ if (cartridge == null) {
+ String msg =
+ "Instance start-up failed. No matching Cartridge found [type] "+cartridgeType +". "+
+ containerClusterContext.toString();
+ LOG.error(msg);
+ throw new UnregisteredCartridgeException(msg);
+ }
+
+ try {
+ String minReplicas = validateProperty(StratosConstants.KUBERNETES_MIN_REPLICAS, ctxt);
+ String kubernetesClusterId = validateProperty(StratosConstants.KUBERNETES_CLUSTER_ID, ctxt);
+ String kubernetesMasterIp = validateProperty(StratosConstants.KUBERNETES_MASTER_IP, containerClusterContext);
+ String kubernetesPortRange = validateProperty(StratosConstants.KUBERNETES_PORT_RANGE, containerClusterContext);
+
+ KubernetesClusterContext kubClusterContext = getKubernetesClusterContext(kubernetesClusterId, kubernetesMasterIp, kubernetesPortRange);
+
+ KubernetesApiClient kubApi = kubClusterContext.getKubApi();
+
+ // first let's create a replication controller.
+ ContainerClusterContextToReplicationController controllerFunction = new ContainerClusterContextToReplicationController();
+ ReplicationController controller = controllerFunction.apply(containerClusterContext);
+
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Cloud Controller is delegating request to start a replication controller "+controller+
+ " for "+ containerClusterContext + " to Kubernetes layer.");
+ }
+
+ kubApi.createReplicationController(controller);
+
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Cloud Controller successfully started the controller "
+ + controller + " via Kubernetes layer.");
+ }
+
+ // secondly let's create a kubernetes service proxy to load balance these containers
+ ContainerClusterContextToKubernetesService serviceFunction = new ContainerClusterContextToKubernetesService();
+ Service service = serviceFunction.apply(containerClusterContext);
+
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Cloud Controller is delegating request to start a service "+service+
+ " for "+ containerClusterContext + " to Kubernetes layer.");
+ }
+
+ kubApi.createService(service);
+
+ // set host port and update
+ ctxt.addProperty(StratosConstants.ALLOCATED_SERVICE_HOST_PORT, service.getPort());
+ dataHolder.addClusterContext(ctxt);
+
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Cloud Controller successfully started the service "
+ + controller + " via Kubernetes layer.");
+ }
+
+ // create a label query
+ Label l = new Label();
+ l.setName(clusterId);
+ // execute the label query
+ Pod[] newlyCreatedPods = new Pod[0];
+ int expectedCount = Integer.parseInt(minReplicas);
+
+ for (int i = 0; i < expectedCount ; i++) {
+ newlyCreatedPods = kubApi.getSelectedPods(new Label[]{l});
+
+ if (LOG.isDebugEnabled()) {
+
+ LOG.debug("Pods Count: "+newlyCreatedPods.length+" for cluster: "+clusterId);
+ }
+ if(newlyCreatedPods.length == expectedCount) {
+ break;
+ }
+ Thread.sleep(10000);
+ }
+
+ if (newlyCreatedPods.length == 0) {
+ if (LOG.isDebugEnabled()) {
+ LOG.debug(String.format("Pods are not created for cluster : %s, hence deleting the service", clusterId));
+ }
+ terminateAllContainers(clusterId);
+ return new MemberContext[0];
+ }
+
+ if (LOG.isDebugEnabled()) {
+
+ LOG.debug(String.format("Pods created : %s for cluster : %s",newlyCreatedPods.length, clusterId));
+ }
+
+ List<MemberContext> memberContexts = new ArrayList<MemberContext>();
+
+ PodToMemberContext podToMemberContextFunc = new PodToMemberContext();
+ // generate Member Contexts
+ for (Pod pod : newlyCreatedPods) {
+ MemberContext context = podToMemberContextFunc.apply(pod);
+ context.setCartridgeType(cartridgeType);
+ context.setClusterId(clusterId);
+
+ context.setProperties(CloudControllerUtil.addProperty(context
+ .getProperties(), StratosConstants.ALLOCATED_SERVICE_HOST_PORT,
+ String.valueOf(service.getPort())));
+
+ dataHolder.addMemberContext(context);
+
+ // wait till Pod status turns to running and send member spawned.
+ ScheduledThreadExecutor exec = ScheduledThreadExecutor.getInstance();
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Cloud Controller is starting the instance start up thread.");
+ }
+ dataHolder.addScheduledFutureJob(context.getMemberId(), exec.schedule(new PodActivationWatcher(pod.getId(), context, kubApi), 5000));
+
+ memberContexts.add(context);
+ }
+
+ // persist in registry
+ persist();
+
+ LOG.info("Kubernetes entities are successfully starting up: " + memberContexts);
+
+ return memberContexts.toArray(new MemberContext[0]);
+
+ } catch (Exception e) {
+ String msg = "Failed to start an instance. " + containerClusterContext.toString()+" Cause: "+e.getMessage();
+ LOG.error(msg, e);
+ throw new IllegalStateException(msg, e);
+ }
+ }
+
+ private String validateProperty(String property, ClusterContext ctxt) {
+
+ String propVal = CloudControllerUtil.getProperty(ctxt.getProperties(), property);
+ handleNullObject(propVal, "Property validation failed. Cannot find '"+property+"' in " + ctxt);
+ return propVal;
+ }
+
+ private String validateProperty(String property, ContainerClusterContext ctxt) {
+
+ String propVal = CloudControllerUtil.getProperty(ctxt.getProperties(), property);
+ handleNullObject(propVal, "Property validation failed. '"+property+"' in " + ctxt);
+ return propVal;
+
+ }
+
+ private KubernetesClusterContext getKubernetesClusterContext(
+ String kubernetesClusterId, String kubernetesMasterIp,
+ String kubernetesPortRange) {
+
+ KubernetesClusterContext origCtxt = dataHolder.getKubernetesClusterContext(kubernetesClusterId);
+ KubernetesClusterContext newCtxt = new KubernetesClusterContext(kubernetesClusterId, kubernetesPortRange, kubernetesMasterIp);
+
+ if (origCtxt == null) {
+ dataHolder.addKubernetesClusterContext(newCtxt);
+ return newCtxt;
+ }
+
+ if (!origCtxt.equals(newCtxt)) {
+ // if for some reason master IP etc. have changed
+ newCtxt.setAvailableHostPorts(origCtxt.getAvailableHostPorts());
+ dataHolder.addKubernetesClusterContext(newCtxt);
+ return newCtxt;
+ } else {
+ return origCtxt;
+ }
+ }
+
+ @Override
+ public MemberContext[] terminateAllContainers(String clusterId)
+ throws InvalidClusterException {
+
+ ClusterContext ctxt = dataHolder.getClusterContext(clusterId);
+ handleNullObject(ctxt, "Kubernetes units temrination failed. Invalid cluster id. "+clusterId);
+
+ String kubernetesClusterId = CloudControllerUtil.getProperty(ctxt.getProperties(),
+ StratosConstants.KUBERNETES_CLUSTER_ID);
+ handleNullObject(kubernetesClusterId, "Kubernetes units termination failed. Cannot find '"+
+ StratosConstants.KUBERNETES_CLUSTER_ID+"'. " + ctxt);
+
+ KubernetesClusterContext kubClusterContext = dataHolder.getKubernetesClusterContext(kubernetesClusterId);
+ handleNullObject(kubClusterContext, "Kubernetes units termination failed. Cannot find a matching Kubernetes Cluster for cluster id: "
+ +kubernetesClusterId);
+
+ KubernetesApiClient kubApi = kubClusterContext.getKubApi();
+ // delete the service
+ try {
+ kubApi.deleteService(CloudControllerUtil.getCompatibleId(clusterId));
+ } catch (KubernetesClientException e) {
+ // we're not going to throw this error, but proceed with other deletions
+ LOG.error("Failed to delete Kubernetes service with id: "+clusterId, e);
+ }
+
+ // set replicas=0 for the replication controller
+ try {
+ kubApi.updateReplicationController(clusterId, 0);
+ } catch (KubernetesClientException e) {
+ // we're not going to throw this error, but proceed with other deletions
+ LOG.error("Failed to update Kubernetes Controller with id: "+clusterId, e);
+ }
+
+ // delete pods forcefully
+ try {
+ // create a label query
+ Label l = new Label();
+ l.setName(clusterId);
+ // execute the label query
+ Pod[] pods = kubApi.getSelectedPods(new Label[]{l});
+
+ for (Pod pod : pods) {
+ try {
+ // delete pods forcefully
+ kubApi.deletePod(pod.getId());
+ } catch (KubernetesClientException ignore) {
+ // we can't do nothing here
+ LOG.warn(String.format("Failed to delete Pod [%s] forcefully!", pod.getId()));
+ }
+ }
+ } catch (KubernetesClientException e) {
+ // we're not going to throw this error, but proceed with other deletions
+ LOG.error("Failed to delete pods forcefully for cluster: "+clusterId, e);
+ }
+
+ // delete the replication controller.
+ try {
+ kubApi.deleteReplicationController(clusterId);
+ } catch (KubernetesClientException e) {
+ String msg = "Failed to delete Kubernetes Controller with id: "+clusterId;
+ LOG.error(msg, e);
+ throw new InvalidClusterException(msg, e);
+ }
+
+ String allocatedPort = CloudControllerUtil.getProperty(ctxt.getProperties(),
+ StratosConstants.ALLOCATED_SERVICE_HOST_PORT);
+
+ if (allocatedPort != null) {
+ kubClusterContext.deallocateHostPort(Integer
+ .parseInt(allocatedPort));
+ } else {
+ LOG.warn("Host port dealloacation failed due to a missing property: "
+ + StratosConstants.ALLOCATED_SERVICE_HOST_PORT);
+ }
+
+ List<MemberContext> membersToBeRemoved = dataHolder.getMemberContextsOfClusterId(clusterId);
+
+ for (MemberContext memberContext : membersToBeRemoved) {
+ logTermination(memberContext);
+ }
+
+ // persist
+ persist();
+
+ return membersToBeRemoved.toArray(new MemberContext[0]);
+ }
+
+ @Override
+ public MemberContext[] updateContainers(String clusterId, int replicas)
+ throws UnregisteredCartridgeException {
+
+ if(LOG.isDebugEnabled()) {
+ LOG.debug("CloudControllerServiceImpl:updateContainers for cluster : "+clusterId);
+ }
+
+ ClusterContext ctxt = dataHolder.getClusterContext(clusterId);
+ handleNullObject(ctxt, "Container update failed. Invalid cluster id. " + clusterId);
+
+ String cartridgeType = ctxt.getCartridgeType();
+
+ Cartridge cartridge = dataHolder.getCartridge(cartridgeType);
+
+ if (cartridge == null) {
+ String msg =
+ "Container update failed. No matching Cartridge found [type] "+cartridgeType
+ +". [cluster id] "+ clusterId;
+ LOG.error(msg);
+ throw new UnregisteredCartridgeException(msg);
+ }
+
+ try {
+ String kubernetesClusterId = validateProperty(StratosConstants.KUBERNETES_CLUSTER_ID, ctxt);
+
+ KubernetesClusterContext kubClusterContext = dataHolder.getKubernetesClusterContext(kubernetesClusterId);
+
+ if (kubClusterContext == null) {
+ String msg =
+ "Instance start-up failed. No matching Kubernetes Context Found for [id] "+kubernetesClusterId
+ +". [cluster id] "+ clusterId;
+ LOG.error(msg);
+ throw new UnregisteredCartridgeException(msg);
+ }
+
+ KubernetesApiClient kubApi = kubClusterContext.getKubApi();
+ // create a label query
+ Label l = new Label();
+ l.setName(clusterId);
+
+ // get the current pods - useful when scale down
+ Pod[] previousStatePods = kubApi.getSelectedPods(new Label[]{l});
+
+ // update the replication controller - cluster id = replication controller id
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Cloud Controller is delegating request to update a replication controller "+clusterId+
+ " to Kubernetes layer.");
+ }
+
+ kubApi.updateReplicationController(clusterId, replicas);
+
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Cloud Controller successfully updated the controller "
+ + clusterId + " via Kubernetes layer.");
+ }
+
+ // execute the label query
+ Pod[] allPods = new Pod[0];
+
+ // wait replicas*5s time in the worst case ; best case = 0s
+ for (int i = 0; i < (replicas*previousStatePods.length+1) ; i++) {
+ allPods = kubApi.getSelectedPods(new Label[]{l});
+
+ if (LOG.isDebugEnabled()) {
+
+ LOG.debug("Pods Count: "+allPods.length+" for cluster: "+clusterId);
+ }
+ if(allPods.length == replicas) {
+ break;
+ }
+ Thread.sleep(10000);
+ }
+
+ if (LOG.isDebugEnabled()) {
+
+ LOG.debug(String.format("Pods created : %s for cluster : %s",allPods.length, clusterId));
+ }
+
+ List<MemberContext> memberContexts = new ArrayList<MemberContext>();
+
+ PodToMemberContext podToMemberContextFunc = new PodToMemberContext();
+ // generate Member Contexts
+ for (Pod pod : allPods) {
+ MemberContext context;
+ // if member context does not exist -> a new member (scale up)
+ if ((context = dataHolder.getMemberContextOfMemberId(pod.getId())) == null) {
+
+ context = podToMemberContextFunc.apply(pod);
+ context.setCartridgeType(cartridgeType);
+ context.setClusterId(clusterId);
+
+ context.setProperties(CloudControllerUtil.addProperty(context
+ .getProperties(), StratosConstants.ALLOCATED_SERVICE_HOST_PORT,
+ CloudControllerUtil.getProperty(ctxt.getProperties(),
+ StratosConstants.ALLOCATED_SERVICE_HOST_PORT)));
+
+ // wait till Pod status turns to running and send member spawned.
+ ScheduledThreadExecutor exec = ScheduledThreadExecutor.getInstance();
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Cloud Controller is starting the instance start up thread.");
+ }
+ dataHolder.addScheduledFutureJob(context.getMemberId(), exec.schedule(new PodActivationWatcher(pod.getId(), context, kubApi), 5000));
+
+ memberContexts.add(context);
+
+ }
+ // publish data
+ // TODO
+// CartridgeInstanceDataPublisher.publish(context.getMemberId(), null, null, context.getClusterId(), cartridgeType, MemberStatus.Created.toString(), node);
+
+ }
+
+ if (memberContexts.isEmpty()) {
+ // terminated members
+ @SuppressWarnings("unchecked")
+ List<Pod> difference = ListUtils.subtract(Arrays.asList(previousStatePods), Arrays.asList(allPods));
+ for (Pod pod : difference) {
+ if (pod != null) {
+ MemberContext context = dataHolder.getMemberContextOfMemberId(pod.getId());
+ logTermination(context);
+ memberContexts.add(context);
+ }
+ }
+ }
+
+
+ // persist in registry
+ persist();
+
+ LOG.info("Kubernetes entities are successfully starting up. "+memberContexts);
+
+ return memberContexts.toArray(new MemberContext[0]);
+
+ } catch (Exception e) {
+ String msg = "Failed to update containers belong to cluster " + clusterId+". Cause: "+e.getMessage();
+ LOG.error(msg, e);
+ throw new IllegalStateException(msg, e);
+ }
+ }
+
+ @Override
+ public MemberContext terminateContainer(String memberId) throws MemberTerminationFailedException {
+
+ handleNullObject(memberId, "Failed to terminate member. Invalid Member id. [Member id] " + memberId);
+
+ MemberContext memberContext = dataHolder.getMemberContextOfMemberId(memberId);
+
+ handleNullObject(memberContext, "Failed to terminate member. Member id not found. [Member id] " + memberId);
+
+ String clusterId = memberContext.getClusterId();
+
+ handleNullObject(clusterId, "Failed to terminate member. Cluster id is null. [Member id] " + memberId);
+
+ ClusterContext ctxt = dataHolder.getClusterContext(clusterId);
+
+ handleNullObject(ctxt,
+ String.format("Failed to terminate member [Member id] %s. Invalid cluster id %s ", memberId, clusterId));
+
+ String kubernetesClusterId = CloudControllerUtil.getProperty(ctxt.getProperties(),
+ StratosConstants.KUBERNETES_CLUSTER_ID);
+
+ handleNullObject(kubernetesClusterId, String.format("Failed to terminate member [Member id] %s. Cannot find '"+
+ StratosConstants.KUBERNETES_CLUSTER_ID+"' in [cluster context] %s ", memberId, ctxt));
+
+ KubernetesClusterContext kubClusterContext = dataHolder.getKubernetesClusterContext(kubernetesClusterId);
+
+ handleNullObject(kubClusterContext, String.format("Failed to terminate member [Member id] %s. Cannot find a matching Kubernetes Cluster in [cluster context] %s ", memberId, ctxt));
+
+ KubernetesApiClient kubApi = kubClusterContext.getKubApi();
+ // delete the Pod
+ try {
+ // member id = pod id
+ kubApi.deletePod(memberId);
+
+ MemberContext memberToBeRemoved = dataHolder.getMemberContextOfMemberId(memberId);
+
+ logTermination(memberToBeRemoved);
+
+ return memberToBeRemoved;
+
+ } catch (KubernetesClientException e) {
+ String msg = String.format("Failed to terminate member [Member id] %s", memberId);
+ LOG.error(msg, e);
+ throw new MemberTerminationFailedException(msg, e);
+ }
+ }
+
+ private void handleNullObject(Object obj, String errorMsg) {
+ if (obj == null) {
+ LOG.error(errorMsg);
+ throw new IllegalArgumentException(errorMsg);
+ }
+ }
+
+ public void deployApplicationDefinition (ApplicationContext applicationContext) throws ApplicationDefinitionException {
+
+ ApplicationParser applicationParser = new DefaultApplicationParser();
+ Application application = applicationParser.parse(applicationContext);
+
+ // Create a Cluster Context obj. for each of the Clusters in the Application
+ for (ApplicationClusterContext applicationClusterContext : applicationParser.getApplicationClusterContexts()) {
+ dataHolder.addClusterContext(new ClusterContext(applicationClusterContext.getClusterId(),
+ applicationClusterContext.getCartridgeType(), applicationClusterContext.getTextPayload(),
+ applicationClusterContext.getHostName(), applicationClusterContext.isLbCluster()));
+ }
+
+ TopologyBuilder.handleApplicationDeployed(application, applicationParser.getApplicationClusterContexts(),
+ applicationParser.getPayloadData());
+
+ persist();
+ }
+
+ @Override
+ public void unDeployApplicationDefinition(String applicationId, int tenantId, String tenantDomain) throws ApplicationDefinitionException {
+
+ TopologyBuilder.handleApplicationUndeployed(applicationId);
+ }
+
}
http://git-wip-us.apache.org/repos/asf/stratos/blob/17cc86eb/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/interfaces/CloudControllerService.java
----------------------------------------------------------------------
diff --cc components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/interfaces/CloudControllerService.java
index d81eab7,5301b14..835cc09
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/interfaces/CloudControllerService.java
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/interfaces/CloudControllerService.java
@@@ -19,16 -19,9 +19,18 @@@
package org.apache.stratos.cloud.controller.interfaces;
import org.apache.stratos.cloud.controller.deployment.partition.Partition;
+import org.apache.stratos.cloud.controller.exception.InvalidCartridgeDefinitionException;
+import org.apache.stratos.cloud.controller.exception.InvalidCartridgeTypeException;
+import org.apache.stratos.cloud.controller.exception.InvalidClusterException;
+import org.apache.stratos.cloud.controller.exception.InvalidIaasProviderException;
+import org.apache.stratos.cloud.controller.exception.InvalidMemberException;
+import org.apache.stratos.cloud.controller.exception.InvalidPartitionException;
+import org.apache.stratos.cloud.controller.exception.MemberTerminationFailedException;
+import org.apache.stratos.cloud.controller.exception.UnregisteredCartridgeException;
+import org.apache.stratos.cloud.controller.exception.UnregisteredClusterException;
+ import org.apache.stratos.cloud.controller.exception.*;
import org.apache.stratos.cloud.controller.pojo.*;
+ import org.apache.stratos.cloud.controller.pojo.application.ApplicationContext;
/**
* This API provides a way to communicate with underline
http://git-wip-us.apache.org/repos/asf/stratos/blob/17cc86eb/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/internal/CloudControllerDSComponent.java
----------------------------------------------------------------------
diff --cc components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/internal/CloudControllerDSComponent.java
index 934788f,5831948..88ff2b6
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/internal/CloudControllerDSComponent.java
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/internal/CloudControllerDSComponent.java
@@@ -30,7 -32,10 +32,9 @@@ import org.apache.stratos.cloud.control
import org.apache.stratos.cloud.controller.topic.instance.status.InstanceStatusEventMessageListener;
import org.apache.stratos.cloud.controller.util.CloudControllerConstants;
import org.apache.stratos.cloud.controller.util.ServiceReferenceHolder;
-import org.apache.stratos.messaging.broker.publish.EventPublisherPool;
import org.apache.stratos.messaging.broker.subscribe.TopicSubscriber;
+ import org.apache.stratos.messaging.message.receiver.application.status.ApplicationStatusEventReceiver;
+ import org.apache.stratos.messaging.util.Constants;
import org.osgi.framework.BundleContext;
import org.osgi.service.component.ComponentContext;
import org.wso2.carbon.ntask.core.service.TaskService;
@@@ -59,71 -64,77 +63,67 @@@ import org.wso2.carbon.utils.Configurat
*/
public class CloudControllerDSComponent {
- private static final Log LOG = LogFactory
- .getLog(CloudControllerDSComponent.class);
-
- protected void activate(ComponentContext context) {
- try {
-
- // Start instance status event message listener
- TopicSubscriber subscriber = new TopicSubscriber(
- CloudControllerConstants.INSTANCE_TOPIC);
- subscriber.setMessageListener(
- new InstanceStatusEventMessageListener());
- Thread tsubscriber = new Thread(subscriber);
- tsubscriber.start();
-
- // Start instance status message delegator
- InstanceStatusEventMessageDelegator delegator =
- new InstanceStatusEventMessageDelegator();
- Thread tdelegator = new Thread(delegator);
- tdelegator.start();
-
- // Register cloud controller service
- BundleContext bundleContext = context.getBundleContext();
- bundleContext.registerService(CloudControllerService.class.getName(),
- new CloudControllerServiceImpl(), null);
-
- if (LOG.isInfoEnabled()) {
- LOG.info("Scheduling tasks");
- }
-
- TopologySynchronizerTaskScheduler.schedule(ServiceReferenceHolder
- .getInstance().getTaskService());
-
- } catch (Throwable e) {
- LOG.error("Cloud Controller Service bundle is failed to activate.", e);
- }
- }
-
- protected void setTaskService(TaskService taskService) {
- if (LOG.isDebugEnabled()) {
- LOG.debug("Setting the Task Service");
- }
- ServiceReferenceHolder.getInstance().setTaskService(taskService);
- }
-
- protected void unsetTaskService(TaskService taskService) {
- if (LOG.isDebugEnabled()) {
- LOG.debug("Unsetting the Task Service");
- }
- ServiceReferenceHolder.getInstance().setTaskService(null);
- }
-
+ private static final Log log = LogFactory.getLog(CloudControllerDSComponent.class);
- private ApplicationStatusTopicReceiver applicationStatusTopicReceiver;
++
+ protected void activate(ComponentContext context) {
+ try {
+
+ // Start instance status event message listener
+ TopicSubscriber subscriber = new TopicSubscriber(CloudControllerConstants.INSTANCE_TOPIC);
+ subscriber.setMessageListener(new InstanceStatusEventMessageListener());
+ Thread tsubscriber = new Thread(subscriber);
+ tsubscriber.start();
+
+ // Start instance status message delegator
+ InstanceStatusEventMessageDelegator delegator = new InstanceStatusEventMessageDelegator();
+ Thread tdelegator = new Thread(delegator);
+ tdelegator.start();
-
- applicationStatusTopicReceiver = new ApplicationStatusTopicReceiver();
- Thread appThread = new Thread(applicationStatusTopicReceiver);
- appThread.start();
- if (log.isDebugEnabled()) {
- log.debug("Application status Receiver thread started");
- }
-
+
+ // Register cloud controller service
+ BundleContext bundleContext = context.getBundleContext();
+ bundleContext.registerService(CloudControllerService.class.getName(), new CloudControllerServiceImpl(), null);
+
+ if(log.isInfoEnabled()) {
+ log.info("Scheduling tasks");
+ }
+
+ TopologySynchronizerTaskScheduler
+ .schedule(ServiceReferenceHolder.getInstance()
+ .getTaskService());
-
-
+
+ } catch (Throwable e) {
+ log.error("******* Cloud Controller Service bundle is failed to activate ****", e);
+ }
+ }
+
+ protected void setTaskService(TaskService taskService) {
+ if (log.isDebugEnabled()) {
+ log.debug("Setting the Task Service");
+ }
+ ServiceReferenceHolder.getInstance().setTaskService(taskService);
+ }
+
+ protected void unsetTaskService(TaskService taskService) {
+ if (log.isDebugEnabled()) {
+ log.debug("Unsetting the Task Service");
+ }
+ ServiceReferenceHolder.getInstance().setTaskService(null);
+ }
+
protected void setRegistryService(RegistryService registryService) {
- if (LOG.isDebugEnabled()) {
- LOG.debug("Setting the Registry Service");
- }
-
- try {
- UserRegistry registry = registryService
- .getGovernanceSystemRegistry();
- ServiceReferenceHolder.getInstance().setRegistry(registry);
- } catch (RegistryException e) {
- String msg = "Failed when retrieving Governance System Registry.";
- LOG.error(msg, e);
- throw new CloudControllerException(msg, e);
+ if (log.isDebugEnabled()) {
+ log.debug("Setting the Registry Service");
}
+
+ try {
+ UserRegistry registry = registryService.getGovernanceSystemRegistry();
+ ServiceReferenceHolder.getInstance()
+ .setRegistry(registry);
+ } catch (RegistryException e) {
+ String msg = "Failed when retrieving Governance System Registry.";
+ log.error(msg, e);
+ throw new CloudControllerException(msg, e);
+ }
}
protected void unsetRegistryService(RegistryService registryService) {
http://git-wip-us.apache.org/repos/asf/stratos/blob/17cc86eb/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/Cartridge.java
----------------------------------------------------------------------
diff --cc components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/Cartridge.java
index 3103a22,805aaa5..002157e
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/Cartridge.java
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/Cartridge.java
@@@ -374,21 -372,13 +376,29 @@@ public class Cartridge implements Seria
this.serviceGroup = serviceGroup;
}
+ public Container getContainer() {
+ return container;
+ }
+
+ public void setContainer(Container container) {
+ this.container = container;
+ }
+
+ public String getDeployerType() {
+ return deployerType;
+ }
+
+ public void setDeployerType(String deployerType) {
+ this.deployerType = deployerType;
+ }
-
-
++
+
+ public String[] getExportingProperties() {
+ return exportingProperties;
+ }
+
+ public void setExportingProperties(String[] exportingProperties) {
+ this.exportingProperties = exportingProperties;
+ }
+
}
http://git-wip-us.apache.org/repos/asf/stratos/blob/17cc86eb/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/CartridgeConfig.java
----------------------------------------------------------------------
diff --cc components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/CartridgeConfig.java
index 670ef19,00fe884..51e571e
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/CartridgeConfig.java
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/CartridgeConfig.java
@@@ -66,10 -62,8 +66,11 @@@ public class CartridgeConfig implement
private LoadbalancerConfig lbConfig;
private String serviceGroup;
+
+ private Container container;
+ private String[] exportingProperties;
+ private String deployerType;
public String getType() {
return type;
@@@ -285,21 -271,12 +286,30 @@@
this.serviceGroup = serviceGroup;
}
+
+ public String[] getExportingProperties() {
+ return exportingProperties;
+ }
+
+ public void setExportingProperties(String[] exportingProperties) {
+ this.exportingProperties = exportingProperties;
+ }
++
+ public Container getContainer() {
+ return container;
+ }
+
+ public void setContainer(Container container) {
+ this.container = container;
+ }
+
+ public String getDeployerType() {
+ return deployerType;
+ }
+
+ public void setDeployerType(String deployerType) {
+ this.deployerType = deployerType;
+ }
+
+
}
http://git-wip-us.apache.org/repos/asf/stratos/blob/17cc86eb/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/runtime/FasterLookUpDataHolder.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/stratos/blob/17cc86eb/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java
----------------------------------------------------------------------
diff --cc components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java
index aa98e5d,b6e3470..bf74095
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java
@@@ -24,11 -23,14 +24,15 @@@ import org.apache.commons.logging.LogFa
import org.apache.stratos.cloud.controller.exception.InvalidCartridgeTypeException;
import org.apache.stratos.cloud.controller.exception.InvalidMemberException;
import org.apache.stratos.cloud.controller.pojo.*;
+ import org.apache.stratos.cloud.controller.pojo.Cartridge;
+ import org.apache.stratos.cloud.controller.pojo.payload.MetaDataHolder;
import org.apache.stratos.cloud.controller.publisher.CartridgeInstanceDataPublisher;
+ import org.apache.stratos.cloud.controller.registry.RegistryManager;
import org.apache.stratos.cloud.controller.runtime.FasterLookUpDataHolder;
import org.apache.stratos.cloud.controller.util.CloudControllerUtil;
+import org.apache.stratos.common.constants.StratosConstants;
import org.apache.stratos.messaging.domain.topology.*;
+ import org.apache.stratos.messaging.event.application.status.*;
import org.apache.stratos.messaging.event.instance.status.InstanceActivatedEvent;
import org.apache.stratos.messaging.event.instance.status.InstanceMaintenanceModeEvent;
import org.apache.stratos.messaging.event.instance.status.InstanceReadyToShutdownEvent;
@@@ -119,13 -121,8 +123,13 @@@ public class TopologyBuilder
TopologyManager.acquireWriteLock();
String cartridgeType = registrant.getCartridgeType();
service = topology.getService(cartridgeType);
+
+ if(log.isDebugEnabled()) {
+ log.debug(" Service is retrieved from Topology [" + service + "] ");
+ }
+
Properties props = CloudControllerUtil.toJavaUtilProperties(registrant.getProperties());
-
+
Cluster cluster;
String clusterId = registrant.getClusterId();
if (service.clusterExists(clusterId)) {
@@@ -140,21 -137,19 +144,22 @@@
}
cluster.setProperties(props);
cluster.setLbCluster(isLb);
+ setKubernetesCluster(cluster);
} else {
cluster = new Cluster(cartridgeType, clusterId,
- registrant.getDeploymentPolicyName(), registrant.getAutoScalerPolicyName());
+ registrant.getDeploymentPolicyName(), registrant.getAutoScalerPolicyName(), null);
cluster.addHostName(registrant.getHostName());
- if(service.getServiceType() == ServiceType.MultiTenant) {
+ if (service.getServiceType() == ServiceType.MultiTenant) {
cluster.setTenantRange(registrant.getTenantRange());
}
- if(service.getProperties().getProperty(Constants.IS_PRIMARY) != null) {
+ if (service.getProperties().getProperty(Constants.IS_PRIMARY) != null) {
props.setProperty(Constants.IS_PRIMARY, service.getProperties().getProperty(Constants.IS_PRIMARY));
}
cluster.setProperties(props);
cluster.setLbCluster(isLb);
+ //cluster.setStatus(Status.Created);
+ setKubernetesCluster(cluster);
+ cluster.setStatus(ClusterStatus.Created);
service.addCluster(cluster);
}
TopologyManager.updateTopology(topology);
@@@ -162,18 -157,10 +167,18 @@@
} finally {
TopologyManager.releaseWriteLock();
- }
+ }*/
}
- public static void handleClusterRemoved(ClusterContext ctxt) {
+ private static void setKubernetesCluster(Cluster cluster) {
+ boolean isKubernetesCluster = (cluster.getProperties().getProperty(StratosConstants.KUBERNETES_CLUSTER_ID) != null);
+ if (log.isDebugEnabled()) {
+ log.debug(" Kubernetes Cluster ["+ isKubernetesCluster + "] ");
+ }
+ cluster.setKubernetesCluster(isKubernetesCluster);
+ }
+
+ public static void handleClusterRemoved(ClusterContext ctxt) {
Topology topology = TopologyManager.getTopology();
Service service = topology.getService(ctxt.getCartridgeType());
String deploymentPolicy;
@@@ -364,17 -331,34 +349,24 @@@
}
MemberActivatedEvent memberActivatedEvent = new MemberActivatedEvent(instanceActivatedEvent.getServiceName(),
- instanceActivatedEvent.getClusterId(), instanceActivatedEvent.getNetworkPartitionId(), instanceActivatedEvent.getPartitionId(), instanceActivatedEvent.getMemberId());
+ instanceActivatedEvent.getClusterId(), instanceActivatedEvent.getNetworkPartitionId(), instanceActivatedEvent.getPartitionId(), instanceActivatedEvent.getMemberId());
+ // grouping - set grouid
+ memberActivatedEvent.setGroupId(instanceActivatedEvent.getGroupId());
try {
TopologyManager.acquireWriteLock();
+ // try update lifecycle state
+ if (!member.isStateTransitionValid(MemberStatus.Activated)) {
+ log.error("Invalid State Transition from " + member.getStatus() + " to " + MemberStatus.Activated);
+ }
member.setStatus(MemberStatus.Activated);
log.info("member started event adding status activated");
- Cartridge cartridge = FasterLookUpDataHolder.getInstance().
- getCartridge(instanceActivatedEvent.getServiceName());
-
- List<PortMapping> portMappings = cartridge.getPortMappings();
- Port port;
- //adding ports to the event
- for (PortMapping portMapping : portMappings) {
- port = new Port(portMapping.getProtocol(),
- Integer.parseInt(portMapping.getPort()),
- Integer.parseInt(portMapping.getProxyPort()));
- member.addPort(port);
- memberActivatedEvent.addPort(port);
- }
+ // Adding ports to the event
+ // TODO: Need to remove this since ports are now set in member spawned event
+ memberActivatedEvent.addPorts(member.getPorts());
memberActivatedEvent.setMemberIp(member.getMemberIp());
+ memberActivatedEvent.setMemberPublicIp(member.getMemberPublicIp());
TopologyManager.updateTopology(topology);
} finally {
[35/50] [abbrv] git commit: initial parent to child status
notification
Posted by im...@apache.org.
initial parent to child status notification
Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/ff315c99
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/ff315c99
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/ff315c99
Branch: refs/heads/docker-grouping-merge
Commit: ff315c990eb33532bcd28eecba32d2b86256991c
Parents: 3b51d5c
Author: Isuru Haththotuwa <is...@apache.org>
Authored: Wed Oct 29 15:13:47 2014 +0530
Committer: Isuru Haththotuwa <is...@apache.org>
Committed: Wed Oct 29 15:16:22 2014 +0530
----------------------------------------------------------------------
.../AutoscalerTopologyEventReceiver.java | 2 +-
.../monitor/AbstractClusterMonitor.java | 2 +-
.../autoscaler/monitor/EventHandler.java | 11 ++++--
.../monitor/MonitorStatusEventBuilder.java | 8 +++--
.../monitor/ParentComponentMonitor.java | 35 ++++++++++++++++++++
.../monitor/application/ApplicationMonitor.java | 9 ++---
.../monitor/cluster/ClusterMonitor.java | 7 +++-
.../autoscaler/monitor/group/GroupMonitor.java | 9 +++--
8 files changed, 67 insertions(+), 16 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/stratos/blob/ff315c99/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 ac8b6c9..8c2d1a1 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
@@ -470,7 +470,7 @@ public class AutoscalerTopologyEventReceiver implements Runnable {
// topologyEventReceiver.addEventListener(new ApplicationRemovedEventListener() {
// @Override
-// protected void onEvent(Event event) {
+// protected void onChildEvent(Event event) {
//
// log.info("[ApplicationRemovedEvent] Received: " + event.getClass());
//
http://git-wip-us.apache.org/repos/asf/stratos/blob/ff315c99/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/AbstractClusterMonitor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/AbstractClusterMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/AbstractClusterMonitor.java
index 1461b6e..1eda837 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/AbstractClusterMonitor.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/AbstractClusterMonitor.java
@@ -248,7 +248,7 @@ abstract public class AbstractClusterMonitor extends Monitor implements Runnable
}
@Override
- public void onEvent(MonitorStatusEvent statusEvent) {
+ public void onChildEvent(MonitorStatusEvent statusEvent) {
}
http://git-wip-us.apache.org/repos/asf/stratos/blob/ff315c99/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/EventHandler.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/EventHandler.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/EventHandler.java
index e4eb816..06c722c 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/EventHandler.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/EventHandler.java
@@ -27,11 +27,18 @@ import org.apache.stratos.autoscaler.monitor.events.MonitorTerminateAllEvent;
*/
public interface EventHandler {
/**
- * Triggered when an event is received.
+ * Triggered when an event is received from a child.
*
* @param statusEvent
*/
- public abstract void onEvent(MonitorStatusEvent statusEvent);
+ public abstract void onChildEvent(MonitorStatusEvent statusEvent);
+
+ /**
+ * Triggered when an event is received from the parent.
+ *
+ * @param statusEvent
+ */
+ public abstract void onParentEvent(MonitorStatusEvent statusEvent);
/**
* Triggered when termination decision is made.
http://git-wip-us.apache.org/repos/asf/stratos/blob/ff315c99/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/MonitorStatusEventBuilder.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/MonitorStatusEventBuilder.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/MonitorStatusEventBuilder.java
index fcb0f06..30187ea 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/MonitorStatusEventBuilder.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/MonitorStatusEventBuilder.java
@@ -50,8 +50,12 @@ public class MonitorStatusEventBuilder {
}
private static void notifyParent(ParentComponentMonitor parent, MonitorStatusEvent statusEvent) {
- parent.onEvent(statusEvent);
+ parent.onChildEvent(statusEvent);
}
-
+ public static void notifyChildren (ParentComponentMonitor parent, MonitorStatusEvent statusEvent) {
+ for (Monitor activeChildMonitor : parent.getAliasToActiveMonitorsMap().values()) {
+ activeChildMonitor.onParentEvent(statusEvent);
+ }
+ }
}
http://git-wip-us.apache.org/repos/asf/stratos/blob/ff315c99/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ParentComponentMonitor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ParentComponentMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ParentComponentMonitor.java
index bd50f42..7ad0a43 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ParentComponentMonitor.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ParentComponentMonitor.java
@@ -30,6 +30,8 @@ import org.apache.stratos.autoscaler.grouping.dependency.context.ApplicationCont
import org.apache.stratos.autoscaler.grouping.topic.StatusEventPublisher;
import org.apache.stratos.autoscaler.monitor.events.MonitorStatusEvent;
import org.apache.stratos.autoscaler.status.checker.StatusChecker;
+import org.apache.stratos.messaging.domain.topology.ApplicationStatus;
+import org.apache.stratos.messaging.domain.topology.GroupStatus;
import org.apache.stratos.messaging.domain.topology.ParentComponent;
import java.util.HashMap;
@@ -111,6 +113,39 @@ public abstract class ParentComponentMonitor extends Monitor {
}
}
+ @Override
+ public void onParentEvent(MonitorStatusEvent statusEvent) {
+
+ if (statusEvent.getStatus() == GroupStatus.Terminating || statusEvent.getStatus() ==
+ ApplicationStatus.Terminating) {
+
+ // parent monitor is in Terminating state. send Terminating event for all monitors
+ for (Monitor childMonitor : this.getAliasToActiveMonitorsMap().values()) {
+ if (childMonitor.hasActiveMonitors()) {
+ // this is a Group Monitor, send Group Terminating
+ StatusEventPublisher.sendGroupTerminatingEvent(appId, childMonitor.getId());
+ markMonitorAsInactive(childMonitor.getId());
+ } else {
+ // this is a Cluster Monitor, send Cluster Terminating
+ StatusEventPublisher.sendClusterTerminatingEvent(appId,
+ ((AbstractClusterMonitor) childMonitor).getServiceId(),
+ ((AbstractClusterMonitor) childMonitor).getClusterId());
+ markMonitorAsInactive(((AbstractClusterMonitor) childMonitor).getClusterId());
+ }
+
+ }
+ }
+ }
+
+ // move to inactive monitors list to use in the Terminated event
+ private synchronized void markMonitorAsInactive (String monitorKey) {
+
+ if (!this.aliasToInActiveMonitorsMap.containsKey(monitorKey)) {
+ this.aliasToInActiveMonitorsMap.put(monitorKey,
+ this.aliasToActiveMonitorsMap.remove(monitorKey));
+ }
+ }
+
protected void onChildInActiveEvent(String idOfEvent) {
List<ApplicationContext> terminationList;
Monitor monitor;
http://git-wip-us.apache.org/repos/asf/stratos/blob/ff315c99/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 77def36..337a5c5 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
@@ -27,6 +27,7 @@ import org.apache.stratos.autoscaler.monitor.AbstractClusterMonitor;
import org.apache.stratos.autoscaler.monitor.Monitor;
import org.apache.stratos.autoscaler.monitor.MonitorStatusEventBuilder;
import org.apache.stratos.autoscaler.monitor.ParentComponentMonitor;
+import org.apache.stratos.autoscaler.monitor.events.ApplicationStatusEvent;
import org.apache.stratos.autoscaler.monitor.events.MonitorScalingEvent;
import org.apache.stratos.autoscaler.monitor.events.MonitorStatusEvent;
import org.apache.stratos.autoscaler.monitor.events.MonitorTerminateAllEvent;
@@ -143,14 +144,14 @@ public class ApplicationMonitor extends ParentComponentMonitor {
public void setStatus(ApplicationStatus status) {
log.info(String.format("[ApplicationMonitor] %s " +
"state changes from %s to %s", id, this.status, status));
- //if(this.status != status) {
- this.status = status;
- //}
+ this.status = status;
+ //notify the children about the state change
+ MonitorStatusEventBuilder.notifyChildren(this.parent, new ApplicationStatusEvent(status, appId));
}
@Override
- public void onEvent(MonitorStatusEvent statusEvent) {
+ public void onChildEvent(MonitorStatusEvent statusEvent) {
monitor(statusEvent);
}
http://git-wip-us.apache.org/repos/asf/stratos/blob/ff315c99/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 b47fb15..b9f6cbf 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
@@ -275,7 +275,12 @@ public class ClusterMonitor extends AbstractClusterMonitor {
}
@Override
- public void onEvent(MonitorStatusEvent statusEvent) {
+ public void onChildEvent(MonitorStatusEvent statusEvent) {
}
+
+ @Override
+ public void onParentEvent(MonitorStatusEvent statusEvent) {
+ // doesn't have to do anything since this is not a Parent Monitor
+ }
}
http://git-wip-us.apache.org/repos/asf/stratos/blob/ff315c99/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java
index e6f8495..2fe5ae7 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java
@@ -25,9 +25,7 @@ import org.apache.stratos.autoscaler.exception.TopologyInConsistentException;
import org.apache.stratos.autoscaler.monitor.EventHandler;
import org.apache.stratos.autoscaler.monitor.MonitorStatusEventBuilder;
import org.apache.stratos.autoscaler.monitor.ParentComponentMonitor;
-import org.apache.stratos.autoscaler.monitor.events.MonitorScalingEvent;
-import org.apache.stratos.autoscaler.monitor.events.MonitorStatusEvent;
-import org.apache.stratos.autoscaler.monitor.events.MonitorTerminateAllEvent;
+import org.apache.stratos.autoscaler.monitor.events.*;
import org.apache.stratos.autoscaler.status.checker.StatusChecker;
import org.apache.stratos.messaging.domain.topology.ClusterStatus;
import org.apache.stratos.messaging.domain.topology.Group;
@@ -59,7 +57,7 @@ public class GroupMonitor extends ParentComponentMonitor implements EventHandler
}
@Override
- public void onEvent(MonitorStatusEvent statusEvent) {
+ public void onChildEvent(MonitorStatusEvent statusEvent) {
monitor(statusEvent);
}
@@ -150,6 +148,7 @@ public class GroupMonitor extends ParentComponentMonitor implements EventHandler
MonitorStatusEventBuilder.handleGroupStatusEvent(this.parent, this.status, this.id);
}
//}
-
+ //notify the children about the state change
+ MonitorStatusEventBuilder.notifyChildren(this.parent, new GroupStatusEvent(status, getId()));
}
}
[07/50] [abbrv] git commit: fixing a issue in acquiring locks in
ApplicationTerminatedMessageProcessor
Posted by im...@apache.org.
fixing a issue in acquiring locks in ApplicationTerminatedMessageProcessor
Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/bea691b0
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/bea691b0
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/bea691b0
Branch: refs/heads/docker-grouping-merge
Commit: bea691b0fca8ac36b9d329d0b2a9da8369652d0f
Parents: b56e328
Author: Isuru Haththotuwa <is...@apache.org>
Authored: Mon Oct 27 13:18:18 2014 +0530
Committer: Isuru Haththotuwa <is...@apache.org>
Committed: Mon Oct 27 13:18:18 2014 +0530
----------------------------------------------------------------------
.../topology/ApplicationTerminatedMessageProcessor.java | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/stratos/blob/bea691b0/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationTerminatedMessageProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationTerminatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationTerminatedMessageProcessor.java
index 49a8d22..3b91e3f 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationTerminatedMessageProcessor.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationTerminatedMessageProcessor.java
@@ -58,7 +58,7 @@ public class ApplicationTerminatedMessageProcessor extends MessageProcessor {
ApplicationTerminatedEvent event = (ApplicationTerminatedEvent) Util.
jsonToObject(message, ApplicationTerminatedEvent.class);
- TopologyUpdater.acquireWriteLockForApplication(event.getAppId());
+ TopologyUpdater.acquireWriteLockForApplications();
Set<ClusterDataHolder> clusterDataHolders = event.getClusterData();
if (clusterDataHolders != null) {
for (ClusterDataHolder clusterData : clusterDataHolders) {
@@ -70,7 +70,7 @@ public class ApplicationTerminatedMessageProcessor extends MessageProcessor {
return doProcess(event, topology);
} finally {
- TopologyUpdater.releaseWriteLockForApplication(event.getAppId());
+ TopologyUpdater.releaseWriteLockForApplications();
if (clusterDataHolders != null) {
for (ClusterDataHolder clusterData : clusterDataHolders) {
TopologyUpdater.releaseWriteLockForService(clusterData.getServiceType());
[36/50] [abbrv] git commit: fix compilation failure
Posted by im...@apache.org.
fix compilation failure
Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/fcd8a7ca
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/fcd8a7ca
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/fcd8a7ca
Branch: refs/heads/docker-grouping-merge
Commit: fcd8a7ca407a5653d7a0a4fbae2a1958e214873b
Parents: ff315c9
Author: Isuru Haththotuwa <is...@apache.org>
Authored: Wed Oct 29 15:20:58 2014 +0530
Committer: Isuru Haththotuwa <is...@apache.org>
Committed: Wed Oct 29 15:20:58 2014 +0530
----------------------------------------------------------------------
.../stratos/autoscaler/monitor/cluster/LbClusterMonitor.java | 5 +++++
1 file changed, 5 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/stratos/blob/fcd8a7ca/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/LbClusterMonitor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/LbClusterMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/LbClusterMonitor.java
index cc21205..6697d73 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/LbClusterMonitor.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/LbClusterMonitor.java
@@ -24,6 +24,7 @@ import org.apache.stratos.autoscaler.NetworkPartitionContext;
import org.apache.stratos.autoscaler.PartitionContext;
import org.apache.stratos.autoscaler.deployment.policy.DeploymentPolicy;
import org.apache.stratos.autoscaler.monitor.AbstractClusterMonitor;
+import org.apache.stratos.autoscaler.monitor.events.MonitorStatusEvent;
import org.apache.stratos.autoscaler.policy.model.AutoscalePolicy;
import org.apache.stratos.autoscaler.rule.AutoscalerRuleEvaluator;
import org.apache.stratos.messaging.domain.topology.ClusterStatus;
@@ -121,4 +122,8 @@ public class LbClusterMonitor extends AbstractClusterMonitor {
}
+ @Override
+ public void onParentEvent(MonitorStatusEvent statusEvent) {
+
+ }
}
[16/50] [abbrv] git commit: fixing wrongly used topology events and
fixing issue while inactivation of group and cluster
Posted by im...@apache.org.
fixing wrongly used topology events and fixing issue while inactivation of group and cluster
Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/d7d226cb
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/d7d226cb
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/d7d226cb
Branch: refs/heads/docker-grouping-merge
Commit: d7d226cb5e0c81b0f0629e8f1c843611b3cb6784
Parents: 4f6b5fe
Author: reka <rt...@gmail.com>
Authored: Tue Oct 28 00:08:46 2014 +0530
Committer: reka <rt...@gmail.com>
Committed: Tue Oct 28 00:08:46 2014 +0530
----------------------------------------------------------------------
.../grouping/dependency/DependencyTree.java | 1 +
.../stratos/autoscaler/monitor/Monitor.java | 11 ++++
.../monitor/ParentComponentMonitor.java | 57 ++++++++++++++------
.../autoscaler/monitor/group/GroupMonitor.java | 9 +++-
.../ApplicationStatusTopicReceiver.java | 8 +++
...tatusApplicationCreatedMessageProcessor.java | 8 +--
...StatusClusterTerminatedMessageProcessor.java | 5 +-
7 files changed, 73 insertions(+), 26 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/stratos/blob/d7d226cb/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/DependencyTree.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/DependencyTree.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/DependencyTree.java
index 48ba7b7..1ec686b 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/DependencyTree.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/DependencyTree.java
@@ -195,6 +195,7 @@ public class DependencyTree {
if (this.killDependent) {
//finding the ApplicationContext of the given id
//finding all the children of the found application context
+ allChildrenOfAppContext.add(applicationContext);
findAllChildrenOfAppContext(applicationContext.getApplicationContextList(),
allChildrenOfAppContext);
return allChildrenOfAppContext;
http://git-wip-us.apache.org/repos/asf/stratos/blob/d7d226cb/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/Monitor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/Monitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/Monitor.java
index b1e2eb3..2088351 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/Monitor.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/Monitor.java
@@ -93,4 +93,15 @@ public abstract class Monitor implements EventHandler {
public void setHasDependent(boolean hasDependent) {
this.hasDependent = hasDependent;
}
+
+ public boolean hasInDependentChild() {
+ boolean hasInDepChild = false;
+ for(Monitor monitor : this.aliasToActiveMonitorsMap.values()) {
+ if(!monitor.isDependent()) {
+ hasInDepChild = true;
+ break;
+ }
+ }
+ return hasInDepChild;
+ }
}
http://git-wip-us.apache.org/repos/asf/stratos/blob/d7d226cb/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ParentComponentMonitor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ParentComponentMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ParentComponentMonitor.java
index 4eb4bcb..9f3417d 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ParentComponentMonitor.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ParentComponentMonitor.java
@@ -30,6 +30,7 @@ import org.apache.stratos.autoscaler.grouping.dependency.context.ApplicationCont
import org.apache.stratos.autoscaler.grouping.topic.StatusEventPublisher;
import org.apache.stratos.autoscaler.monitor.events.MonitorStatusEvent;
import org.apache.stratos.autoscaler.status.checker.StatusChecker;
+import org.apache.stratos.messaging.domain.topology.GroupStatus;
import org.apache.stratos.messaging.domain.topology.ParentComponent;
import java.util.HashMap;
@@ -114,30 +115,52 @@ public abstract class ParentComponentMonitor extends Monitor {
protected void onChildInActiveEvent(String idOfEvent) {
List<ApplicationContext> terminationList;
Monitor monitor;
- terminationList = this.dependencyTree.getTerminationDependencies(idOfEvent);
//Temporarily move the group/cluster to inactive list
this.aliasToInActiveMonitorsMap.put(idOfEvent, this.aliasToActiveMonitorsMap.remove(idOfEvent));
- if (terminationList != null) {
- //Checking the termination dependents status
- for (ApplicationContext terminationContext : terminationList) {
- //Check whether dependent is in_active, then start to kill it
- monitor = this.aliasToActiveMonitorsMap.
- get(terminationContext.getId());
- //start to kill it
- if (monitor.hasActiveMonitors()) {
- //it is a group
- StatusEventPublisher.sendGroupTerminatingEvent(this.appId, terminationContext.getId());
- } else {
- StatusEventPublisher.sendClusterTerminatingEvent(this.appId,
- ((AbstractClusterMonitor) monitor).getServiceId(), terminationContext.getId());
+ if(this.hasDependent) {
+ //need to notify the parent
+ StatusChecker.getInstance().onChildStatusChange(idOfEvent, this.id, this.appId);
+ } else {
+ terminationList = this.dependencyTree.getTerminationDependencies(idOfEvent);
+ if(this.hasInDependentChild()) {
+ if(this.parent != null) {
+ StatusEventPublisher.sendGroupInActivateEvent(this.appId, this.id);
+ } /*else {
+ StatusEventPublisher.sendApplicationInactivatedEvent(this.appId, terminationContext.getId());
+
+ }*/
+
+ }
+
+ if (terminationList != null) {
+ //Checking the termination dependents status
+ for (ApplicationContext terminationContext : terminationList) {
+ //Check whether dependent is in_active, then start to kill it
+ monitor = this.aliasToActiveMonitorsMap.
+ get(terminationContext.getId());
+ //start to kill it
+ if(monitor != null) {
+ if (monitor.hasActiveMonitors()) {
+ //it is a group
+ StatusEventPublisher.sendGroupTerminatingEvent(this.appId, terminationContext.getId());
+ } else {
+ StatusEventPublisher.sendClusterTerminatingEvent(this.appId,
+ ((AbstractClusterMonitor) monitor).getServiceId(), terminationContext.getId());
+
+ }
+ } else {
+ log.warn("The relevant [monitor] " + terminationContext.getId() +
+ "is not in the active map....");
+ }
}
+ } else {
+ log.warn("Wrong inActive event received from [Child] " + idOfEvent + " to the [parent]"
+ + " where child is identified as a independent");
}
- } else {
- log.warn("Wrong inActive event received from [Child] " + idOfEvent + " to the [parent]"
- + " where child is identified as a independent");
}
+
}
protected void onChildTerminatedEvent(String idOfEvent) {
http://git-wip-us.apache.org/repos/asf/stratos/blob/d7d226cb/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java
index 161d9b4..3123782 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java
@@ -95,7 +95,7 @@ public class GroupMonitor extends ParentComponentMonitor implements EventHandler
//Check whether all dependent goes Terminated and then start them in parallel.
this.aliasToInActiveMonitorsMap.remove(id);
if (this.status != GroupStatus.Terminating && !this.aliasToInActiveMonitorsMap.isEmpty() &&
- !this.aliasToActiveMonitorsMap.isEmpty()) {
+ !this.aliasToActiveMonitorsMap.isEmpty()) {
onChildTerminatedEvent(id);
} else {
StatusChecker.getInstance().onChildStatusChange(id, this.id, this.appId);
@@ -143,6 +143,11 @@ public class GroupMonitor extends ParentComponentMonitor implements EventHandler
"on its state change from %s to %s", id, this.status, status));
this.status = status;
//notifying the parent
- MonitorStatusEventBuilder.handleGroupStatusEvent(this.parent, this.status, this.id);
+ if (status == GroupStatus.Inactive && !this.hasDependent) {
+ log.info("[Group] " + this.id + "is not notifying the parent, " +
+ "since it is identified as the independent unit");
+ } else {
+ MonitorStatusEventBuilder.handleGroupStatusEvent(this.parent, this.status, this.id);
+ }
}
}
http://git-wip-us.apache.org/repos/asf/stratos/blob/d7d226cb/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/status/receiver/ApplicationStatusTopicReceiver.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/status/receiver/ApplicationStatusTopicReceiver.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/status/receiver/ApplicationStatusTopicReceiver.java
index ca93dce..4d52fce 100644
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/status/receiver/ApplicationStatusTopicReceiver.java
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/status/receiver/ApplicationStatusTopicReceiver.java
@@ -116,6 +116,14 @@ public class ApplicationStatusTopicReceiver implements Runnable {
}
});
+ statusEventReceiver.addEventListener(new AppStatusGroupInactivateEventListener() {
+ @Override
+ protected void onEvent(Event event) {
+ TopologyBuilder.handleGroupInActiveEvent((AppStatusGroupInactivateEvent) event);
+
+ }
+ });
+
statusEventReceiver.addEventListener(new AppStatusApplicationActivatedEventListener() {
@Override
http://git-wip-us.apache.org/repos/asf/stratos/blob/d7d226cb/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusApplicationCreatedMessageProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusApplicationCreatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusApplicationCreatedMessageProcessor.java
index 4e2f97f..29fce0a 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusApplicationCreatedMessageProcessor.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusApplicationCreatedMessageProcessor.java
@@ -20,7 +20,7 @@ package org.apache.stratos.messaging.message.processor.application.status;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.messaging.event.topology.ApplicationCreatedEvent;
+import org.apache.stratos.messaging.event.application.status.AppStatusApplicationCreatedEvent;
import org.apache.stratos.messaging.message.processor.MessageProcessor;
import org.apache.stratos.messaging.util.Util;
@@ -39,10 +39,10 @@ public class AppStatusApplicationCreatedMessageProcessor extends MessageProcesso
@Override
public boolean process(String type, String message, Object object) {
- if (ApplicationCreatedEvent.class.getName().equals(type)) {
+ if (AppStatusApplicationCreatedEvent.class.getName().equals(type)) {
// Parse complete message and build event
- ApplicationCreatedEvent event =
- (ApplicationCreatedEvent) Util.jsonToObject(message, ApplicationCreatedEvent.class);
+ AppStatusApplicationCreatedEvent event =
+ (AppStatusApplicationCreatedEvent) Util.jsonToObject(message, AppStatusApplicationCreatedEvent.class);
if (log.isDebugEnabled()) {
log.debug("Received ApplicationCreated Event in application status topic: " + event.toString());
http://git-wip-us.apache.org/repos/asf/stratos/blob/d7d226cb/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusClusterTerminatedMessageProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusClusterTerminatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusClusterTerminatedMessageProcessor.java
index 6cdde51..55cec80 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusClusterTerminatedMessageProcessor.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusClusterTerminatedMessageProcessor.java
@@ -21,7 +21,6 @@ package org.apache.stratos.messaging.message.processor.application.status;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.stratos.messaging.event.application.status.AppStatusClusterTerminatedEvent;
-import org.apache.stratos.messaging.event.topology.ClusterTerminatedEvent;
import org.apache.stratos.messaging.message.processor.MessageProcessor;
import org.apache.stratos.messaging.util.Util;
@@ -40,9 +39,9 @@ public class AppStatusClusterTerminatedMessageProcessor extends MessageProcessor
if (AppStatusClusterTerminatedEvent.class.getName().equals(type)) {
// Parse complete message and build event
AppStatusClusterTerminatedEvent event = (AppStatusClusterTerminatedEvent) Util.
- jsonToObject(message, AppStatusClusterTerminatedEvent.class);
+ jsonToObject(message, AppStatusClusterTerminatedEvent.class);
- if(log.isDebugEnabled()) {
+ if (log.isDebugEnabled()) {
log.debug("Received AppStatusClusterTerminatedEvent: " + event.toString());
}
// Notify event listeners
[20/50] [abbrv] git commit: correcting wrong state transition in
GroupTerminatingProcessor
Posted by im...@apache.org.
correcting wrong state transition in GroupTerminatingProcessor
Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/dd210b59
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/dd210b59
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/dd210b59
Branch: refs/heads/docker-grouping-merge
Commit: dd210b59206a445e8ae3fef8f97f937012dd528c
Parents: c95377f
Author: Isuru Haththotuwa <is...@apache.org>
Authored: Tue Oct 28 11:05:11 2014 +0530
Committer: Isuru Haththotuwa <is...@apache.org>
Committed: Tue Oct 28 11:05:11 2014 +0530
----------------------------------------------------------------------
.../message/processor/topology/GroupTerminatingProcessor.java | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/stratos/blob/dd210b59/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupTerminatingProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupTerminatingProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupTerminatingProcessor.java
index 210279c..ecf6873 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupTerminatingProcessor.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupTerminatingProcessor.java
@@ -93,8 +93,8 @@ public class GroupTerminatingProcessor extends MessageProcessor {
}
} else {
// Apply changes to the topology
- if (!group.isStateTransitionValid(GroupStatus.Active)) {
- log.error("Invalid State Transition from " + group.getStatus() + " to " + GroupStatus.Active);
+ if (!group.isStateTransitionValid(GroupStatus.Terminating)) {
+ log.error("Invalid State Transition from " + group.getStatus() + " to " + GroupStatus.Terminating);
}
group.setStatus(GroupStatus.Terminating);
[25/50] [abbrv] git commit: delete application from metadata service
when app is undeployed
Posted by im...@apache.org.
delete application from metadata service when app is undeployed
Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/19530324
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/19530324
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/19530324
Branch: refs/heads/docker-grouping-merge
Commit: 195303244312d60cb83a1e0d7a0c44f221d05014
Parents: c947820
Author: Udara Liyanage <ud...@wso2.com>
Authored: Tue Oct 28 16:31:31 2014 +0530
Committer: Udara Liyanage <ud...@wso2.com>
Committed: Tue Oct 28 16:31:31 2014 +0530
----------------------------------------------------------------------
.../controller/topology/TopologyBuilder.java | 23 +++++++++++++-------
.../topology/GroupTerminatingProcessor.java | 2 +-
2 files changed, 16 insertions(+), 9 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/stratos/blob/19530324/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java
index e715130..fac6671 100644
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java
@@ -31,19 +31,13 @@ import org.apache.stratos.cloud.controller.runtime.FasterLookUpDataHolder;
import org.apache.stratos.cloud.controller.util.CloudControllerUtil;
import org.apache.stratos.messaging.domain.topology.*;
import org.apache.stratos.messaging.event.application.status.*;
-import org.apache.stratos.messaging.event.application.status.AppStatusApplicationActivatedEvent;
-import org.apache.stratos.messaging.event.application.status.AppStatusApplicationCreatedEvent;
-import org.apache.stratos.messaging.event.application.status.AppStatusApplicationInactivatedEvent;
-import org.apache.stratos.messaging.event.application.status.AppStatusApplicationTerminatedEvent;
-import org.apache.stratos.messaging.event.application.status.AppStatusApplicationTerminatingEvent;
-import org.apache.stratos.messaging.event.application.status.AppStatusClusterActivatedEvent;
-import org.apache.stratos.messaging.event.application.status.AppStatusGroupActivatedEvent;
-import org.apache.stratos.messaging.event.application.status.AppStatusGroupInactivateEvent;
import org.apache.stratos.messaging.event.instance.status.InstanceActivatedEvent;
import org.apache.stratos.messaging.event.instance.status.InstanceMaintenanceModeEvent;
import org.apache.stratos.messaging.event.instance.status.InstanceReadyToShutdownEvent;
import org.apache.stratos.messaging.event.instance.status.InstanceStartedEvent;
import org.apache.stratos.messaging.event.topology.*;
+import org.apache.stratos.metadata.client.defaults.DefaultMetaDataServiceClient;
+import org.apache.stratos.metadata.client.defaults.MetaDataServiceClient;
import org.wso2.carbon.registry.core.exceptions.RegistryException;
import java.util.*;
@@ -939,10 +933,14 @@ public class TopologyBuilder {
}
}
+
+
// remove application
topology.removeApplication(event.getAppId());
TopologyManager.updateTopology(topology);
+ deleteAppResourcesFromMetadataService(event);
+
log.info("Removed application [ " + event.getAppId() + " ] from Topology");
TopologyEventPublisher.sendApplicationTerminatedEvent(new ApplicationTerminatedEvent(event.getAppId(),
@@ -954,6 +952,15 @@ public class TopologyBuilder {
}
}
+ private static void deleteAppResourcesFromMetadataService(AppStatusApplicationTerminatedEvent event) {
+ try {
+ MetaDataServiceClient metadataClient = new DefaultMetaDataServiceClient();
+ metadataClient.deleteApplicationProperties(event.getAppId());
+ } catch (Exception e) {
+ log.error("Error occurred while deleting the application resources frm metadata service " , e);
+ }
+ }
+
public static void handleGroupInActiveEvent(AppStatusGroupInactivateEvent event) {
Topology topology = TopologyManager.getTopology();
Application application = topology.getApplication(event.getAppId());
http://git-wip-us.apache.org/repos/asf/stratos/blob/19530324/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupTerminatingProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupTerminatingProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupTerminatingProcessor.java
index ecf6873..27b5cff 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupTerminatingProcessor.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupTerminatingProcessor.java
@@ -94,7 +94,7 @@ public class GroupTerminatingProcessor extends MessageProcessor {
} else {
// Apply changes to the topology
if (!group.isStateTransitionValid(GroupStatus.Terminating)) {
- log.error("Invalid State Transition from " + group.getStatus() + " to " + GroupStatus.Terminating);
+ log.error("Invalid State Transition from " + group.getStatus() + " to " + GroupStatus.Active);
}
group.setStatus(GroupStatus.Terminating);
[39/50] [abbrv] git commit: refactoring current undeployment logic in
Autoscaler
Posted by im...@apache.org.
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/docker-grouping-merge
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());
+// }
}
});
[48/50] [abbrv] Merge branch '4.0.0-grouping' into
docker-grouping-merge
Posted by im...@apache.org.
http://git-wip-us.apache.org/repos/asf/stratos/blob/17cc86eb/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyEventPublisher.java
----------------------------------------------------------------------
diff --cc components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyEventPublisher.java
index 4a48a13,a3feb4d..7ac8334
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyEventPublisher.java
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyEventPublisher.java
@@@ -30,231 -26,295 +29,362 @@@ import org.apache.stratos.cloud.control
import org.apache.stratos.cloud.controller.util.CloudControllerUtil;
import org.apache.stratos.messaging.broker.publish.EventPublisher;
import org.apache.stratos.messaging.broker.publish.EventPublisherPool;
-import org.apache.stratos.messaging.domain.topology.*;
+import org.apache.stratos.messaging.domain.topology.Cluster;
+import org.apache.stratos.messaging.domain.topology.ClusterStatus;
+import org.apache.stratos.messaging.domain.topology.Port;
+import org.apache.stratos.messaging.domain.topology.ServiceType;
+import org.apache.stratos.messaging.domain.topology.Topology;
import org.apache.stratos.messaging.event.Event;
import org.apache.stratos.messaging.event.instance.status.InstanceStartedEvent;
-import org.apache.stratos.messaging.event.topology.*;
-import org.apache.stratos.messaging.util.Constants;
+import org.apache.stratos.messaging.event.topology.ClusterCreatedEvent;
+import org.apache.stratos.messaging.event.topology.ClusterMaintenanceModeEvent;
+import org.apache.stratos.messaging.event.topology.ClusterRemovedEvent;
+import org.apache.stratos.messaging.event.topology.CompleteTopologyEvent;
+import org.apache.stratos.messaging.event.topology.InstanceSpawnedEvent;
+import org.apache.stratos.messaging.event.topology.MemberActivatedEvent;
+import org.apache.stratos.messaging.event.topology.MemberMaintenanceModeEvent;
+import org.apache.stratos.messaging.event.topology.MemberReadyToShutdownEvent;
+import org.apache.stratos.messaging.event.topology.MemberStartedEvent;
+import org.apache.stratos.messaging.event.topology.MemberTerminatedEvent;
+import org.apache.stratos.messaging.event.topology.ServiceCreatedEvent;
+import org.apache.stratos.messaging.event.topology.ServiceRemovedEvent;
+import org.apache.stratos.messaging.util.Util;
+ import java.util.List;
+ import java.util.Properties;
+ import java.util.Set;
+
/**
* this is to send the relevant events from cloud controller to topology topic
*/
public class TopologyEventPublisher {
- private static final Log log = LogFactory.getLog(TopologyEventPublisher.class);
-
-
- public static void sendServiceCreateEvent(List<Cartridge> cartridgeList) {
- ServiceCreatedEvent serviceCreatedEvent;
- for(Cartridge cartridge : cartridgeList) {
- serviceCreatedEvent = new ServiceCreatedEvent(cartridge.getType(), (cartridge.isMultiTenant() ? ServiceType.MultiTenant : ServiceType.SingleTenant));
-
- // Add ports to the event
- Port port;
- List<PortMapping> portMappings = cartridge.getPortMappings();
- for(PortMapping portMapping : portMappings) {
- port = new Port(portMapping.getProtocol(),
- Integer.parseInt(portMapping.getPort()),
- Integer.parseInt(portMapping.getProxyPort()));
- serviceCreatedEvent.addPort(port);
- }
-
- if(log.isInfoEnabled()) {
- log.info(String.format("Publishing service created event: [service] %s", cartridge.getType()));
- }
- publishEvent(serviceCreatedEvent);
- }
- }
-
- public static void sendServiceRemovedEvent(List<Cartridge> cartridgeList) {
- ServiceRemovedEvent serviceRemovedEvent;
- for(Cartridge cartridge : cartridgeList) {
- serviceRemovedEvent = new ServiceRemovedEvent(cartridge.getType());
- if(log.isInfoEnabled()) {
- log.info(String.format("Publishing service removed event: [service] %s", serviceRemovedEvent.getServiceName()));
- }
- publishEvent(serviceRemovedEvent);
- }
- }
-
- public static void sendClusterCreatedEvent(String appId, String serviceName, String clusterId) {
- ClusterCreatedEvent clusterCreatedEvent = new ClusterCreatedEvent(appId,serviceName, clusterId);
-
- if(log.isInfoEnabled()) {
- log.info("Publishing cluster created event: " +clusterId);
- }
- publishEvent(clusterCreatedEvent);
- }
+ private static final Log log = LogFactory
+ .getLog(TopologyEventPublisher.class);
+
+ public static void sendServiceCreateEvent(List<Cartridge> cartridgeList) {
+ ServiceCreatedEvent serviceCreatedEvent;
+ for (Cartridge cartridge : cartridgeList) {
+ serviceCreatedEvent = new ServiceCreatedEvent(cartridge.getType(),
+ (cartridge.isMultiTenant() ? ServiceType.MultiTenant
+ : ServiceType.SingleTenant));
+
+ // Add ports to the event
+ Port port;
+ List<PortMapping> portMappings = cartridge.getPortMappings();
+ for (PortMapping portMapping : portMappings) {
+ port = new Port(portMapping.getProtocol(),
+ Integer.parseInt(portMapping.getPort()),
+ Integer.parseInt(portMapping.getProxyPort()));
+ serviceCreatedEvent.addPort(port);
+ }
+
+ if (log.isInfoEnabled()) {
+ log.info(String.format(
+ "Publishing service created event: [service] %s",
+ cartridge.getType()));
+ }
+ publishEvent(serviceCreatedEvent);
+ }
+ }
+
+ public static void sendServiceRemovedEvent(List<Cartridge> cartridgeList) {
+ ServiceRemovedEvent serviceRemovedEvent;
+ for (Cartridge cartridge : cartridgeList) {
+ serviceRemovedEvent = new ServiceRemovedEvent(cartridge.getType());
+ if (log.isInfoEnabled()) {
+ log.info(String.format(
+ "Publishing service removed event: [service] %s",
+ serviceRemovedEvent.getServiceName()));
+ }
+ publishEvent(serviceRemovedEvent);
+ }
+ }
+
+ public static void sendClusterCreatedEvent(String serviceName,
+ String clusterId, Cluster cluster) {
+ ClusterCreatedEvent clusterCreatedEvent = new ClusterCreatedEvent(
+ serviceName, clusterId, cluster);
+
+ if (log.isInfoEnabled()) {
+ log.info("Publishing cluster created event: " + cluster.toString());
+ }
+ publishEvent(clusterCreatedEvent);
-
+ }
- public static void sendClusterRemovedEvent(ClusterContext ctxt,
- String deploymentPolicy) {
+ public static void sendApplicationCreatedEvent (ApplicationCreatedEvent applicationCreatedEvent) {
+
+ if(log.isInfoEnabled()) {
+ log.info("Publishing Application created event: " + applicationCreatedEvent.toString());
+ }
+
+ publishEvent(applicationCreatedEvent);
+ }
- ClusterRemovedEvent clusterRemovedEvent = new ClusterRemovedEvent(
- ctxt.getCartridgeType(), ctxt.getClusterId(), deploymentPolicy,
- ctxt.isLbCluster());
+ public static void sendApplicationUndeployedEvent (String applicationId, Set<ClusterDataHolder> clusterData) {
+
+ if (log.isInfoEnabled()) {
+ log.info("Publishing Application undeployed event for Application: " + applicationId);
+ }
+
+ publishEvent(new ApplicationUndeployedEvent(applicationId, clusterData));
+ }
+
+ // public static void sendApplicationRemovedEvent(String applicationId, Set<ClusterDataHolder> clusterData,
+ // int tenantId, String tenantDomain) {
+ //
+ // if(log.isInfoEnabled() || log.isDebugEnabled()) {
+ // log.info("Publishing Application removed event: " + applicationId + " tenantId: " + tenantId);
+ // }
+ //
+ // publishEvent(new ApplicationRemovedEvent(applicationId, clusterData, tenantId, tenantDomain));
+ // }
+
+ public static void sendClusterRemovedEvent(ClusterContext ctxt, String deploymentPolicy) {
- ClusterRemovedEvent clusterRemovedEvent = new ClusterRemovedEvent(ctxt.getCartridgeType(), ctxt.getClusterId(), deploymentPolicy, ctxt.isLbCluster());
-
- if(log.isInfoEnabled()) {
- log.info(String.format("Publishing cluster removed event: [service] %s [cluster] %s", ctxt.getCartridgeType(), ctxt.getClusterId()));
- }
- publishEvent(clusterRemovedEvent);
-
- }
+ if (log.isInfoEnabled()) {
+ log.info(String
+ .format("Publishing cluster removed event: [service] %s [cluster] %s",
+ ctxt.getCartridgeType(), ctxt.getClusterId()));
+ }
+ publishEvent(clusterRemovedEvent);
+
+ }
+
+ public static void sendClusterMaintenanceModeEvent(ClusterContext ctxt) {
+
+ ClusterMaintenanceModeEvent clusterMaintenanceModeEvent = new ClusterMaintenanceModeEvent(
+ ctxt.getCartridgeType(), ctxt.getClusterId());
+ clusterMaintenanceModeEvent.setStatus(ClusterStatus.In_Maintenance);
+ if (log.isInfoEnabled()) {
+ log.info(String
+ .format("Publishing cluster maintenance mode event: [service] %s [cluster] %s",
+ clusterMaintenanceModeEvent.getServiceName(),
+ clusterMaintenanceModeEvent.getClusterId()));
+ }
+ publishEvent(clusterMaintenanceModeEvent);
+
+ }
+
+ public static void sendInstanceSpawnedEvent(String serviceName,
+ String clusterId, String networkPartitionId, String partitionId,
+ String memberId, String lbClusterId, String publicIp,
+ String privateIp, MemberContext context) {
+
+ long initTime = context.getInitTime();
+ InstanceSpawnedEvent instanceSpawnedEvent = new InstanceSpawnedEvent(
+ serviceName, clusterId, networkPartitionId, partitionId,
+ memberId, initTime);
+ instanceSpawnedEvent.setLbClusterId(lbClusterId);
+ instanceSpawnedEvent.setMemberIp(privateIp);
+ instanceSpawnedEvent.setMemberPublicIp(publicIp);
+ instanceSpawnedEvent.setProperties(CloudControllerUtil
+ .toJavaUtilProperties(context.getProperties()));
+ if (log.isInfoEnabled()) {
+ log.info(String
+ .format("Publishing instance spawned event: [service] %s [cluster] %s [network-partition] %s [partition] %s [member] %s [lb-cluster-id] %s [properties] %s",
+ serviceName, clusterId, networkPartitionId,
+ partitionId, memberId, lbClusterId, context.getProperties()));
+ }
+ publishEvent(instanceSpawnedEvent);
+ }
- public static void sendMemberStartedEvent(
- InstanceStartedEvent instanceStartedEvent) {
- MemberStartedEvent memberStartedEventTopology = new MemberStartedEvent(
- instanceStartedEvent.getServiceName(),
- instanceStartedEvent.getClusterId(),
- instanceStartedEvent.getNetworkPartitionId(),
- instanceStartedEvent.getPartitionId(),
- instanceStartedEvent.getMemberId());
+ public static void sendInstanceSpawnedEvent(String serviceName, String clusterId, String networkPartitionId, String partitionId, String memberId,
+ String lbClusterId, String publicIp, String privateIp, MemberContext context) {
+ InstanceSpawnedEvent instanceSpawnedEvent = new InstanceSpawnedEvent(serviceName, clusterId, networkPartitionId, partitionId, memberId);
+ instanceSpawnedEvent.setLbClusterId(lbClusterId);
+ instanceSpawnedEvent.setMemberIp(privateIp);
+ instanceSpawnedEvent.setMemberPublicIp(publicIp);
+ instanceSpawnedEvent.setProperties(CloudControllerUtil.toJavaUtilProperties(context.getProperties()));
+ if(log.isInfoEnabled()) {
+ log.info(String.format("Publishing instance spawned event: [service] %s [cluster] %s [network-partition] %s [partition] %s [member] %s [lb-cluster-id] %s",
+ serviceName, clusterId, networkPartitionId, partitionId, memberId, lbClusterId));
+ }
+ publishEvent(instanceSpawnedEvent);
+ }
+ public static void sendMemberStartedEvent(InstanceStartedEvent instanceStartedEvent) {
+ MemberStartedEvent memberStartedEventTopology = new MemberStartedEvent(instanceStartedEvent.getServiceName(),
+ instanceStartedEvent.getClusterId(), instanceStartedEvent.getNetworkPartitionId(), instanceStartedEvent.getPartitionId(), instanceStartedEvent.getMemberId());
-
- // grouping
- memberStartedEventTopology.setGroupId(instanceStartedEvent.getGroupId());
- if(log.isInfoEnabled()) {
- log.info(" Grouping member started event - adding groupID " + instanceStartedEvent.getGroupId() + " for cluster " +
- instanceStartedEvent.getClusterId());
- }
-
- if(log.isInfoEnabled()) {
- log.info(String.format("Publishing member started event: [service] %s [cluster] %s [network-partition] %s [partition] %s [member] %s [groupId] %s",
- memberStartedEventTopology.getServiceName(), memberStartedEventTopology.getClusterId(), memberStartedEventTopology.getNetworkPartitionId(),
- memberStartedEventTopology.getPartitionId(), memberStartedEventTopology.getMemberId(), memberStartedEventTopology.getGroupId()));
- }
-
- publishEvent(memberStartedEventTopology);
- }
-
- public static void sendMemberActivatedEvent(MemberActivatedEvent memberActivatedEvent) {
- if(log.isInfoEnabled()) {
- log.info(String.format("Publishing member activated event: [service] %s [cluster] %s [network-partition] %s [partition] %s [member] %s [groupId] %s",
- memberActivatedEvent.getServiceName(), memberActivatedEvent.getClusterId(), memberActivatedEvent.getNetworkPartitionId(),
- memberActivatedEvent.getPartitionId(), memberActivatedEvent.getMemberId(), memberActivatedEvent.getGroupId()));
- }
- publishEvent(memberActivatedEvent);
- }
+ if (log.isInfoEnabled()) {
+ log.info(String
+ .format("Publishing member started event: [service] %s [cluster] %s [network-partition] %s [partition] %s [member] %s",
+ instanceStartedEvent.getServiceName(),
+ instanceStartedEvent.getClusterId(),
+ instanceStartedEvent.getNetworkPartitionId(),
+ instanceStartedEvent.getPartitionId(),
+ instanceStartedEvent.getMemberId()));
+ }
+ publishEvent(memberStartedEventTopology);
+ }
+
+ public static void sendMemberActivatedEvent(
+ MemberActivatedEvent memberActivatedEvent) {
+ if (log.isInfoEnabled()) {
+ log.info(String
+ .format("Publishing member activated event: [service] %s [cluster] %s [network-partition] %s [partition] %s [member] %s",
+ memberActivatedEvent.getServiceName(),
+ memberActivatedEvent.getClusterId(),
+ memberActivatedEvent.getNetworkPartitionId(),
+ memberActivatedEvent.getPartitionId(),
+ memberActivatedEvent.getMemberId()));
+ }
+ publishEvent(memberActivatedEvent);
+ }
- public static void sendMemberReadyToShutdownEvent(
- MemberReadyToShutdownEvent memberReadyToShutdownEvent) {
- if (log.isInfoEnabled()) {
- log.info(String
- .format("Publishing member Ready to shut down event: [service] %s [cluster] %s [network-partition] %s [partition] %s [member] %s",
- memberReadyToShutdownEvent.getServiceName(),
- memberReadyToShutdownEvent.getClusterId(),
- memberReadyToShutdownEvent.getNetworkPartitionId(),
- memberReadyToShutdownEvent.getPartitionId(),
- memberReadyToShutdownEvent.getMemberId()));
- }
- publishEvent(memberReadyToShutdownEvent);
- }
+ public static void sendMemberReadyToShutdownEvent(MemberReadyToShutdownEvent memberReadyToShutdownEvent) {
+ if(log.isInfoEnabled()) {
+ log.info(String.format("Publishing member Ready to shut down event: [service] %s [cluster] %s [network-partition] %s [partition] %s [member] %s [groupId] %s",
+ memberReadyToShutdownEvent.getServiceName(), memberReadyToShutdownEvent.getClusterId(), memberReadyToShutdownEvent.getNetworkPartitionId(),
+ memberReadyToShutdownEvent.getPartitionId(), memberReadyToShutdownEvent.getMemberId(), memberReadyToShutdownEvent.getGroupId()));
+ }
+ // grouping
+ memberReadyToShutdownEvent.setGroupId(memberReadyToShutdownEvent.getGroupId());
+ publishEvent(memberReadyToShutdownEvent);
+ }
- public static void sendMemberMaintenanceModeEvent(
- MemberMaintenanceModeEvent memberMaintenanceModeEvent) {
- if (log.isInfoEnabled()) {
- log.info(String
- .format("Publishing Maintenance mode event: [service] %s [cluster] %s [network-partition] %s [partition] %s [member] %s",
- memberMaintenanceModeEvent.getServiceName(),
- memberMaintenanceModeEvent.getClusterId(),
- memberMaintenanceModeEvent.getNetworkPartitionId(),
- memberMaintenanceModeEvent.getPartitionId(),
- memberMaintenanceModeEvent.getMemberId()));
- }
- publishEvent(memberMaintenanceModeEvent);
- }
+ public static void sendMemberMaintenanceModeEvent(MemberMaintenanceModeEvent memberMaintenanceModeEvent) {
+ if(log.isInfoEnabled()) {
+ log.info(String.format("Publishing Maintenance mode event: [service] %s [cluster] %s [network-partition] %s [partition] %s [member] %s [groupId] %s",
+ memberMaintenanceModeEvent.getServiceName(), memberMaintenanceModeEvent.getClusterId(), memberMaintenanceModeEvent.getNetworkPartitionId(),
+ memberMaintenanceModeEvent.getPartitionId(), memberMaintenanceModeEvent.getMemberId(), memberMaintenanceModeEvent.getGroupId()));
+ }
- public static void sendMemberTerminatedEvent(String serviceName,
- String clusterId, String networkPartitionId, String partitionId,
- String memberId, Properties properties) {
- MemberTerminatedEvent memberTerminatedEvent = new MemberTerminatedEvent(
- serviceName, clusterId, networkPartitionId, partitionId,
- memberId);
- memberTerminatedEvent.setProperties(properties);
- if (log.isInfoEnabled()) {
- log.info(String
- .format("Publishing member terminated event: [service] %s [cluster] %s [network-partition] %s [partition] %s [member] %s",
- serviceName, clusterId, networkPartitionId,
- partitionId, memberId));
- }
- publishEvent(memberTerminatedEvent);
- }
+ publishEvent(memberMaintenanceModeEvent);
+ }
- public static void sendCompleteTopologyEvent(Topology topology) {
- CompleteTopologyEvent completeTopologyEvent = new CompleteTopologyEvent(
- topology);
+ public static void sendGroupActivatedEvent(GroupActivatedEvent groupActivatedEvent) {
+ if(log.isInfoEnabled()) {
+ log.info(String.format("Publishing group activated event: [appId] %s [group] %s",
+ groupActivatedEvent.getAppId(), groupActivatedEvent.getGroupId()));
+ }
+ publishEvent(groupActivatedEvent);
+ }
- if (log.isDebugEnabled()) {
- log.debug(String.format("Publishing complete topology event"));
- }
- publishEvent(completeTopologyEvent);
- }
+ public static void sendClusterActivatedEvent(ClusterActivatedEvent clusterActivatedEvent) {
+ if(log.isInfoEnabled()) {
+ log.info(String.format("Publishing cluster activated event: [service] %s [cluster] %s [appId] %s",
+ clusterActivatedEvent.getServiceName(), clusterActivatedEvent.getClusterId() , clusterActivatedEvent.getAppId()));
+ }
+ publishEvent(clusterActivatedEvent);
+ }
+
+ public static void sendClusterInActivateEvent(ClusterInactivateEvent clusterInActiveEvent) {
+ if(log.isInfoEnabled()) {
+ log.info(String.format("Publishing cluster in-active event: [service] %s [cluster] %s [appId] %s",
+ clusterInActiveEvent.getServiceName(), clusterInActiveEvent.getClusterId() , clusterInActiveEvent.getAppId()));
+ }
+ publishEvent(clusterInActiveEvent);
+ }
+
+
+ public static void sendMemberTerminatedEvent(String serviceName, String clusterId, String networkPartitionId,
+ String partitionId, String memberId, Properties properties, String groupId) {
+ MemberTerminatedEvent memberTerminatedEvent = new MemberTerminatedEvent(serviceName, clusterId, networkPartitionId, partitionId, memberId);
+ memberTerminatedEvent.setProperties(properties);
+ memberTerminatedEvent.setGroupId(groupId);
+
+ if(log.isInfoEnabled()) {
+ log.info(String.format("Publishing member terminated event: [service] %s [cluster] %s [network-partition] %s [partition] %s [member] %s [groupId] %s", serviceName, clusterId, networkPartitionId,
+ partitionId, memberId, groupId));
+ }
+
+ publishEvent(memberTerminatedEvent);
+ }
+
+ public static void sendCompleteTopologyEvent(Topology topology) {
+ CompleteTopologyEvent completeTopologyEvent = new CompleteTopologyEvent(topology);
+
+ if(log.isDebugEnabled()) {
+ log.debug(String.format("Publishing complete topology event"));
+ }
+ publishEvent(completeTopologyEvent);
+ }
+
+ public static void sendApplicationActivatedEvent(ApplicationActivatedEvent applicationActivatedEvent) {
+ if(log.isInfoEnabled()) {
+ log.info(String.format("Publishing application activated event: [appId] %s",
+ applicationActivatedEvent.getAppId()));
+ }
+ publishEvent(applicationActivatedEvent);
+ }
+
+ public static void publishEvent(Event event) {
+ EventPublisher eventPublisher = EventPublisherPool.getPublisher(Constants.TOPOLOGY_TOPIC);
+ eventPublisher.publish(event);
+ }
+
+ public static void sendApplicationInactivatedEvent(ApplicationInactivatedEvent applicationActivatedEvent1) {
+ if(log.isInfoEnabled()) {
+ log.info(String.format("Publishing application in activated event: [appId] %s",
+ applicationActivatedEvent1.getAppId()));
+ }
+ publishEvent(applicationActivatedEvent1);
+ }
+
+ public static void sendApplicationTerminatingEvent(ApplicationTerminatingEvent applicationTerminatingEvent) {
+ if(log.isInfoEnabled()) {
+ log.info(String.format("Publishing application terminating event: [appId] %s",
+ applicationTerminatingEvent.getAppId()));
+ }
+ publishEvent(applicationTerminatingEvent);
+ }
+
+ public static void sendApplicationTerminatedEvent(ApplicationTerminatedEvent applicationTerminatedEvent) {
+ if(log.isInfoEnabled()) {
+ log.info(String.format("Publishing application terminated event: [appId] %s",
+ applicationTerminatedEvent.getAppId()));
+ }
+ publishEvent(applicationTerminatedEvent);
+ }
+
+ public static void sendGroupInActiveEvent(GroupInactivateEvent groupInActivateEvent) {
+ if(log.isInfoEnabled()) {
+ log.info(String.format("Publishing group in-active event: [appId] %s",
+ groupInActivateEvent.getAppId()));
+ }
+ publishEvent(groupInActivateEvent);
+ }
+
+
+ public static void sendGroupTerminatedEvent(GroupTerminatedEvent groupTerminatedTopologyEvent) {
+ if(log.isInfoEnabled()) {
+ log.info(String.format("Publishing group terminated event: [appId] %s",
+ groupTerminatedTopologyEvent.getAppId()));
+ }
+ publishEvent(groupTerminatedTopologyEvent);
+ }
+
+ public static void sendGroupTerminatingEvent(GroupTerminatingEvent groupTerminatingTopologyEvent) {
+ if(log.isInfoEnabled()) {
+ log.info(String.format("Publishing group terminating event: [appId] %s",
+ groupTerminatingTopologyEvent.getAppId()));
+ }
+ publishEvent(groupTerminatingTopologyEvent);
+ }
+
+ public static void sendClusterTerminatingEvent (ClusterTerminatingEvent clusterTerminatingEvent) {
+
+ if(log.isInfoEnabled()) {
+ log.info(String.format("Publishing Cluster terminating event: [appId] %s [cluster id] %s",
+ clusterTerminatingEvent.getAppId(), clusterTerminatingEvent.getClusterId()));
+ }
+
+ publishEvent(clusterTerminatingEvent);
+ }
+
+ public static void sendClusterTerminatedEvent (ClusterTerminatedEvent clusterTerminatedEvent) {
+
+ if(log.isInfoEnabled()) {
+ log.info(String.format("Publishing Cluster terminated event: [appId] %s [cluster id] %s",
+ clusterTerminatedEvent.getAppId(), clusterTerminatedEvent.getClusterId()));
+ }
+ publishEvent(clusterTerminatedEvent);
+ }
-}
++
+ public static void publishEvent(Event event) {
+ String topic = Util.getMessageTopicName(event);
+ EventPublisher eventPublisher = EventPublisherPool.getPublisher(topic);
+ eventPublisher.publish(event);
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/17cc86eb/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/util/CloudControllerUtil.java
----------------------------------------------------------------------
diff --cc components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/util/CloudControllerUtil.java
index fe2493d,0ad8488..5cea0b7
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/util/CloudControllerUtil.java
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/util/CloudControllerUtil.java
@@@ -161,12 -159,11 +161,16 @@@ public class CloudControllerUtil
}
}
}
+
+ // populate container
+ if(config.getContainer() != null) {
+ cartridge.setContainer(config.getContainer());
+ }
+ if(config.getExportingProperties() != null){
+ cartridge.setExportingProperties(config.getExportingProperties());
+ }
+
return cartridge;
}
http://git-wip-us.apache.org/repos/asf/stratos/blob/17cc86eb/components/org.apache.stratos.load.balancer/src/main/java/org/apache/stratos/load/balancer/conf/LoadBalancerConfiguration.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/stratos/blob/17cc86eb/components/org.apache.stratos.manager.console/console/util/utility.jag
----------------------------------------------------------------------
diff --cc components/org.apache.stratos.manager.console/console/util/utility.jag
index 916f265,083b330..c75c209
--- a/components/org.apache.stratos.manager.console/console/util/utility.jag
+++ b/components/org.apache.stratos.manager.console/console/util/utility.jag
@@@ -321,20 -321,14 +321,31 @@@ consoleAppUtil = new function()
if (response.xhr.status >= 200 && response.xhr.status < 300) { //if success
session.put("get-status", "succeeded");
+ } else if (response.xhr.status >= 300 && response.xhr.status < 400) { //if redirects
+ if(response.data != null && response.data != undefined) {
+ session.put("get-status", parse(response.data).Error.errorMessage);
+ }
+ } else if (response.xhr.status >= 400 && response.xhr.status < 500) { //if client error
+ if(response.data != null && response.data != undefined) {
+ session.put("get-status", parse(response.data).Error.errorMessage);
+ }
+ } else if (response.xhr.status >= 500 && response.xhr.status < 600) { //if server error
+ if(response.data != null && response.data != undefined) {
+ session.put("get-status", parse(response.data).Error.errorMessage);
+ }
+ } else {
+ session.put("get-status", "Unknown response!");
++
++ if (response.xhr.status >= 200 && response.xhr.status < 300) { //if success
++ session.put("get-status", "succeeded");
+ } else if (response.xhr.status >= 400 && response.xhr.status < 500) { //if client error
+ if(response.data != null && response.data != undefined) {
+ session.put("get-status", parse(response.data).Error.errorMessage);
+ }
+ } else if (response.xhr.status >= 500 && response.xhr.status < 600) { //if server error
+ if(response.data != null && response.data != undefined) {
+ session.put("get-status", response.data); return;
+ }
}
log.debug("sent is: " + stringify(response));
@@@ -401,20 -395,14 +412,30 @@@
if (response.xhr.status >= 200 && response.xhr.status < 300) { //if success
session.put("deploy-status", "succeeded");
+ } else if (response.xhr.status >= 300 && response.xhr.status < 400) { //if redirects
+ if(response.data != null && response.data != undefined) {
+ session.put("deploy-status", parse(response.data).Error.errorMessage);
+ }
+ } else if (response.xhr.status >= 400 && response.xhr.status < 500) { //if client error
+ if(response.data != null && response.data != undefined) {
+ session.put("deploy-status", parse(response.data).Error.errorMessage);
+ }
+ } else if (response.xhr.status >= 500 && response.xhr.status < 600) { //if server error
+ if(response.data != null && response.data != undefined) {
+ session.put("deploy-status", parse(response.data).Error.errorMessage);
+ }
+ } else {
+ session.put("deploy-status", "Unknown response!");
++ if (response.xhr.status >= 200 && response.xhr.status < 300) { //if success
++ session.put("deploy-status", "succeeded");
+ } else if (response.xhr.status >= 400 && response.xhr.status < 500) { //if client error
+ if(response.data != null && response.data != undefined) {
+ session.put("deploy-status", parse(response.data).Error.errorMessage);
+ }
+ } else if (response.xhr.status >= 500 && response.xhr.status < 600) { //if server error
+ if(response.data != null && response.data != undefined) {
+ session.put("deploy-status", response.data); return;
+ }
}
log.debug("sent is: " + stringify(response));
http://git-wip-us.apache.org/repos/asf/stratos/blob/17cc86eb/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/internal/ADCManagementServerComponent.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/stratos/blob/17cc86eb/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/manager/CartridgeSubscriptionManager.java
----------------------------------------------------------------------
diff --cc components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/manager/CartridgeSubscriptionManager.java
index 539c983,0dd09a5..eedd1e5
--- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/manager/CartridgeSubscriptionManager.java
+++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/manager/CartridgeSubscriptionManager.java
@@@ -35,13 -37,8 +37,10 @@@ import org.apache.stratos.manager.lb.ca
import org.apache.stratos.manager.repository.Repository;
import org.apache.stratos.manager.retriever.DataInsertionAndRetrievalManager;
import org.apache.stratos.manager.subscriber.Subscriber;
- import org.apache.stratos.manager.subscription.CartridgeSubscription;
- import org.apache.stratos.manager.subscription.PersistenceContext;
- import org.apache.stratos.manager.subscription.SubscriptionData;
- import org.apache.stratos.manager.subscription.SubscriptionDomain;
+ import org.apache.stratos.manager.subscription.*;
import org.apache.stratos.manager.subscription.factory.CartridgeSubscriptionFactory;
+import org.apache.stratos.manager.subscription.filter.LBCreationSubscriptionFilter;
+import org.apache.stratos.manager.subscription.filter.SubscriptionFilter;
import org.apache.stratos.manager.subscription.tenancy.SubscriptionMultiTenantBehaviour;
import org.apache.stratos.manager.subscription.tenancy.SubscriptionSingleTenantBehaviour;
import org.apache.stratos.manager.subscription.tenancy.SubscriptionTenancyBehaviour;
@@@ -69,14 -66,202 +69,209 @@@ import java.util.*
public class CartridgeSubscriptionManager {
private static Log log = LogFactory.getLog(CartridgeSubscriptionManager.class);
+ //private static DataInsertionAndRetrievalManager dataInsertionAndRetrievalManager = new DataInsertionAndRetrievalManager();
+
+ public GroupSubscription createGroupSubscription (String groupName, String groupAlias, int tenantId)
+ throws GroupSubscriptionException {
+
+ DataInsertionAndRetrievalManager dataInsertionAndRetrievalMgr = new DataInsertionAndRetrievalManager();
+ GroupSubscription groupSubscription;
+
+ try {
+ groupSubscription = dataInsertionAndRetrievalMgr.getGroupSubscription(tenantId, groupName, groupAlias);
+
+ } catch (PersistenceManagerException e) {
+ throw new GroupSubscriptionException(e);
+ }
+
+ if (groupSubscription != null) {
+ // Group Subscription already exists with same Group name and alias
+ throw new GroupSubscriptionException("Group Subscription already exists with name [ " + groupName + " ], alias [ " + groupAlias + " ]");
+ }
+
+ return new GroupSubscription(groupName, groupAlias);
+ }
+
+ public ApplicationSubscription createApplicationSubscription (String appId, int tenantId) throws ApplicationSubscriptionException {
+
+ if (log.isDebugEnabled()) {
+ log.debug("create Application Subscription for appId: " + appId + " and tenantId: " + tenantId);
+ }
+
+ DataInsertionAndRetrievalManager dataInsertionAndRetrievalMgr = new DataInsertionAndRetrievalManager();
+ ApplicationSubscription appSubscription;
+
+ try {
+ appSubscription = dataInsertionAndRetrievalMgr.getApplicationSubscription(tenantId, appId);
+
+ } catch (PersistenceManagerException e) {
+ log.error("failed to retrieve application Subscription for appId: " + appId + " and tenantId: " + tenantId + " e:" + e);
+ throw new ApplicationSubscriptionException(e);
+ }
+
+ if (appSubscription != null) {
+ // Composite App Subscription already exists with same app id
+ log.error("app Id already exists, failed to createappSubscription for appId: " + appId + " and tenantId: " + tenantId);
+ throw new ApplicationSubscriptionException("Composite App Subscription already exists with Id [ " + appId + " ]");
+ } else {
+
+ if (log.isDebugEnabled()) {
+ log.debug("creating new application subscription for app:" + appId );
+ }
+
+ appSubscription = new ApplicationSubscription(appId);
+ // persist
+ try {
+ this.persistApplicationSubscription(appSubscription);
+ } catch (ADCException e) {
+ // TODO Auto-generated catch block
+ log.error("Failed to persist applicaiton subscription for appId: " + appId +
+ " and tenantId: " + tenantId + " e:" + e);
+ }
+ }
+
+ return new ApplicationSubscription(appId);
+ }
+
+ public void removeApplicationSubscription (String appId, int tenantId) throws ApplicationSubscriptionException {
+
+ if (log.isDebugEnabled()) {
+ log.debug("remove Application Subscription for appId: " + appId + " and tenantId: " + tenantId);
+ }
+
+ DataInsertionAndRetrievalManager dataInsertionAndRetrievalMgr = new DataInsertionAndRetrievalManager();
+ ApplicationSubscription appSubscription = null;
+
+ try {
+ appSubscription = dataInsertionAndRetrievalMgr.getApplicationSubscription(tenantId, appId);
+
+ } catch (PersistenceManagerException e) {
+ log.error("failed to retrieve Application Subscription for appId: " + appId + " and tenantId: " + tenantId + "with exception:" + e);
+ throw new ApplicationSubscriptionException(e);
+ }
+
+ if (appSubscription != null) {
+
+ try {
+ dataInsertionAndRetrievalMgr.removeApplicationSubscription(tenantId, appId);
+ } catch (PersistenceManagerException e) {
+ log.error("failed to remove Application Subscription for appId: " + appId + " and tenantId: " + tenantId + " with exception:" + e);
+ throw new ApplicationSubscriptionException(e);
+ }
+
+ if (log.isDebugEnabled()) {
+ log.debug("successfully removed Application Subscription for appId: " + appId + " and tenantId: " + tenantId);
+ }
+
+ }
+ }
+
+ public ApplicationSubscription getApplicationSubscription (String appId, int tenantId) throws ApplicationSubscriptionException {
+ if (log.isDebugEnabled()) {
+ log.debug("get Application Subscription for appId: " + appId + " and tenantId: " + tenantId);
+ }
+
+ DataInsertionAndRetrievalManager dataInsertionAndRetrievalMgr = new DataInsertionAndRetrievalManager();
+ ApplicationSubscription appSubscription = null;
+
+ try {
+ appSubscription = dataInsertionAndRetrievalMgr.getApplicationSubscription(tenantId, appId);
+
+ } catch (PersistenceManagerException e) {
+ log.error("failed to Application Subscription for appId: " + appId + " and tenantId: " + tenantId + " e:" + e);
+ throw new ApplicationSubscriptionException(e);
+ }
+
+ return appSubscription;
+ }
+
+ public CartridgeSubscription createCartridgeSubscription (SubscriptionData subscriptionData) throws ADCException,
+ InvalidCartridgeAliasException, DuplicateCartridgeAliasException, PolicyException, UnregisteredCartridgeException,
+ RepositoryRequiredException, RepositoryCredentialsRequiredException, RepositoryTransportException,
+ AlreadySubscribedException, InvalidRepositoryException {
+
+
+ CartridgeSubscriptionUtils.validateCartridgeAlias(subscriptionData.getTenantId(), subscriptionData.getCartridgeType(), subscriptionData.getCartridgeAlias());
+
+ CartridgeInfo cartridgeInfo;
+ try {
+ cartridgeInfo = CloudControllerServiceClient.getServiceClient().getCartridgeInfo(subscriptionData.getCartridgeType());
+
+ } catch (CloudControllerServiceUnregisteredCartridgeExceptionException e) {
+ String message = subscriptionData.getCartridgeType() + " is not a valid cartridgeSubscription type. Please try again with a valid cartridgeSubscription type.";
+ log.error(message);
+ throw new ADCException(message, e);
+
+ } catch (Exception e) {
+ String message = "Error getting info for " + subscriptionData.getCartridgeType();
+ log.error(message, e);
+ throw new ADCException(message, e);
+ }
+
+ // subscribe to relevant service cartridge
+ CartridgeSubscription serviceCartridgeSubscription = subscribe (subscriptionData, cartridgeInfo, null);
+
+ return serviceCartridgeSubscription;
+ }
+
+ public void persistCartridgeSubscription (CartridgeSubscription cartridgeSubscription) throws ADCException {
+
+ try {
+ new DataInsertionAndRetrievalManager().cacheAndPersistSubcription(cartridgeSubscription);
+
+ } catch (PersistenceManagerException e) {
+ String errorMsg = "Error saving subscription for tenant " +
+ cartridgeSubscription.getSubscriber().getTenantDomain() + ", alias " + cartridgeSubscription.getType();
+ log.error(errorMsg);
+ throw new ADCException(errorMsg, e);
+ }
+
+ log.info("Successful Subscription: " + cartridgeSubscription.toString());
+
+ // Publish tenant subscribed event to message broker
+ Set<String> clusterIds = new HashSet<String>();
+ clusterIds.add(cartridgeSubscription.getCluster().getClusterDomain());
+ CartridgeSubscriptionUtils.publishTenantSubscribedEvent(cartridgeSubscription.getSubscriber().getTenantId(),
+ cartridgeSubscription.getCartridgeInfo().getType(), clusterIds);
+ }
+
+ public void persistGroupSubscription (GroupSubscription groupSubscription) throws ADCException {
+
+ try {
+ new DataInsertionAndRetrievalManager().persistGroupSubscription(groupSubscription);
+
+ } catch (PersistenceManagerException e) {
+ throw new ADCException(e);
+ }
+ }
+
+ public void persistApplicationSubscription (ApplicationSubscription compositeAppSubscription) throws ADCException {
+
+ try {
+ new DataInsertionAndRetrievalManager().persistApplicationSubscription(compositeAppSubscription);
+
+ } catch (PersistenceManagerException e) {
+ throw new ADCException(e);
+ }
+ }
+ public SubscriptionInfo subscribeToCartridgeWithProperties(SubscriptionData subscriptionData) throws ADCException,
+ InvalidCartridgeAliasException,
+ DuplicateCartridgeAliasException,
+ PolicyException,
+ UnregisteredCartridgeException,
+ RepositoryRequiredException,
+ RepositoryCredentialsRequiredException,
+ RepositoryTransportException,
+ AlreadySubscribedException,
+ InvalidRepositoryException {
+ /**
+ *
+ * @param subscriptionData
+ * @return
+ * @throws Exception since the caller doesn't react upon specific exceptions, simply throw Generic Exception class.
+ */
+ public static SubscriptionInfo subscribeToCartridgeWithProperties(SubscriptionData subscriptionData) throws Exception {
// validate cartridge alias
CartridgeSubscriptionUtils.validateCartridgeAlias(subscriptionData.getTenantId(), subscriptionData.getCartridgeType(), subscriptionData.getCartridgeAlias());
http://git-wip-us.apache.org/repos/asf/stratos/blob/17cc86eb/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/subscription/utils/CartridgeSubscriptionUtils.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/stratos/blob/17cc86eb/components/org.apache.stratos.messaging/pom.xml
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/stratos/blob/17cc86eb/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Cluster.java
----------------------------------------------------------------------
diff --cc components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Cluster.java
index 9d6b301,1f69fd6..97b4d99
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Cluster.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Cluster.java
@@@ -204,21 -209,53 +210,57 @@@ public class Cluster implements Seriali
return partitionIds.keySet();
}
+ @Override
+ public boolean isStateTransitionValid(ClusterStatus newState) {
+ return clusterStateManager.isStateTransitionValid(newState);
+ }
+
+ @Override
+ public Stack<ClusterStatus> getTransitionedStates() {
+ return clusterStateManager.getStateStack();
+ }
+
public ClusterStatus getStatus() {
- return status;
+ //return status;
+ return clusterStateManager.getCurrentState();
}
+ public void setStatus(ClusterStatus status) {
+ this.status = status;
+ }
+
- @Override
- public String toString() {
- return "Cluster [serviceName=" + serviceName + ", clusterId=" + clusterId + ", autoscalePolicyName="
- + autoscalePolicyName + ", deploymentPolicyName=" + deploymentPolicyName + ", hostNames=" + hostNames
- + ", tenantRange=" + tenantRange + ", isLbCluster=" + isLbCluster + ", isKubernetesCluster="
- + isKubernetesCluster + ", memberMap=" + memberMap + ", status=" + status
- + ", loadBalanceAlgorithmName=" + loadBalanceAlgorithmName + ", properties=" + properties + "]";
+ public void setStatus(ClusterStatus newStatus) {
+ clusterStateManager.changeState(newStatus);
+ //this.status = newStatus;
}
+
+ public boolean equals(Object other) {
+ if (other == null || !(other instanceof Cluster)) {
+ return false;
+ }
+
+ if (this == other) {
+ return true;
+ }
+
+ Cluster that = (Cluster) other;
+ return this.clusterId.equals(that.clusterId);
+ }
+
+ public int hashCode() {
+ return clusterId.hashCode();
+ }
+
+ public String getAppId() {
+ return appId;
+ }
+
+ // public ClusterStatus getTempStatus() {
+ // return status;
+ // }
+ //
+ // public void setTempStatus(ClusterStatus status) {
+ // this.status = status;
+ // }
}
http://git-wip-us.apache.org/repos/asf/stratos/blob/17cc86eb/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Member.java
----------------------------------------------------------------------
diff --cc components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Member.java
index 70872c5,fbab2f6..989f079
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Member.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Member.java
@@@ -50,15 -49,16 +50,17 @@@ public class Member implements Serializ
@XmlJavaTypeAdapter(MapAdapter.class)
private Properties properties;
private String lbClusterId;
+ private LifeCycleStateManager<MemberStatus> memberStateManager;
- public Member(String serviceName, String clusterId, String networkPartitionId, String partitionId, String memberId) {
+ public Member(String serviceName, String clusterId, String networkPartitionId, String partitionId, String memberId, long initTime) {
this.serviceName = serviceName;
this.clusterId = clusterId;
this.networkPartitionId = networkPartitionId;
this.partitionId = partitionId;
this.memberId = memberId;
this.portMap = new HashMap<Integer, Port>();
+ this.initTime = initTime;
+ this.memberStateManager = new LifeCycleStateManager<MemberStatus>(MemberStatus.Created, memberId);
}
public String getServiceName() {
@@@ -72,21 -72,28 +74,33 @@@
public String getMemberId() {
return memberId;
}
+
+ public long getInitTime() {
+ return initTime;
+ }
+
+
+ @Override
+ public boolean isStateTransitionValid(MemberStatus newState) {
+ return memberStateManager.isStateTransitionValid(newState);
+ }
+
+ @Override
public MemberStatus getStatus() {
- return status;
+ return memberStateManager.getCurrentState();
+ }
+
+ public Stack<MemberStatus> getTransitionedStates () {
+ return memberStateManager.getStateStack();
}
- public void setStatus(MemberStatus status) {
- this.status = status;
+ @Override
+ public void setStatus(MemberStatus newState) {
+ this.memberStateManager.changeState(newState);
}
- public boolean isActive() {
- return (this.status == MemberStatus.Activated);
+ public boolean isActive () {
+ return memberStateManager.getCurrentState().equals(MemberStatus.Activated);
}
public Collection<Port> getPorts() {
http://git-wip-us.apache.org/repos/asf/stratos/blob/17cc86eb/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/MemberMaintenanceModeEvent.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/stratos/blob/17cc86eb/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/util/Constants.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/stratos/blob/17cc86eb/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/util/Util.java
----------------------------------------------------------------------
diff --cc components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/util/Util.java
index 168ebe3,48905f3..c458f77
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/util/Util.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/util/Util.java
@@@ -57,120 -56,102 +63,126 @@@ public class Util
return props;
}
- /**
- * Validate tenant range.
- * Valid formats: Integer-Integer, Integer-*
- * Examples: 1-100, 101-200, 201-*
- * @param tenantRange
- */
- public static void validateTenantRange(String tenantRange) {
- boolean valid = false;
- if(tenantRange != null) {
- if(tenantRange.equals("*")) {
- valid = true;
- } else {
- String[] array = tenantRange.split(Constants.TENANT_RANGE_DELIMITER);
- if(array.length == 2) {
- // Integer-Integer
- if(isNumber(array[0]) && (isNumber(array[1]))){
- valid = true;
- }
- // Integer-*
- else if(isNumber(array[0]) && "*".equals(array[1])) {
- valid = true;
- }
- }
- }
+ /**
+ * Validate tenant range.
+ * Valid formats: Integer-Integer, Integer-*
+ * Examples: 1-100, 101-200, 201-*
+ *
+ * @param tenantRange
+ */
+ public static void validateTenantRange(String tenantRange) {
+ boolean valid = false;
+ if (tenantRange != null) {
+ if (tenantRange.equals("*")) {
+ valid = true;
+ } else {
+ String[] array = tenantRange.split(Constants.TENANT_RANGE_DELIMITER);
+ if (array.length == 2) {
+ // Integer-Integer
+ if (isNumber(array[0]) && (isNumber(array[1]))) {
+ valid = true;
+ }
+ // Integer-*
+ else if (isNumber(array[0]) && "*".equals(array[1])) {
+ valid = true;
+ }
+ }
+ }
- }
- if(!valid)
- throw new RuntimeException(String.format("Tenant range %s is not valid", tenantRange));
- }
+ }
+ if (!valid)
+ throw new RuntimeException(String.format("Tenant range %s is not valid", tenantRange));
+ }
- public static boolean isNumber(String s) {
- try {
- Integer.parseInt(s);
- return true;
- } catch (NumberFormatException e) {
- // Not a valid number
- }
- return false;
- }
-
- /**
- * Transform json into an object of given type.
- *
- * @param json
- * @param type
- * @return
- */
- public static Object jsonToObject(String json, Class type) {
- return (new JsonMessage(json, type)).getObject();
- }
+ public static boolean isNumber(String s) {
+ try {
+ Integer.parseInt(s);
+ return true;
+ }
+ catch (NumberFormatException e) {
+ // Not a valid number
+ }
+ return false;
+ }
+
+ /**
+ * Transform json into an object of given type.
+ * @param json
+ * @param type
+ * @return
+ */
+ public static Object jsonToObject(String json, Class type) {
+ return (new JsonMessage(json, type)).getObject();
+ }
+
+ public static String ObjectToJson(Object obj) {
+ Gson gson = new Gson();
+ String result = gson.toJson(obj);
+ return result;
+ }
+ // Time interval between each ping message sent to topic.
+ private static int averagePingInterval;
+
+ // Time interval between each ping message after an error had occurred.
+ private static int failoverPingInterval;
+
+ /**
+ * fetch value from system param
+ *
+ * @return
+ */
+ public static int getAveragePingInterval() {
+ if (averagePingInterval <= 0) {
+ averagePingInterval =
+ Util.getNumericSystemProperty(Constants.DEFAULT_AVERAGE_PING_INTERVAL,
+ Constants.AVERAGE_PING_INTERVAL_PROPERTY);
+ }
+ return averagePingInterval;
+ }
- // Time interval between each ping message sent to topic.
- private static int averagePingInterval;
+ /**
+ * fetch value from system param
+ *
+ * @return
+ */
+ public static int getFailoverPingInterval() {
+ if (failoverPingInterval <= 0) {
+ failoverPingInterval =
+ Util.getNumericSystemProperty(Constants.DEFAULT_FAILOVER_PING_INTERVAL,
+ Constants.FAILOVER_PING_INTERVAL_PROPERTY);
+ }
+ return failoverPingInterval;
+ }
- // Time interval between each ping message after an error had occurred.
- private static int failoverPingInterval;
+ /**
+ * Method to safely access numeric system properties
+ *
+ * @param defaultValue
+ * @return
+ */
+ public static Integer getNumericSystemProperty(Integer defaultValue, String propertyKey) {
+ try {
+ return Integer.valueOf(System.getProperty(propertyKey));
+ } catch (NumberFormatException ex) {
+ return defaultValue;
+ }
+ }
- /**
- * fetch value from system param
- * @return
- */
- public static int getAveragePingInterval() {
- if (averagePingInterval <= 0) {
- averagePingInterval = Util.getNumericSystemProperty(Constants.DEFAULT_AVERAGE_PING_INTERVAL,Constants.AVERAGE_PING_INTERVAL_PROPERTY);
- }
- return averagePingInterval;
- }
+ public static String getMessageTopicName(Event event) {
+ return event.getClass().getName().substring(BEGIN_INDEX).replace(".", "/");
+ }
- /**
- * fetch value from system param
- * @return
- */
- public static int getFailoverPingInterval() {
- if (failoverPingInterval <= 0) {
- failoverPingInterval = Util.getNumericSystemProperty(Constants.DEFAULT_FAILOVER_PING_INTERVAL,Constants.FAILOVER_PING_INTERVAL_PROPERTY);
- }
- return failoverPingInterval;
- }
+ public static String getEventNameForTopic(String arg0) {
+ return "org.apache.stratos.messaging.event.".concat(arg0.replace("/", "."));
+ }
- /**
- * Method to safely access numeric system properties
- * @param defaultValue
- * @return
- */
- public static Integer getNumericSystemProperty(Integer defaultValue, String propertyKey) {
- try {
- return Integer.valueOf(System.getProperty(propertyKey));
- } catch (NumberFormatException ex) {
- return defaultValue;
- }
- }
+ public static String getRandomString(int len) {
+ String AB = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
+ Random rnd = new Random();
+ StringBuilder sb = new StringBuilder(len);
+ for (int i = 0; i < len; i++)
+ sb.append(AB.charAt(rnd.nextInt(AB.length())));
+ return sb.toString();
+ }
}
http://git-wip-us.apache.org/repos/asf/stratos/blob/17cc86eb/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/cartridge/definition/CartridgeDefinitionBean.java
----------------------------------------------------------------------
diff --cc components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/cartridge/definition/CartridgeDefinitionBean.java
index c69659e,2a99610..56dbfcf
--- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/cartridge/definition/CartridgeDefinitionBean.java
+++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/cartridge/definition/CartridgeDefinitionBean.java
@@@ -59,17 -57,16 +59,20 @@@ public class CartridgeDefinitionBean
public String defaultDeploymentPolicy;
public String serviceGroup;
+
+ public ContainerBean container;
+
+ public String deployerType;
+ private String[] exportingProperties;
+
public String toString () {
return "Type: " + type + ", Provider: " + provider + ", Host: " + host + ", Display Name: " + displayName +
- ", Description: " + description + ", Version: " + version + ", Multitenant " + multiTenant + "\n" +
+ ", Description: " + description + ", Version: " + version + ", Multitenant " + multiTenant +", Public " + isPublic + "\n" +
getDeploymentDetails() + "\n PortMapping: " + getPortMappings() + "\n IaaS: " + getIaasProviders() +
- "\n LoadBalancer: " + getLoadBalancerInfo() + "\n Properties: " + getProperties() +"\n VolumeBean mappings "+ persistence.toString();
+ "\n LoadBalancer: " + getLoadBalancerInfo() + "\n Properties: " + getProperties() +"\n VolumeBean mappings "+ persistence.toString()
+ + "\n Exports " + exportingProperties.toString();
}
private String getDeploymentDetails () {
http://git-wip-us.apache.org/repos/asf/stratos/blob/17cc86eb/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/topology/Cluster.java
----------------------------------------------------------------------
diff --cc components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/topology/Cluster.java
index e7de37a,f2e5d73..e8a30f9
--- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/topology/Cluster.java
+++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/topology/Cluster.java
@@@ -19,13 -19,19 +19,13 @@@
package org.apache.stratos.rest.endpoint.bean.topology;
import javax.xml.bind.annotation.XmlRootElement;
+import org.apache.stratos.rest.endpoint.bean.cartridge.definition.PropertyBean;
+
import java.util.List;
- @XmlRootElement
+ @XmlRootElement(name="clusters")
public class Cluster {
- @Override
- public String toString() {
- return "Cluster [serviceName=" + serviceName + ", clusterId="
- + clusterId + ", member=" + member + ", tenantRange="
- + tenantRange + ", hostNames=" + hostNames + ", isLbCluster="
- + isLbCluster + "]";
- }
-
public String serviceName;
public String clusterId;
http://git-wip-us.apache.org/repos/asf/stratos/blob/17cc86eb/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/util/converter/PojoConverter.java
----------------------------------------------------------------------
diff --cc components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/util/converter/PojoConverter.java
index 40cc88d,cc3ae4a..871078f
--- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/util/converter/PojoConverter.java
+++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/util/converter/PojoConverter.java
@@@ -20,12 -20,23 +20,25 @@@
package org.apache.stratos.rest.endpoint.bean.util.converter;
import org.apache.commons.lang.StringUtils;
+import org.apache.stratos.autoscaler.stub.kubernetes.PropertiesE;
+import org.apache.stratos.autoscaler.stub.kubernetes.PropertyE;
+ import org.apache.commons.logging.Log;
+ import org.apache.commons.logging.LogFactory;
import org.apache.stratos.cloud.controller.stub.pojo.*;
+ import org.apache.stratos.cloud.controller.stub.pojo.application.*;
+ import org.apache.stratos.manager.composite.application.beans.ApplicationDefinition;
+ import org.apache.stratos.manager.composite.application.beans.GroupDefinition;
+ import org.apache.stratos.manager.composite.application.beans.SubscribableDefinition;
+ import org.apache.stratos.manager.composite.application.beans.SubscribableInfo;
import org.apache.stratos.manager.deploy.service.Service;
+ import org.apache.stratos.manager.grouping.definitions.DependencyDefinitions;
+ import org.apache.stratos.manager.grouping.definitions.ServiceGroupDefinition;
import org.apache.stratos.manager.subscription.SubscriptionDomain;
+ import org.apache.stratos.messaging.domain.topology.Application;
import org.apache.stratos.messaging.domain.topology.Cluster;
+ import org.apache.stratos.messaging.domain.topology.Group;
+ import org.apache.stratos.rest.endpoint.bean.ApplicationBean;
+ import org.apache.stratos.rest.endpoint.bean.GroupBean;
import org.apache.stratos.rest.endpoint.bean.autoscaler.partition.Partition;
import org.apache.stratos.rest.endpoint.bean.autoscaler.partition.PartitionGroup;
import org.apache.stratos.rest.endpoint.bean.autoscaler.policy.autoscale.*;
@@@ -95,23 -99,23 +108,36 @@@ public class PojoConverter
cartridgeConfig.setProperties(getProperties(cartridgeDefinitionBean.property));
}
+ if(cartridgeDefinitionBean.getExportingProperties() != null)
+ {
+ cartridgeConfig.setExportingProperties(cartridgeDefinitionBean.getExportingProperties());
+ }
+
+ if (cartridgeDefinitionBean.container != null) {
+ cartridgeConfig.setContainer(getContainer(cartridgeDefinitionBean.container));
+ }
+
return cartridgeConfig;
}
+
+ public static ServiceGroup populateServiceGroupPojo (ServiceGroupDefinition serviceGroupDefinition ) {
+ ServiceGroup servicegroup = new ServiceGroup();
+
+ // implement conversion (mostly List -> Array)
+
+ return servicegroup;
+ }
- private static LoadbalancerConfig getLBConfig(LoadBalancerBean loadBalancer) {
+
+ private static Container getContainer(ContainerBean container) {
+ Container cn = new Container();
+ cn.setDockerFileRepo(container.dockerfileRepo);
+ cn.setImageName(container.imageName);
+ //cn.setProperties(getProperties(container.property));
+ return cn;
+ }
+
+ private static LoadbalancerConfig getLBConfig(LoadBalancerBean loadBalancer) {
LoadbalancerConfig lbConfig = new LoadbalancerConfig();
lbConfig.setType(loadBalancer.type);
if (loadBalancer.property != null && !loadBalancer.property.isEmpty()) {
@@@ -170,13 -174,14 +196,17 @@@
return iaasConfigsArray;
}
+ public static Persistence getPersistence(PersistenceBean persistenceBean) {
+ public static Persistence getPersistence(PersistenceBean persistenceBean) {
+
Persistence persistence = new Persistence();
persistence.setPersistanceRequired(persistenceBean.isRequired);
VolumeBean[] volumeBean = new VolumeBean[persistenceBean.volume.size()];
persistenceBean.volume.toArray(volumeBean);
+ Volume[] volumes = new Volume[persistenceBean.volume.size()];
+ for (int i = 0; i < volumes.length; i++) {
+ Volume[] volumes = new Volume[persistenceBean.volume.size()];
+ for (int i = 0 ; i < volumes.length ; i++) {
Volume volume = new Volume();
volume.setId(volumeBean[i].id);
volume.setVolumeId(volumeBean[i].volumeId);
@@@ -694,171 -674,141 +724,305 @@@
for (Service service : services) {
serviceDefinitionBeans.add(convertToServiceDefinitionBean(service));
}
-
return serviceDefinitionBeans;
}
+
+ public static org.apache.stratos.autoscaler.stub.kubernetes.KubernetesGroup convertToASKubernetesGroupPojo(KubernetesGroup kubernetesGroupBean) {
+
+ org.apache.stratos.autoscaler.stub.kubernetes.KubernetesGroup kubernetesGroup = new
+ org.apache.stratos.autoscaler.stub.kubernetes.KubernetesGroup();
+
+ kubernetesGroup.setGroupId(kubernetesGroupBean.getGroupId());
+ kubernetesGroup.setDescription(kubernetesGroupBean.getDescription());
+ kubernetesGroup.setKubernetesMaster(convertToASKubernetesMasterPojo(kubernetesGroupBean.getKubernetesMaster()));
+ kubernetesGroup.setPortRange(convertToASPortRange(kubernetesGroupBean.getPortRange()));
+ kubernetesGroup.setKubernetesHosts(convertToASKubernetesHostsPojo(kubernetesGroupBean.getKubernetesHosts()));
+ kubernetesGroup.setProperties((getASProperties(kubernetesGroupBean.getProperty())));
+
+ return kubernetesGroup;
+ }
+
+ private static org.apache.stratos.autoscaler.stub.kubernetes.KubernetesHost[] convertToASKubernetesHostsPojo(List<KubernetesHost> kubernetesHosts) {
+ if (kubernetesHosts == null || kubernetesHosts.isEmpty()) {
+ return null;
+ }
+ int kubernetesHostCount = kubernetesHosts.size();
+ org.apache.stratos.autoscaler.stub.kubernetes.KubernetesHost[]
+ kubernetesHostsArr = new org.apache.stratos.autoscaler.stub.kubernetes.KubernetesHost[kubernetesHostCount];
+ for (int i = 0; i < kubernetesHostCount; i++) {
+ KubernetesHost kubernetesHostBean = kubernetesHosts.get(i);
+ kubernetesHostsArr[i] = convertToASKubernetesHostPojo(kubernetesHostBean);
+ }
+ return kubernetesHostsArr;
+ }
+
+
+ private static org.apache.stratos.autoscaler.stub.kubernetes.PortRange convertToASPortRange(PortRange portRangeBean) {
+ if (portRangeBean == null) {
+ return null;
+ }
+ org.apache.stratos.autoscaler.stub.kubernetes.PortRange
+ portRange = new org.apache.stratos.autoscaler.stub.kubernetes.PortRange();
+ portRange.setLower(portRangeBean.getLower());
+ portRange.setUpper(portRangeBean.getUpper());
+ return portRange;
+ }
+
+ public static org.apache.stratos.autoscaler.stub.kubernetes.KubernetesHost convertToASKubernetesHostPojo(KubernetesHost kubernetesHostBean) {
+ if (kubernetesHostBean == null) {
+ return null;
+ }
+
+ org.apache.stratos.autoscaler.stub.kubernetes.KubernetesHost
+ kubernetesHost = new org.apache.stratos.autoscaler.stub.kubernetes.KubernetesHost();
+ kubernetesHost.setHostId(kubernetesHostBean.getHostId());
+ kubernetesHost.setHostIpAddress(kubernetesHostBean.getHostIpAddress());
+ kubernetesHost.setHostname(kubernetesHostBean.getHostname());
+ kubernetesHost.setProperties(getASProperties(kubernetesHostBean.getProperty()));
+
+ return kubernetesHost;
+ }
+
+ public static org.apache.stratos.autoscaler.stub.kubernetes.KubernetesMaster convertToASKubernetesMasterPojo(KubernetesMaster kubernetesMasterBean) {
+ if (kubernetesMasterBean == null) {
+ return null;
+ }
+
+ org.apache.stratos.autoscaler.stub.kubernetes.KubernetesMaster
+ kubernetesMaster = new org.apache.stratos.autoscaler.stub.kubernetes.KubernetesMaster();
+ kubernetesMaster.setHostId(kubernetesMasterBean.getHostId());
+ kubernetesMaster.setHostIpAddress(kubernetesMasterBean.getHostIpAddress());
+ kubernetesMaster.setHostname(kubernetesMasterBean.getHostname());
+ kubernetesMaster.setEndpoint(kubernetesMasterBean.getEndpoint());
+ kubernetesMaster.setProperties(getASProperties(kubernetesMasterBean.getProperty()));
+
+ return kubernetesMaster;
+ }
+
+ public static KubernetesGroup[] populateKubernetesGroupsPojo(org.apache.stratos.autoscaler.stub.kubernetes.KubernetesGroup[] kubernetesGroups) {
+
+ if (kubernetesGroups == null){
+ return null;
+ }
+ KubernetesGroup[] kubernetesGroupsBean = new KubernetesGroup[kubernetesGroups.length];
+ for (int i = 0; i < kubernetesGroups.length; i++){
+ kubernetesGroupsBean[i] = populateKubernetesGroupPojo(kubernetesGroups[i]);
+ }
+ return kubernetesGroupsBean;
+ }
+
+ public static KubernetesGroup populateKubernetesGroupPojo(org.apache.stratos.autoscaler.stub.kubernetes.KubernetesGroup kubernetesGroup) {
+ if (kubernetesGroup == null){
+ return null;
+ }
+ KubernetesGroup kubernetesGroupBean = new KubernetesGroup();
+ kubernetesGroupBean.setGroupId(kubernetesGroup.getGroupId());
+ kubernetesGroupBean.setDescription(kubernetesGroup.getDescription());
+ kubernetesGroupBean.setPortRange(populatePortRangePojo(kubernetesGroup.getPortRange()));
+ kubernetesGroupBean.setKubernetesHosts(populateKubernetesHostsPojo(kubernetesGroup.getKubernetesHosts()));
+ kubernetesGroupBean.setKubernetesMaster(populateKubernetesMasterPojo(kubernetesGroup.getKubernetesMaster()));
+ kubernetesGroupBean.setProperty(populateASProperties(kubernetesGroup.getProperties()));
+ return kubernetesGroupBean;
+ }
+
+ public static KubernetesMaster populateKubernetesMasterPojo(org.apache.stratos.autoscaler.stub.kubernetes.KubernetesMaster kubernetesMaster) {
+ if (kubernetesMaster == null){
+ return null;
+ }
+ KubernetesMaster kubernetesMasterBean = new KubernetesMaster();
+ kubernetesMasterBean.setHostId(kubernetesMaster.getHostId());
+ kubernetesMasterBean.setHostname(kubernetesMaster.getHostname());
+ kubernetesMasterBean.setHostIpAddress(kubernetesMaster.getHostIpAddress());
+ kubernetesMasterBean.setProperty(populateASProperties(kubernetesMaster.getProperties()));
+ kubernetesMasterBean.setEndpoint(kubernetesMaster.getEndpoint());
+ return kubernetesMasterBean;
+ }
+
+ public static List<KubernetesHost> populateKubernetesHostsPojo(org.apache.stratos.autoscaler.stub.kubernetes.KubernetesHost[] kubernetesHosts) {
+ if (kubernetesHosts == null){
+ return null;
+ }
+ List<KubernetesHost> kubernetesHostList = new ArrayList<KubernetesHost>();
+ for (int i = 0; i < kubernetesHosts.length; i++){
+ kubernetesHostList.add(populateKubernetesHostPojo(kubernetesHosts[i]));
+ }
+ return kubernetesHostList;
+ }
+
+ private static KubernetesHost populateKubernetesHostPojo(org.apache.stratos.autoscaler.stub.kubernetes.KubernetesHost kubernetesHost) {
+ if (kubernetesHost == null){
+ return null;
+ }
+ KubernetesHost kubernetesHostBean = new KubernetesHost();
+ kubernetesHostBean.setHostId(kubernetesHost.getHostId());
+ kubernetesHostBean.setHostname(kubernetesHost.getHostname());
+ kubernetesHostBean.setHostIpAddress(kubernetesHost.getHostIpAddress());
+ kubernetesHostBean.setProperty(populateASProperties(kubernetesHost.getProperties()));
+ return kubernetesHostBean;
+ }
+
+ private static List<PropertyBean> populateASProperties(PropertiesE properties) {
+ if (properties == null || properties.getProperties() == null){
+ return null;
+ }
+ List<PropertyBean> propertyBeanList = new ArrayList<PropertyBean>();
+ for (int i = 0; i < properties.getProperties().length; i++){
+ propertyBeanList.add(populateASProperty(properties.getProperties()[i]));
+ }
+ return propertyBeanList;
+ }
+
+ private static PropertyBean populateASProperty(PropertyE propertyE) {
+ if (propertyE == null){
+ return null;
+ }
+ PropertyBean propertyBean = new PropertyBean();
+ propertyBean.name = propertyE.getName();
+ propertyBean.value = propertyE.getValue();
+ return propertyBean;
+ }
+
+ private static PortRange populatePortRangePojo(org.apache.stratos.autoscaler.stub.kubernetes.PortRange portRange) {
+ if (portRange == null){
+ return null;
+ }
+ PortRange portRangeBean = new PortRange();
+ portRangeBean.setUpper(portRange.getUpper());
+ portRangeBean.setLower(portRange.getLower());
+ return portRangeBean;
+ }
+
+ private static Log log = LogFactory.getLog(PojoConverter.class);
+
+ public static ApplicationContext convertApplicationBeanToApplicationContext (ApplicationDefinition compositeAppDefinition) {
+
+ ApplicationContext applicationContext = new ApplicationContext();
+ applicationContext.setApplicationId(compositeAppDefinition.getApplicationId());
+ applicationContext.setAlias(compositeAppDefinition.getAlias());
+
+ // convert and set components
+ if (compositeAppDefinition.getComponents() != null) {
+ ComponentContext componentContext = new ComponentContext();
+ // top level subscribables
+ if (compositeAppDefinition.getComponents().getSubscribables() != null) {
+ componentContext.setSubscribableContexts(getSubscribableContextArrayFromSubscribableDefinitions(
+ compositeAppDefinition.getComponents().getSubscribables()));
+ }
+ // top level Groups
+ if (compositeAppDefinition.getComponents().getGroups() != null) {
+ componentContext.setGroupContexts(getgroupContextArrayFromGroupDefinitions(compositeAppDefinition.getComponents().getGroups()));
+ }
+ // top level dependency information
+ if (compositeAppDefinition.getComponents().getDependencies() != null) {
+ componentContext.setDependencyContext(getDependencyContextFromDependencyDefinition(compositeAppDefinition.getComponents().getDependencies()));
+ }
+
+ applicationContext.setComponents(componentContext);
+ }
+
+ // subscribable information
+ applicationContext.setSubscribableInfoContext(getSubscribableInfoContextArrFromSubscribableInfoDefinition(compositeAppDefinition.getSubscribableInfo()));
+
+ return applicationContext;
+ }
+
+ private static SubscribableInfoContext[] getSubscribableInfoContextArrFromSubscribableInfoDefinition (List<SubscribableInfo> subscribableInfos) {
+
+ SubscribableInfoContext[] subscribableInfoContexts = new SubscribableInfoContext[subscribableInfos.size()];
+ int i = 0;
+ for (SubscribableInfo subscribableInfo : subscribableInfos) {
+ SubscribableInfoContext subscribableInfoContext = new SubscribableInfoContext();
+ subscribableInfoContext.setAlias(subscribableInfo.getAlias());
+ subscribableInfoContext.setAutoscalingPolicy(subscribableInfo.getAutoscalingPolicy());
+ subscribableInfoContext.setDeploymentPolicy(subscribableInfo.getDeploymentPolicy());
+ subscribableInfoContext.setRepoUrl(subscribableInfo.getRepoUrl());
+ subscribableInfoContext.setPrivateRepo(subscribableInfo.isPrivateRepo());
+ subscribableInfoContext.setRepoUsername(subscribableInfo.getRepoUsername());
+ subscribableInfoContext.setRepoPassword(subscribableInfo.getRepoPassword());
+ subscribableInfoContext.setDependencyAliases(subscribableInfo.getDependencyAliases());
+ subscribableInfoContexts[i++] = subscribableInfoContext;
+
+ }
+
+ return subscribableInfoContexts;
+ }
+
+ private static DependencyContext getDependencyContextFromDependencyDefinition (DependencyDefinitions dependencyDefinitions) {
+
+ DependencyContext dependencyContext = new DependencyContext();
+ dependencyContext.setKillBehaviour(dependencyDefinitions.getKillBehaviour());
+
+ if (dependencyDefinitions != null && dependencyDefinitions.getStartupOrders() != null) {
+ String [] startupOrders = new String [dependencyDefinitions.getStartupOrders().size()];
+ startupOrders = dependencyDefinitions.getStartupOrders().toArray(startupOrders);
+ dependencyContext.setStartupOrdersContexts(startupOrders);
+ }
+
+ return dependencyContext;
+ }
+
+ private static GroupContext[] getgroupContextArrayFromGroupDefinitions (List<GroupDefinition> groupDefinitions) {
+
+ GroupContext[] groupContexts = new GroupContext[groupDefinitions.size()];
+ int i = 0;
+ for (GroupDefinition groupDefinition : groupDefinitions) {
+ GroupContext groupContext = new GroupContext();
+ groupContext.setName(groupDefinition.getName());
+ groupContext.setAlias(groupDefinition.getAlias());
+ groupContext.setDeploymentPolicy(groupDefinition.getDeploymentPolicy());
+ groupContext.setAutoscalingPolicy(groupDefinition.getAutoscalingPolicy());
+ // nested Subscribables
+ if (groupDefinition.getSubscribables() != null) {
+ groupContext.setSubscribableContexts(getSubscribableContextArrayFromSubscribableDefinitions(groupDefinition.getSubscribables()));
+ }
+ // nested Groups
+ if (groupDefinition.getSubGroups() != null) {
+ groupContext.setGroupContexts(getgroupContextArrayFromGroupDefinitions(groupDefinition.getSubGroups()));
+ }
+ groupContexts[i++] = groupContext;
+ }
+
+ return groupContexts;
+ }
+
+ private static SubscribableContext [] getSubscribableContextArrayFromSubscribableDefinitions(List<SubscribableDefinition> subscribableDefinitions) {
+
+ SubscribableContext[] subscribableContexts = new SubscribableContext[subscribableDefinitions.size()];
+ int i = 0;
+ for (SubscribableDefinition subscribableDefinition : subscribableDefinitions) {
+ SubscribableContext subscribableContext = new SubscribableContext();
+ subscribableContext.setType(subscribableDefinition.getType());
+ subscribableContext.setAlias(subscribableDefinition.getAlias());
+ subscribableContexts[i++] = subscribableContext;
+ }
+
+ return subscribableContexts;
+ }
+
+
+ public static ApplicationBean applicationToBean(Application application) {
+
+ if(application == null){
+ return null;
+ }
+
+ ApplicationBean applicationBean = new ApplicationBean();
+ applicationBean.setId(application.getUniqueIdentifier());
+ applicationBean.setTenantDomain(application.getTenantDomain());
+ applicationBean.setTenantAdminUsername(application.getTenantAdminUserName());
+ return applicationBean;
+ }
+
+ public static GroupBean toGroupBean(Group group) {
+ if(group == null){
+ return null;
+ }
+
+ GroupBean groupBean = new GroupBean();
+ groupBean.setAlias(group.getUniqueIdentifier());
+ groupBean.setDeploymentPolicy(group.getDeploymentPolicy());
+ groupBean.setAutoScalingPolicy(group.getAutoscalingPolicy());
+ return groupBean;
+ }
+
}
[13/50] [abbrv] git commit: setting hasDependent to monitors based on
kill behaviours
Posted by im...@apache.org.
setting hasDependent to monitors based on kill behaviours
Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/aef9c12c
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/aef9c12c
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/aef9c12c
Branch: refs/heads/docker-grouping-merge
Commit: aef9c12cbfc204a4a5c85f6c32b6707c21b1683f
Parents: 66aeb30
Author: reka <rt...@gmail.com>
Authored: Mon Oct 27 18:29:22 2014 +0530
Committer: reka <rt...@gmail.com>
Committed: Mon Oct 27 18:29:22 2014 +0530
----------------------------------------------------------------------
.../grouping/dependency/DependencyBuilder.java | 2 +-
.../dependency/context/ApplicationContext.java | 12 ++++++++++--
.../dependency/context/ApplicationContextFactory.java | 14 ++++++++------
.../autoscaler/monitor/ApplicationMonitorFactory.java | 4 ++--
.../autoscaler/monitor/cluster/ClusterMonitor.java | 4 ++--
5 files changed, 23 insertions(+), 13 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/stratos/blob/aef9c12c/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/DependencyBuilder.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/DependencyBuilder.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/DependencyBuilder.java
index 14fc90e..edd1c02 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/DependencyBuilder.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/DependencyBuilder.java
@@ -91,7 +91,7 @@ public class DependencyBuilder {
if (start != null) {
ApplicationContext applicationContext = ApplicationContextFactory.
- getApplicationContext(start, component, dependencyTree.isKillDependent());
+ getApplicationContext(start, component, dependencyTree);
String id = applicationContext.getId();
ApplicationContext existingApplicationContext =
http://git-wip-us.apache.org/repos/asf/stratos/blob/aef9c12c/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/context/ApplicationContext.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/context/ApplicationContext.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/context/ApplicationContext.java
index 45e1655..3197fb9 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/context/ApplicationContext.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/context/ApplicationContext.java
@@ -38,12 +38,12 @@ public abstract class ApplicationContext {
private Stack<ClusterStatus> statusLifeCycle;
- protected boolean killDependent;
+ protected boolean isDependent;
public ApplicationContext(String id, boolean killDependent) {
applicationContextList = new ArrayList<ApplicationContext>();
statusLifeCycle = new Stack<ClusterStatus>();
- this.killDependent = killDependent;
+ this.setDependent(killDependent);
this.id = id;
}
@@ -102,4 +102,12 @@ public abstract class ApplicationContext {
public void setTerminated(boolean terminated) {
this.terminated = terminated;
}
+
+ public boolean isDependent() {
+ return isDependent;
+ }
+
+ public void setDependent(boolean isDependent) {
+ this.isDependent = isDependent;
+ }
}
http://git-wip-us.apache.org/repos/asf/stratos/blob/aef9c12c/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/context/ApplicationContextFactory.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/context/ApplicationContextFactory.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/context/ApplicationContextFactory.java
index 970d593..631e5d4 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/context/ApplicationContextFactory.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/context/ApplicationContextFactory.java
@@ -21,6 +21,7 @@ package org.apache.stratos.autoscaler.grouping.dependency.context;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.stratos.autoscaler.Constants;
+import org.apache.stratos.autoscaler.grouping.dependency.DependencyTree;
import org.apache.stratos.messaging.domain.topology.ClusterDataHolder;
import org.apache.stratos.messaging.domain.topology.Group;
import org.apache.stratos.messaging.domain.topology.ParentComponent;
@@ -36,24 +37,25 @@ public class ApplicationContextFactory {
*
* @param startOrder reference of group/cluster in the start order
* @param component The component which used to build the dependency
- * @param isKillDependent kill dependent behaviour of this component
+ * @param tree kill dependent behaviour of this component
* @return Context
*/
public static ApplicationContext getApplicationContext(String startOrder,
ParentComponent component,
- boolean isKillDependent) {
+ DependencyTree tree) {
String id;
ApplicationContext applicationContext = null;
+ boolean isDependent = tree.isKillDependent() || tree.isKillAll();
if (startOrder.startsWith(Constants.GROUP + ".")) {
//getting the group alias
id = getGroupFromStartupOrder(startOrder);
- applicationContext = getGroupContext(id, isKillDependent);
+ applicationContext = getGroupContext(id, isDependent);
} else if (startOrder.startsWith(Constants.CARTRIDGE + ".")) {
//getting the cluster alias
id = getClusterFromStartupOrder(startOrder);
//getting the cluster-id from cluster alias
ClusterDataHolder clusterDataHolder = component.getClusterDataMap().get(id);
- applicationContext = getClusterContext(clusterDataHolder, isKillDependent);
+ applicationContext = getClusterContext(clusterDataHolder, isDependent);
} else {
log.warn("[Startup Order]: " + startOrder + " contains unknown reference");
@@ -91,10 +93,10 @@ public class ApplicationContextFactory {
return applicationContext;
}
- public static ApplicationContext getGroupContext(String id, boolean isKillDependent) {
+ public static ApplicationContext getGroupContext(String id, boolean isDependent) {
ApplicationContext applicationContext;
applicationContext = new GroupContext(id,
- isKillDependent);
+ isDependent);
return applicationContext;
}
}
http://git-wip-us.apache.org/repos/asf/stratos/blob/aef9c12c/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ApplicationMonitorFactory.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ApplicationMonitorFactory.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ApplicationMonitorFactory.java
index b60e645..2ead896 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ApplicationMonitorFactory.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ApplicationMonitorFactory.java
@@ -109,7 +109,7 @@ public class ApplicationMonitorFactory {
if(parentMonitor != null) {
groupMonitor.setParent(parentMonitor);
//Setting the dependent behaviour of the monitor
- if(parentMonitor.hasMonitors() && (parentMonitor.isDependent() || context.hasChild())) {
+ if(parentMonitor.isDependent() || (context.isDependent() && context.hasChild())) {
groupMonitor.setHasDependent(true);
} else {
groupMonitor.setHasDependent(false);
@@ -291,7 +291,7 @@ public class ApplicationMonitorFactory {
clusterMonitor.addNetworkPartitionCtxt(networkPartitionContext);
clusterMonitor.setParent(parentMonitor);
- if(parentMonitor.hasActiveMonitors() && (parentMonitor.isDependent() || context.hasChild())) {
+ if(parentMonitor.isDependent() || (context.isDependent() && context.hasChild())) {
clusterMonitor.setHasDependent(true);
} else {
clusterMonitor.setHasDependent(false);
http://git-wip-us.apache.org/repos/asf/stratos/blob/aef9c12c/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 0848d64..557fedb 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
@@ -174,7 +174,7 @@ public class ClusterMonitor extends AbstractClusterMonitor {
}
- boolean rifReset = networkPartitionContext.isRifReset();
+ /*boolean rifReset = networkPartitionContext.isRifReset();
boolean memoryConsumptionReset = networkPartitionContext.isMemoryConsumptionReset();
boolean loadAverageReset = networkPartitionContext.isLoadAverageReset();
@@ -208,7 +208,7 @@ public class ClusterMonitor extends AbstractClusterMonitor {
} else if (log.isDebugEnabled()) {
log.debug(String.format("Scale rule will not run since the LB statistics have not received before this " +
"cycle for network partition %s", networkPartitionContext.getId()));
- }
+ }*/
}
}
[50/50] [abbrv] git commit: Merge branch '4.0.0-grouping' into
docker-grouping-merge
Posted by im...@apache.org.
Merge branch '4.0.0-grouping' into docker-grouping-merge
Conflicts:
components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/AutoscalerContext.java
components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/PartitionContext.java
components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/health/AutoscalerHealthStatEventReceiver.java
components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java
components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/AbstractClusterMonitor.java
components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/rule/AutoscalerRuleEvaluator.java
components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/AutoscalerUtil.java
components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/AutoscalePolicyCommand.java
components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/AutoscalingPolicyDeploymentCommand.java
components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/CartridgeDeploymentCommand.java
components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/DeployServiceDeploymentCommand.java
components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/DeploymentPolicyCommand.java
components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/DeploymentPolicyDeploymentCommand.java
components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/ListSubscribedCartridgesCommand.java
components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/PartitionCommand.java
components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/PartitionDeploymentCommand.java
components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/PoliciesCommand.java
components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/RemoveDomainMappingCommand.java
components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/SubscribeCommand.java
components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/SubscribedCartridgeInfoCommand.java
components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/utils/CommandLineUtils.java
components/org.apache.stratos.cloud.controller/pom.xml
components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/AWSEC2Iaas.java
components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/OpenstackNovaIaas.java
components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java
components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/interfaces/CloudControllerService.java
components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/internal/CloudControllerDSComponent.java
components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/Cartridge.java
components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/CartridgeConfig.java
components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java
components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyEventPublisher.java
components/org.apache.stratos.manager.console/console/util/utility.jag
components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/manager/CartridgeSubscriptionManager.java
components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Cluster.java
components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Member.java
components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/InstanceSpawnedMessageProcessor.java
components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/util/Constants.java
components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/util/Util.java
components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/util/converter/PojoConverter.java
components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java
components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/StratosAdmin.java
components/org.apache.stratos.rest.endpoint/src/main/webapp/stratos/WEB-INF/cxf-servlet.xml
dependencies/pom.xml
extensions/cep/stratos-cep-extension/src/main/java/org/apache/stratos/cep/extension/CEPTopologyEventReceiver.java
extensions/cep/stratos-cep-extension/src/main/java/org/apache/stratos/cep/extension/FaultHandlingWindowProcessor.java
features/cloud-controller/org.apache.stratos.cloud.controller.feature/pom.xml
pom.xml
products/stratos/modules/distribution/src/assembly/bin.xml
products/stratos/modules/distribution/src/main/conf/mincheck.drl
service-stubs/org.apache.stratos.cloud.controller.service.stub/pom.xml
service-stubs/org.apache.stratos.cloud.controller.service.stub/src/main/resources/CloudControllerService.wsdl
tools/puppet3/modules/mysql/manifests/init.pp
Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/17cc86eb
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/17cc86eb
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/17cc86eb
Branch: refs/heads/docker-grouping-merge
Commit: 17cc86ebdbc4c6e405576a98a0bb30f0f28f9fbc
Parents: dd9cc95 5e69c7f
Author: Imesh Gunaratne <im...@apache.org>
Authored: Thu Oct 30 09:42:56 2014 +0530
Committer: Imesh Gunaratne <im...@apache.org>
Committed: Thu Oct 30 09:42:56 2014 +0530
----------------------------------------------------------------------
.../apache/stratos/autoscaler/Constants.java | 9 +
.../stratos/autoscaler/PartitionContext.java | 45 +
.../exception/DependencyBuilderException.java | 48 +
.../TopologyInConsistentException.java | 47 +
.../grouping/dependency/DependencyBuilder.java | 158 ++++
.../grouping/dependency/DependencyTree.java | 291 ++++++
.../dependency/context/ApplicationContext.java | 113 +++
.../context/ApplicationContextFactory.java | 102 +++
.../dependency/context/ClusterContext.java | 38 +
.../dependency/context/GroupContext.java | 25 +
.../topic/InstanceNotificationPublisher.java | 53 ++
.../grouping/topic/StatusEventPublisher.java | 312 +++++++
.../AutoscalerHealthStatEventReceiver.java | 12 +-
.../monitor/ApplicationMonitorFactory.java | 344 +++++++
.../autoscaler/monitor/EventHandler.java | 56 ++
.../stratos/autoscaler/monitor/Monitor.java | 108 +++
.../monitor/MonitorStatusEventBuilder.java | 61 ++
.../monitor/ParentComponentMonitor.java | 407 +++++++++
.../monitor/application/ApplicationMonitor.java | 196 ++++
.../monitor/cluster/ClusterMonitor.java | 293 ++++++
.../monitor/cluster/LbClusterMonitor.java | 129 +++
.../monitor/events/ApplicationStatusEvent.java | 42 +
.../monitor/events/ClusterStatusEvent.java | 42 +
.../monitor/events/GroupStatusEvent.java | 41 +
.../monitor/events/GroupTerminateAllEvent.java | 29 +
.../autoscaler/monitor/events/MonitorEvent.java | 28 +
.../monitor/events/MonitorScalingEvent.java | 30 +
.../monitor/events/MonitorStartAllEvent.java | 28 +
.../monitor/events/MonitorStatusEvent.java | 41 +
.../events/MonitorTerminateAllEvent.java | 29 +
.../autoscaler/monitor/group/GroupMonitor.java | 167 ++++
.../rule/AutoscalerRuleEvaluator.java | 22 +
.../autoscaler/rule/RuleTasksDelegator.java | 27 +-
.../status/checker/StatusChecker.java | 428 +++++++++
.../termination-change.patch | 596 +++++++++++++
.../stratos/cartridge/agent/CartridgeAgent.java | 11 +
.../git/impl/GitBasedArtifactRepository.java | 47 -
.../publisher/CartridgeStatistics.java | 66 ++
.../publisher/HealthStatisticsNotifier.java | 119 ++-
.../publisher/HealthStatisticsReader.java | 31 +-
.../publisher/IHealthStatisticsReader.java | 55 ++
.../statistics/publisher/PluginLoader.java | 88 ++
.../java/org/apache/stratos/cli/Command.java | 5 +-
.../stratos/cli/RestCommandLineService.java | 1 +
.../apache/stratos/cli/StratosApplication.java | 8 +-
.../cli/commands/ActivateTenantCommand.java | 3 +-
.../cli/commands/AddDomainMappingCommand.java | 3 +-
.../stratos/cli/commands/AddTenantCommand.java | 30 +-
.../cli/commands/DeactivateTenantCommand.java | 3 +-
.../cli/commands/DeleteTenantCommand.java | 3 +-
.../DescribeAutoScalingPolicyCommand.java | 2 +-
.../cli/commands/DescribeCartridgeCommand.java | 2 +-
.../DescribeDeploymentPolicyCommand.java | 2 +-
.../cli/commands/DescribePartitionCommand.java | 3 +-
.../stratos/cli/commands/ExitCommand.java | 3 +-
.../stratos/cli/commands/HelpCommand.java | 3 +-
.../stratos/cli/commands/InfoCommand.java | 3 +-
.../stratos/cli/commands/ListAllTenants.java | 3 +-
.../cli/commands/ListCartridgesCommand.java | 3 +-
.../cli/commands/ListDeployServiceCommand.java | 3 +-
.../stratos/cli/commands/ListMemberCommand.java | 14 +-
.../stratos/cli/commands/SyncCommand.java | 3 +-
.../UndeployCartridgeDefinitionCommand.java | 3 +-
.../UndeployServiceDefinitionCommand.java | 3 +-
.../cli/commands/UnsubscribeCommand.java | 9 +-
.../src/main/resources/log4j.properties | 2 +-
.../org.apache.stratos.cloud.controller/pom.xml | 2 +
.../application/ApplicationUtils.java | 291 ++++++
.../application/ClusterInformation.java | 27 +
.../application/MTClusterInformation.java | 45 +
.../application/STClusterInformation.java | 55 ++
.../parser/DefaultApplicationParser.java | 610 +++++++++++++
.../application/parser/ParserUtils.java | 142 +++
.../ApplicationCartridgePayloadData.java | 27 +
.../application/payload/BasicPayloadData.java | 311 +++++++
.../payload/DataCartridgePayloadData.java | 27 +
.../payload/FrameworkCartridgePayloadData.java | 27 +
.../LoadBalancerCartridgePayloadData.java | 27 +
.../application/payload/PayloadData.java | 69 ++
.../application/payload/PayloadFactory.java | 59 ++
.../ApplicationStatusTopicReceiver.java | 175 ++++
.../ApplicationDefinitionException.java | 47 +
...CompositeApplicationDefinitionException.java | 44 +
.../exception/InvalidServiceGroupException.java | 46 +
.../cloud/controller/iaases/AWSEC2Iaas.java | 4 +
.../controller/iaases/OpenstackNovaIaas.java | 3 +
.../impl/CloudControllerServiceImpl.java | 252 ++++--
.../interfaces/ApplicationParser.java | 53 ++
.../interfaces/CloudControllerService.java | 34 +-
.../internal/CloudControllerDSComponent.java | 180 ++--
.../pojo/ApplicationClusterContext.java | 137 +++
.../cloud/controller/pojo/Cartridge.java | 16 +-
.../cloud/controller/pojo/CartridgeConfig.java | 10 +
.../pojo/CompositeApplicationDefinition.java | 38 +
.../cloud/controller/pojo/ConfigCartridge.java | 17 +
.../controller/pojo/ConfigDependencies.java | 29 +
.../controller/pojo/ConfigDependencyPair.java | 29 +
.../cloud/controller/pojo/ConfigGroup.java | 35 +
.../cloud/controller/pojo/Dependencies.java | 48 +
.../cloud/controller/pojo/ServiceGroup.java | 69 ++
.../pojo/application/ApplicationContext.java | 93 ++
.../pojo/application/ComponentContext.java | 54 ++
.../pojo/application/DependencyContext.java | 44 +
.../pojo/application/GroupContext.java | 84 ++
.../pojo/application/SubscribableContext.java | 44 +
.../application/SubscribableInfoContext.java | 103 +++
.../controller/pojo/payload/MetaDataHolder.java | 99 ++
.../runtime/FasterLookUpDataHolder.java | 37 +-
.../InstanceStatusEventMessageDelegator.java | 17 +-
.../controller/topology/TopologyBuilder.java | 892 ++++++++++++++++---
.../topology/TopologyEventPublisher.java | 270 ++++--
.../controller/util/CloudControllerUtil.java | 4 +
.../CompositeApplicationParseTest.java | 554 ++++++++++++
.../LoadBalancerTopologyEventReceiver.java | 77 +-
.../conf/LoadBalancerConfiguration.java | 9 +-
.../console/util/utility.jag | 21 +
.../client/CloudControllerServiceClient.java | 49 +-
.../composite/application/TemporyClass.java | 7 -
.../beans/ApplicationDefinition.java | 67 ++
.../application/beans/ComponentDefinition.java | 41 +
.../application/beans/GroupDefinition.java | 87 ++
.../beans/SubscribableDefinition.java | 48 +
.../application/beans/SubscribableInfo.java | 106 +++
.../parser/CompositeApplicationParser.java | 30 +
.../DefaultCompositeApplicationParser.java | 431 +++++++++
.../application/parser/ParserUtils.java | 60 ++
.../structure/CompositeAppContext.java | 107 +++
.../application/structure/GroupContext.java | 123 +++
.../application/structure/StartupOrder.java | 66 ++
.../structure/SubscribableContext.java | 126 +++
.../application/utils/ApplicationUtils.java | 28 +
.../ApplicationSubscriptionException.java | 51 ++
...CompositeApplicationDefinitionException.java | 47 +
.../CompositeApplicationException.java | 47 +
.../DomainSubscriptionDoesNotExist.java | 39 +-
.../exception/GroupSubscriptionException.java | 47 +
.../exception/InvalidServiceGroupException.java | 47 +
.../ServiceGroupDefinitioException.java | 47 +
.../definitions/DependencyDefinitions.java | 53 ++
.../definitions/ServiceGroupDefinition.java | 68 ++
.../definitions/StartupOrderDefinition.java | 47 +
.../deployer/DefaultServiceGroupDeployer.java | 326 +++++++
.../grouping/deployer/ServiceGroupDeployer.java | 36 +
.../manager/ServiceGroupingManager.java | 57 ++
.../internal/ADCManagementServerComponent.java | 12 +
.../manager/CartridgeSubscriptionManager.java | 237 ++++-
.../manager/persistence/PersistenceManager.java | 26 +
.../RegistryBasedPersistenceManager.java | 396 +++++++-
.../DataInsertionAndRetrievalManager.java | 49 +
.../subscription/ApplicationSubscription.java | 78 ++
.../manager/subscription/GroupSubscription.java | 73 ++
.../utils/CartridgeSubscriptionUtils.java | 1 +
.../StratosManagerTopologyEventReceiver.java | 219 ++++-
.../stratos/manager/utils/Serializer.java | 53 +-
components/org.apache.stratos.messaging/pom.xml | 20 +-
.../messaging/domain/topology/Application.java | 123 +++
.../domain/topology/ApplicationStatus.java | 74 ++
.../messaging/domain/topology/Cartridge.java | 89 ++
.../messaging/domain/topology/Cluster.java | 102 ++-
.../domain/topology/ClusterDataHolder.java | 51 ++
.../domain/topology/ClusterStatus.java | 54 +-
.../messaging/domain/topology/Composite.java | 15 +
.../domain/topology/CompositeApplication.java | 298 +++++++
.../domain/topology/ConfigCartridge.java | 20 +
.../topology/ConfigCompositeApplication.java | 42 +
.../domain/topology/ConfigDependencies.java | 57 ++
.../messaging/domain/topology/ConfigGroup.java | 33 +
.../messaging/domain/topology/Dependencies.java | 334 +++++++
.../domain/topology/DependencyOrder.java | 54 ++
.../messaging/domain/topology/Group.java | 111 +++
.../messaging/domain/topology/GroupStatus.java | 73 ++
.../messaging/domain/topology/GroupTemp.java | 503 +++++++++++
.../LifeCycleStateTransitionBehavior.java | 35 +
.../messaging/domain/topology/Member.java | 28 +-
.../messaging/domain/topology/MemberStatus.java | 62 +-
.../domain/topology/ParentComponent.java | 212 +++++
.../messaging/domain/topology/Scalable.java | 5 +
.../messaging/domain/topology/Service.java | 9 +-
.../messaging/domain/topology/StartupOrder.java | 40 +
.../messaging/domain/topology/Subscribable.java | 25 +
.../messaging/domain/topology/Topology.java | 125 ++-
.../topology/lifecycle/LifeCycleState.java | 28 +
.../lifecycle/LifeCycleStateManager.java | 138 +++
.../domain/topology/locking/TopologyLock.java | 63 ++
.../topology/locking/TopologyLockHierarchy.java | 176 ++++
.../AppStatusApplicationActivatedEvent.java | 38 +
.../AppStatusApplicationCreatedEvent.java | 38 +
.../AppStatusApplicationInactivatedEvent.java | 38 +
.../AppStatusApplicationTerminatedEvent.java | 47 +
.../AppStatusApplicationTerminatingEvent.java | 38 +
.../status/AppStatusClusterActivatedEvent.java | 50 ++
.../status/AppStatusClusterInactivateEvent.java | 50 ++
.../AppStatusClusterMaintenanceModeEvent.java | 49 +
.../AppStatusClusterReadyToShutdownEvent.java | 47 +
.../status/AppStatusClusterTerminatedEvent.java | 50 ++
.../AppStatusClusterTerminatingEvent.java | 50 ++
.../status/AppStatusGroupActivatedEvent.java | 44 +
.../status/AppStatusGroupInactivateEvent.java | 44 +
.../AppStatusGroupMaintenanceModeEvent.java | 41 +
.../AppStatusGroupReadyToShutdownEvent.java | 40 +
.../status/AppStatusGroupTerminatedEvent.java | 44 +
.../status/AppStatusGroupTerminatingEvent.java | 44 +
.../event/application/status/StatusEvent.java | 31 +
.../instance/status/InstanceActivatedEvent.java | 9 +
.../status/InstanceMaintenanceModeEvent.java | 9 +
.../status/InstanceReadyToShutdownEvent.java | 9 +
.../instance/status/InstanceStartedEvent.java | 9 +
.../topology/ApplicationActivatedEvent.java | 34 +
.../event/topology/ApplicationCreatedEvent.java | 54 ++
.../topology/ApplicationInactivatedEvent.java | 34 +
.../topology/ApplicationTerminatedEvent.java | 57 ++
.../topology/ApplicationTerminatingEvent.java | 35 +
.../topology/ApplicationUndeployedEvent.java | 43 +
.../event/topology/ClusterActivatedEvent.java | 57 ++
.../event/topology/ClusterCreatedEvent.java | 22 +-
.../event/topology/ClusterInactivateEvent.java | 56 ++
.../topology/ClusterMaintenanceModeEvent.java | 58 --
.../event/topology/ClusterTerminatedEvent.java | 56 ++
.../event/topology/ClusterTerminatingEvent.java | 56 ++
.../CompositeApplicationCreatedEvent.java | 51 ++
.../topology/CompositeApplicationEvent.java | 31 +
.../CompositeApplicationRemovedEvent.java | 49 +
.../event/topology/GroupActivatedEvent.java | 43 +
.../event/topology/GroupInactivateEvent.java | 43 +
.../event/topology/GroupTerminatedEvent.java | 43 +
.../event/topology/GroupTerminatingEvent.java | 43 +
.../event/topology/MemberActivatedEvent.java | 42 +-
.../topology/MemberMaintenanceModeEvent.java | 9 +
.../topology/MemberReadyToShutdownEvent.java | 9 +
.../event/topology/MemberStartedEvent.java | 9 +
.../event/topology/MemberSuspendedEvent.java | 9 +
.../event/topology/MemberTerminatedEvent.java | 8 +
...StatusApplicationActivatedEventListener.java | 27 +
...ppStatusApplicationCreatedEventListener.java | 27 +
...atusApplicationInactivatedEventListener.java | 27 +
...tatusApplicationTerminatedEventListener.java | 27 +
...atusApplicationTerminatingEventListener.java | 27 +
.../AppStatusClusterActivatedEventListener.java | 24 +
...AppStatusClusterInactivateEventListener.java | 24 +
...AppStatusClusterTerminatedEventListener.java | 24 +
...ppStatusClusterTerminatingEventListener.java | 24 +
.../AppStatusGroupActivatedEventListener.java | 24 +
.../AppStatusGroupInactivateEventListener.java | 24 +
.../AppStatusGroupTerminatedEventListener.java | 24 +
.../AppStatusGroupTerminatingEventListener.java | 24 +
.../ApplicationActivatedEventListener.java | 27 +
.../ApplicationCreatedEventListener.java | 26 +
.../ApplicationInActivateEventListener.java | 27 +
.../ApplicationTerminatedEventListener.java | 27 +
.../ApplicationTerminatingEventListener.java | 27 +
.../ApplicationUndeployedEventListener.java | 26 +
.../topology/ClusterActivatedEventListener.java | 24 +
.../ClusterInActivateEventListener.java | 24 +
.../ClusterMaintenanceModeEventListener.java | 25 -
.../ClusterTerminatedEventListener.java | 24 +
.../ClusterTerminatingEventListener.java | 24 +
.../topology/GroupActivatedEventListener.java | 27 +
.../topology/GroupInActivateEventListener.java | 27 +
.../topology/GroupTerminatedEventListener.java | 27 +
.../topology/GroupTerminatingEventListener.java | 27 +
...tusApplicationActivatedMessageProcessor.java | 62 ++
...tatusApplicationCreatedMessageProcessor.java | 63 ++
...sApplicationInactivatedMessageProcessor.java | 63 ++
...usApplicationTerminatedMessageProcessor.java | 63 ++
...sApplicationTerminatingMessageProcessor.java | 63 ++
...pStatusClusterActivatedMessageProcessor.java | 57 ++
...StatusClusterInactivateMessageProcessor.java | 58 ++
...StatusClusterTerminatedMessageProcessor.java | 58 ++
...tatusClusterTerminatingMessageProcessor.java | 58 ++
...AppStatusGroupActivatedMessageProcessor.java | 61 ++
...pStatusGroupInactivatedMessageProcessor.java | 61 ++
...ppStatusGroupTerminatedMessageProcessor.java | 61 ++
...pStatusGroupTerminatingMessageProcessor.java | 61 ++
.../status/AppStatusMessageProcessorChain.java | 126 +++
.../ApplicationActivatedMessageProcessor.java | 104 +++
.../ApplicationCreatedMessageProcessor.java | 121 +++
.../ApplicationInactivatedMessageProcessor.java | 104 +++
.../ApplicationTerminatedMessageProcessor.java | 136 +++
.../ApplicationTerminatingMessageProcessor.java | 104 +++
.../ApplicationUndeployedMessageProcessor.java | 136 +++
.../topology/ClusterActivatedProcessor.java | 133 +++
.../ClusterCreatedMessageProcessor.java | 130 +--
.../topology/ClusterInActivateProcessor.java | 131 +++
.../ClusterMaintenanceModeMessageProcessor.java | 115 ---
.../ClusterRemovedMessageProcessor.java | 105 ++-
.../topology/ClusterTerminatedProcessor.java | 133 +++
.../topology/ClusterTerminatingProcessor.java | 133 +++
.../CompleteTopologyMessageProcessor.java | 210 +++--
.../topology/GroupActivatedProcessor.java | 104 +++
.../topology/GroupInActivateProcessor.java | 107 +++
.../topology/GroupTerminatedProcessor.java | 107 +++
.../topology/GroupTerminatingProcessor.java | 107 +++
.../InstanceSpawnedMessageProcessor.java | 151 ++--
.../MemberActivatedMessageProcessor.java | 184 ++--
.../MemberMaintenanceModeProcessor.java | 162 ++--
.../MemberReadyToShutdownMessageProcessor.java | 163 ++--
.../topology/MemberStartedMessageProcessor.java | 160 ++--
.../MemberSuspendedMessageProcessor.java | 158 ++--
.../MemberTerminatedMessageProcessor.java | 139 +--
.../ServiceCreatedMessageProcessor.java | 74 +-
.../ServiceRemovedMessageProcessor.java | 71 +-
.../topology/TopologyMessageProcessorChain.java | 98 +-
.../topology/updater/TopologyUpdater.java | 272 ++++++
.../ApplicationStatusEventMessageDelegator.java | 146 +++
.../ApplicationStatusEventMessageListener.java | 54 ++
.../ApplicationStatusEventMessageQueue.java | 26 +
.../status/ApplicationStatusEventReceiver.java | 83 ++
.../topology/TopologyEventMessageDelegator.java | 10 +-
.../receiver/topology/TopologyManager.java | 234 ++++-
.../stratos/messaging/util/Constants.java | 14 +-
.../org/apache/stratos/messaging/util/Util.java | 66 +-
.../topology/locking/TopologyLockingTest.java | 208 +++++
.../org.apache.stratos.metadata.client/pom.xml | 67 ++
.../metadata/client/beans/PropertyBean.java | 65 ++
.../client/config/MetaDataClientConfig.java | 125 +++
.../defaults/DefaultMetaDataServiceClient.java | 131 +++
.../client/defaults/MetaDataServiceClient.java | 69 ++
.../MetaDataServiceClientException.java | 48 +
.../client/exception/RestClientException.java | 48 +
.../metadata/client/rest/DefaultRestClient.java | 171 ++++
.../client/rest/HTTPConnectionManager.java | 50 ++
.../metadata/client/rest/RestClient.java | 53 ++
.../client/util/MetaDataClientConstants.java | 32 +
.../org.apache.stratos.metadataservice/pom.xml | 164 ++++
.../stratos/metadataservice/Constants.java | 28 +
.../stratos/metadataservice/ServiceHolder.java | 84 ++
.../apache/stratos/metadataservice/Utils.java | 44 +
.../annotation/AuthorizationAction.java | 36 +
.../annotation/SuperTenantService.java | 34 +
.../context/AuthenticationContext.java | 40 +
.../definition/ApplicationBean.java | 70 ++
.../definition/CartridgeMetaData.java | 36 +
.../metadataservice/definition/ClusterBean.java | 59 ++
.../metadataservice/definition/NewProperty.java | 68 ++
.../definition/PropertyBean.java | 37 +
.../exception/MetadataException.java | 9 +
.../exception/RestAPIException.java | 70 ++
...tractAuthenticationAuthorizationHandler.java | 56 ++
.../CookieBasedAuthenticationHandler.java | 94 ++
.../handlers/CustomExceptionMapper.java | 47 +
.../CustomThrowableExceptionMapper.java | 44 +
.../handlers/GenericExceptionMapper.java | 54 ++
.../metadataservice/handlers/OAuthHandler.java | 95 ++
.../handlers/StratosAuthenticationHandler.java | 156 ++++
.../handlers/StratosAuthorizingHandler.java | 333 +++++++
.../metadataservice/listener/TopologyAgent.java | 130 +++
.../listener/TopologyListener.java | 69 ++
.../oauth2/ValidationServiceClient.java | 65 ++
.../registry/CarbonRegistry.java | 192 ++++
.../registry/DataRegistryFactory.java | 36 +
.../metadataservice/registry/DataStore.java | 40 +
.../metadataservice/registry/GRegRegistry.java | 109 +++
.../security/StratosPrincipal.java | 53 ++
.../security/StratosSecurityContext.java | 50 ++
.../metadataservice/services/MetaDataAdmin.java | 188 ++++
.../stratos/metadataservice/util/ConfUtil.java | 76 ++
.../src/main/resources/axis2_client.xml | 299 +++++++
.../META-INF/webapp-classloading.xml | 35 +
.../WEB-INF/cxf-servlet.xml | 46 +
.../stratosmetadataservice-test/WEB-INF/web.xml | 40 +
.../META-INF/webapp-classloading.xml | 35 +
.../WEB-INF/cxf-servlet.xml | 80 ++
.../stratosmetadataservice/WEB-INF/web.xml | 42 +
.../rest/endpoint/bean/ApplicationBean.java | 49 +
.../rest/endpoint/bean/CartridgeInfoBean.java | 3 +-
.../stratos/rest/endpoint/bean/GroupBean.java | 86 ++
.../definition/CartridgeDefinitionBean.java | 13 +-
.../rest/endpoint/bean/topology/Cluster.java | 2 +-
.../bean/util/converter/PojoConverter.java | 164 ++++
.../stratos/rest/endpoint/services/MyType.java | 16 -
.../rest/endpoint/services/ServiceUtils.java | 260 +++++-
.../rest/endpoint/services/StratosAdmin.java | 145 +++
.../webapp/stratos/WEB-INF/schemas/schema.xsd | 67 ++
components/pom.xml | 5 +-
.../pom.xml | 111 +++
features/common/pom.xml | 37 +
.../pom.xml | 320 +++++++
.../src/main/resources/p2.inf | 23 +
.../src/main/resources/tomcat/context.xml | 36 +
.../tomcat/webapp-classloading-environments.xml | 68 ++
.../resources/tomcat/webapp-classloading.xml | 33 +
features/manager/pom.xml | 1 +
.../pom.xml | 10 +
features/pom.xml | 1 +
.../conf/templates/jndi.properties.template | 27 +
.../modules/distribution/src/assembly/bin.xml | 24 +-
.../modules/distribution/src/bin/stratos.sh | 7 +-
.../src/main/conf/metadataservice.xml | 43 +
.../distribution/src/main/conf/mincheck.drl | 84 ++
.../src/main/conf/terminatedependency.drl | 52 ++
.../distribution/src/main/license/LICENSE | 4 +-
products/stratos/modules/p2-profile-gen/pom.xml | 48 +-
products/stratos/pom.xml | 1 +
.../pom.xml | 7 +-
.../deployment_script.sh | 36 +
.../m1-samples/ec2/autoscale-policy.json | 14 +
.../m1-samples/ec2/deployment-policy.json | 14 +
.../ec2/m1_single_subsciption_app.json | 19 +
.../m1-samples/ec2/p1.json | 10 +
.../m1-samples/ec2/php-cart.json | 38 +
.../m1-samples/os/autoscale-policy.json | 14 +
.../m1-samples/os/deployment-policy.json | 14 +
.../os/m1_single_subsciption_app.json | 19 +
.../m1-samples/os/p1.json | 10 +
.../m1-samples/os/php-cart.json | 46 +
.../samples/ec2/autoscale-policy 2.json | 17 +
.../samples/ec2/autoscale-policy.json | 14 +
.../samples/ec2/deployment-policy 2.json | 14 +
.../samples/ec2/deployment-policy.json | 14 +
.../samples/ec2/group1.json | 9 +
.../samples/ec2/group2.json | 15 +
.../samples/ec2/m1_single_subsciption_app.json | 19 +
.../samples/ec2/m2_single_subsciption_app.json | 95 ++
.../samples/ec2/mysql.json | 33 +
.../samples/ec2/mytest.json | 33 +
.../samples/ec2/p1.json | 10 +
.../samples/ec2/php-cart.json | 38 +
.../samples/ec2/tomcat.json | 33 +
.../samples/ec2/tomcat1.json | 33 +
.../samples/os/autoscale-policy.json | 14 +
.../samples/os/deployment-policy.json | 14 +
.../samples/os/m1_single_subsciption_app.json | 19 +
.../samples/os/p1.json | 10 +
.../samples/os/php-cart.json | 46 +
.../mysql/templates/instance-activated.sh.erb | 28 +
.../mysql/templates/instance-started.sh.erb | 43 +
.../templates/mysql_root_password_setter.sh.erb | 16 +
.../mysql/templates/publish-metadata.py.erb | 95 ++
tools/stratos-installer/conf/setup.conf | 5 +
.../all/repository/conf/metadataservice.xml | 37 +
.../config/greg/repository/conf/carbon.xml | 609 +++++++++++++
tools/stratos-installer/setup.sh | 29 +
tools/stratos-installer/start-servers.sh | 7 +-
433 files changed, 30504 insertions(+), 1771 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/stratos/blob/17cc86eb/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/PartitionContext.java
----------------------------------------------------------------------
diff --cc components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/PartitionContext.java
index 07014e4,d0886a3..520cf86
--- 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
@@@ -23,18 -31,11 +31,20 @@@ import java.util.HashSet
import java.util.Iterator;
import java.util.List;
import java.util.Map;
+import java.util.Map.Entry;
import java.util.Properties;
+ import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
+ import java.util.concurrent.CopyOnWriteArrayList;
+import org.apache.commons.configuration.XMLConfiguration;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.autoscaler.util.ConfUtil;
+import org.apache.stratos.cloud.controller.stub.deployment.partition.Partition;
+import org.apache.stratos.cloud.controller.stub.pojo.MemberContext;
+import org.apache.stratos.common.constants.StratosConstants;
+
/**
* This is an object that inserted to the rules engine.
http://git-wip-us.apache.org/repos/asf/stratos/blob/17cc86eb/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/health/AutoscalerHealthStatEventReceiver.java
----------------------------------------------------------------------
diff --cc components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/health/AutoscalerHealthStatEventReceiver.java
index 88d8dee,f192cee..cd9aa9d
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/health/AutoscalerHealthStatEventReceiver.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/health/AutoscalerHealthStatEventReceiver.java
@@@ -105,22 -84,34 +105,22 @@@ public class AutoscalerHealthStatEventR
healthStatEventReceiver.addEventListener(new AverageLoadAverageEventListener() {
@Override
protected void onEvent(org.apache.stratos.messaging.event.Event event) {
- AverageLoadAverageEvent e = (AverageLoadAverageEvent) event;
- String clusterId = e.getClusterId();
- String networkPartitionId = e.getNetworkPartitionId();
-
- Float floatValue = e.getValue();
-
- if (log.isDebugEnabled()) {
- log.debug(String.format("Avg load avg event: [cluster] %s [network-partition] %s [value] %s",
- clusterId, networkPartitionId, floatValue));
- }
- AbstractClusterMonitor monitor = getMonitor(clusterId);
- if(null != monitor){
- NetworkPartitionContext networkPartitionContext = monitor.getNetworkPartitionCtxt(networkPartitionId);
- if(null != networkPartitionContext){
- networkPartitionContext.setAverageLoadAverage(floatValue);
- } else {
- if(log.isDebugEnabled()) {
- log.debug(String.format("Network partition context is not available for :" +
- " [network partition] %s", networkPartitionId));
- }
+ AverageLoadAverageEvent averageLoadAverageEvent = (AverageLoadAverageEvent) event;
+ String clusterId = averageLoadAverageEvent.getClusterId();
+ AutoscalerContext asCtx = AutoscalerContext.getInstance();
+ AbstractClusterMonitor monitor;
+ monitor = asCtx.getClusterMonitor(clusterId);
+ if (null == monitor) {
+ if (log.isDebugEnabled()) {
+ log.debug(String.format("A cluster monitor is not found in autoscaler context "
+ + "[cluster] %s", clusterId));
}
- } else {
return;
}
-
+ monitor.handleAverageLoadAverageEvent(averageLoadAverageEvent);
}
- });
+ });
healthStatEventReceiver.addEventListener(new AverageMemoryConsumptionEventListener() {
@Override
protected void onEvent(org.apache.stratos.messaging.event.Event event) {
http://git-wip-us.apache.org/repos/asf/stratos/blob/17cc86eb/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/rule/AutoscalerRuleEvaluator.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/stratos/blob/17cc86eb/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/rule/RuleTasksDelegator.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/stratos/blob/17cc86eb/components/org.apache.stratos.cartridge.agent/src/main/java/org/apache/stratos/cartridge/agent/CartridgeAgent.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/stratos/blob/17cc86eb/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/RestCommandLineService.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/stratos/blob/17cc86eb/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/StratosApplication.java
----------------------------------------------------------------------
diff --cc components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/StratosApplication.java
index a528e61,5031aed..9fcaf9b
--- a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/StratosApplication.java
+++ b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/StratosApplication.java
@@@ -442,10 -444,10 +446,10 @@@ public class StratosApplication extend
Command<StratosCommandContext> command = commands.get(action);
if (command == null) {
System.out.println(action + ": command not found.");
- return CliConstants.BAD_ARGS_CODE;
+ return CliConstants.COMMAND_FAILED;
}
try {
- return command.execute(context, actionArgs);
+ return command.execute(context, actionArgs, new Option[0]);
} catch (CommandException e) {
if (logger.isErrorEnabled()) {
logger.error("Error executing command: " + action, e);
http://git-wip-us.apache.org/repos/asf/stratos/blob/17cc86eb/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/ActivateTenantCommand.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/stratos/blob/17cc86eb/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/AddDomainMappingCommand.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/stratos/blob/17cc86eb/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/AddTenantCommand.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/stratos/blob/17cc86eb/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/DeactivateTenantCommand.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/stratos/blob/17cc86eb/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/DeleteTenantCommand.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/stratos/blob/17cc86eb/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/DescribeAutoScalingPolicyCommand.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/stratos/blob/17cc86eb/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/DescribeCartridgeCommand.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/stratos/blob/17cc86eb/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/DescribeDeploymentPolicyCommand.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/stratos/blob/17cc86eb/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/DescribePartitionCommand.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/stratos/blob/17cc86eb/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/ExitCommand.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/stratos/blob/17cc86eb/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/HelpCommand.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/stratos/blob/17cc86eb/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/InfoCommand.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/stratos/blob/17cc86eb/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/ListAllTenants.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/stratos/blob/17cc86eb/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/ListCartridgesCommand.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/stratos/blob/17cc86eb/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/ListDeployServiceCommand.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/stratos/blob/17cc86eb/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/ListMemberCommand.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/stratos/blob/17cc86eb/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/SyncCommand.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/stratos/blob/17cc86eb/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/UndeployCartridgeDefinitionCommand.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/stratos/blob/17cc86eb/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/UndeployServiceDefinitionCommand.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/stratos/blob/17cc86eb/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/UnsubscribeCommand.java
----------------------------------------------------------------------
diff --cc components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/UnsubscribeCommand.java
index c56db7d,20f3676..ff4967a
--- a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/UnsubscribeCommand.java
+++ b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/UnsubscribeCommand.java
@@@ -92,10 -97,10 +97,10 @@@ public class UnsubscribeCommand impleme
logger.debug("Unsubscribe: not enough arguments");
}
context.getStratosApplication().printUsage(getName());
- return CliConstants.BAD_ARGS_CODE;
+ return CliConstants.COMMAND_FAILED;
}
- if (commandLine.hasOption(CliConstants.FORCE_OPTION)) {
+ if (opts.hasOption(CliConstants.FORCE_OPTION)) {
if (logger.isTraceEnabled()) {
logger.trace("Force option is passed");
}
http://git-wip-us.apache.org/repos/asf/stratos/blob/17cc86eb/components/org.apache.stratos.cloud.controller/pom.xml
----------------------------------------------------------------------
diff --cc components/org.apache.stratos.cloud.controller/pom.xml
index c66dd7d,ce3c635..1f63e3f
--- a/components/org.apache.stratos.cloud.controller/pom.xml
+++ b/components/org.apache.stratos.cloud.controller/pom.xml
@@@ -55,8 -55,9 +55,9 @@@
org.apache.stratos.cloud.controller.topology.*,
org.apache.stratos.cloud.controller.iaases.*,
org.apache.stratos.cloud.controller.pojo.*,
- org.apache.stratos.cloud.controller.pojo.application.*,
org.apache.stratos.cloud.controller.deployers.*,
org.apache.stratos.cloud.controller.exception.*,
++ org.apache.stratos.cloud.controller.pojo.application.*,
</Export-Package>
<Private-Package>
!org.apache.stratos.cloud.controller.interfaces.*,
http://git-wip-us.apache.org/repos/asf/stratos/blob/17cc86eb/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/AWSEC2Iaas.java
----------------------------------------------------------------------
diff --cc components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/AWSEC2Iaas.java
index 435df18,3e46e52..a637edc
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/AWSEC2Iaas.java
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/AWSEC2Iaas.java
@@@ -95,7 -95,11 +95,11 @@@ public class AWSEC2Iaas extends Iaas
// set image id specified
templateBuilder.imageId(iaasInfo.getImage());
+ if(!(iaasInfo instanceof IaasProvider)) {
+ templateBuilder.locationId(iaasInfo.getType());
+ }
+
- /*if(iaasInfo.getProperty(CloudControllerConstants.AVAILABILITY_ZONE) != null) {
+ if(iaasInfo.getProperty(CloudControllerConstants.AVAILABILITY_ZONE) != null) {
Set<? extends Location> locations = iaasInfo.getComputeService().listAssignableLocations();
for(Location location : locations) {
if(location.getScope().toString().equalsIgnoreCase(CloudControllerConstants.ZONE_ELEMENT) &&
http://git-wip-us.apache.org/repos/asf/stratos/blob/17cc86eb/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/OpenstackNovaIaas.java
----------------------------------------------------------------------
[28/50] [abbrv] git commit: fixing STRATOS-921
Posted by im...@apache.org.
fixing STRATOS-921
Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/636d9bb0
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/636d9bb0
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/636d9bb0
Branch: refs/heads/docker-grouping-merge
Commit: 636d9bb0e85a6e91d454157cdce61851738c0a6d
Parents: ae75efc
Author: Isuru Haththotuwa <is...@apache.org>
Authored: Tue Oct 28 19:59:23 2014 +0530
Committer: Isuru Haththotuwa <is...@apache.org>
Committed: Tue Oct 28 19:59:34 2014 +0530
----------------------------------------------------------------------
.../topic/InstanceNotificationPublisher.java | 42 ++++++++++++++++++++
.../AutoscalerTopologyEventReceiver.java | 32 ++++++++++++---
.../impl/CloudControllerServiceImpl.java | 2 +-
3 files changed, 69 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/stratos/blob/636d9bb0/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/InstanceNotificationPublisher.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/InstanceNotificationPublisher.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/InstanceNotificationPublisher.java
new file mode 100644
index 0000000..d745d79
--- /dev/null
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/InstanceNotificationPublisher.java
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.stratos.autoscaler.grouping.topic;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.messaging.broker.publish.EventPublisher;
+import org.apache.stratos.messaging.broker.publish.EventPublisherPool;
+import org.apache.stratos.messaging.event.Event;
+import org.apache.stratos.messaging.event.instance.notifier.InstanceCleanupClusterEvent;
+import org.apache.stratos.messaging.util.Constants;
+
+public class InstanceNotificationPublisher {
+ private static final Log log = LogFactory.getLog(InstanceNotificationPublisher.class);
+
+ private static void publish(Event event) {
+ EventPublisher instanceNotifyingEvent = EventPublisherPool.getPublisher(Constants.INSTANCE_NOTIFIER_TOPIC);
+ instanceNotifyingEvent.publish(event);
+ }
+
+ public static void sendInstanceCleanupEventForCluster(String clusterId) {
+ log.info(String.format("Publishing Instance Cleanup Event: [cluster] %s", clusterId));
+ publish(new InstanceCleanupClusterEvent(clusterId));
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/636d9bb0/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 99aa69c..bff46c2 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
@@ -27,6 +27,7 @@ import org.apache.stratos.autoscaler.deployment.policy.DeploymentPolicy;
import org.apache.stratos.autoscaler.exception.DependencyBuilderException;
import org.apache.stratos.autoscaler.exception.TerminationException;
import org.apache.stratos.autoscaler.exception.TopologyInConsistentException;
+import org.apache.stratos.autoscaler.grouping.topic.InstanceNotificationPublisher;
import org.apache.stratos.autoscaler.grouping.topic.StatusEventPublisher;
import org.apache.stratos.autoscaler.monitor.AbstractClusterMonitor;
import org.apache.stratos.autoscaler.monitor.ApplicationMonitorFactory;
@@ -377,8 +378,21 @@ public class AutoscalerTopologyEventReceiver implements Runnable {
if (clusterMonitor != null) {
clusterMonitorsFound = true;
clusterMonitor.setDestroyed(true);
- clusterMonitor.terminateAllMembers();
- clusterMonitor.setStatus(ClusterStatus.Terminating);
+ //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);
+ try {
+ 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());
}
@@ -526,16 +540,22 @@ public class AutoscalerTopologyEventReceiver implements Runnable {
// findClustersOfApplication(applicationRemovedEvent.getApplicationId());
for (ClusterDataHolder clusterData : clusterDataHolders) {
//stopping the cluster monitor and remove it from the AS
- ((ClusterMonitor) AutoscalerContext.getInstance().getMonitor(clusterData.getClusterId())).
- setDestroyed(true);
- AutoscalerContext.getInstance().removeMonitor(clusterData.getClusterId());
+ ClusterMonitor clusterMonitor = ((ClusterMonitor)
+ AutoscalerContext.getInstance().getMonitor(clusterData.getClusterId()));
+ if (clusterMonitor != null) {
+ clusterMonitor.setDestroyed(true);
+ AutoscalerContext.getInstance().removeMonitor(clusterData.getClusterId());
+ } else {
+ log.warn("Cluster Monitor not found for [ cluster id ] " +
+ clusterData.getClusterId() + ", unable to remove");
+ }
}
//removing the application monitor
AutoscalerContext.getInstance().
removeAppMonitor(applicationRemovedEvent.getAppId());
} else {
log.warn("Application Monitor cannot be found for the terminated [application] "
- + applicationRemovedEvent.getAppId());
+ + applicationRemovedEvent.getAppId() + ", unable to remove");
}
http://git-wip-us.apache.org/repos/asf/stratos/blob/636d9bb0/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java
index 6a337ba..6e003b1 100644
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java
@@ -916,7 +916,7 @@ public class CloudControllerServiceImpl implements CloudControllerService {
List<MemberContext> ctxts = dataHolder.getMemberContextsOfClusterId(clusterId);
- if(ctxts == null) {
+ if(ctxts == null || ctxts.isEmpty()) {
String msg = "Instance termination failed. No members found for cluster id: "+clusterId;
log.warn(msg);
return;
[26/50] [abbrv] git commit: CNF when calling metadata client
Posted by im...@apache.org.
CNF when calling metadata client
Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/7618c7b1
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/7618c7b1
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/7618c7b1
Branch: refs/heads/docker-grouping-merge
Commit: 7618c7b172df604ebf8563b278e0ea0a6d31cd3e
Parents: 1953032
Author: Udara Liyanage <ud...@wso2.com>
Authored: Tue Oct 28 16:32:09 2014 +0530
Committer: Udara Liyanage <ud...@wso2.com>
Committed: Tue Oct 28 16:32:09 2014 +0530
----------------------------------------------------------------------
components/org.apache.stratos.metadata.client/pom.xml | 4 ++--
.../org.apache.stratos.metadata.client.feature/pom.xml | 13 +++++++++++--
2 files changed, 13 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/stratos/blob/7618c7b1/components/org.apache.stratos.metadata.client/pom.xml
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.metadata.client/pom.xml b/components/org.apache.stratos.metadata.client/pom.xml
index 4f92ca7..11daa79 100644
--- a/components/org.apache.stratos.metadata.client/pom.xml
+++ b/components/org.apache.stratos.metadata.client/pom.xml
@@ -18,13 +18,12 @@
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.3.5</version>
- <scope>provided</scope>
</dependency>
<dependency>
<groupId>commons-configuration</groupId>
<artifactId>commons-configuration</artifactId>
<version>1.9</version>
- <scope>provided</scope>
+ <!-- <scope>provided</scope>-->
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
@@ -55,6 +54,7 @@
!org.apache.stratos.metadata.client,
org.apache.commons.logging; version=0.0.0,
org.apache.commons.configuration; version=0.0.0,
+ org.apache.http.conn.ssl;version=0.0.0,
*;resolution:=optional
</Import-Package>
<DynamicImport-Package>*</DynamicImport-Package>
http://git-wip-us.apache.org/repos/asf/stratos/blob/7618c7b1/features/common/org.apache.stratos.metadata.client.feature/pom.xml
----------------------------------------------------------------------
diff --git a/features/common/org.apache.stratos.metadata.client.feature/pom.xml b/features/common/org.apache.stratos.metadata.client.feature/pom.xml
index 6a8402f..09857d0 100644
--- a/features/common/org.apache.stratos.metadata.client.feature/pom.xml
+++ b/features/common/org.apache.stratos.metadata.client.feature/pom.xml
@@ -50,6 +50,17 @@
<artifactId>httpclient-osgi</artifactId>
<version>4.3.5</version>
</dependency>
+ <dependency>
+ <groupId>org.apache.httpcomponents</groupId>
+ <artifactId>httpclient</artifactId>
+ <version>4.3.5</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.httpcomponents</groupId>
+ <artifactId>httpcore</artifactId>
+ <version>4.3.2</version>
+ </dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpcore-osgi</artifactId>
@@ -88,10 +99,8 @@
<bundleDef>org.apache.stratos:org.apache.stratos.metadata.client:${project.version}</bundleDef>
<bundleDef>com.google.code.gson:gson:${gson2.version}</bundleDef>
<bundleDef>org.apache.commons:commons-lang3:3.1</bundleDef>
-<!--
<bundleDef>org.apache.httpcomponents:httpclient-osgi:4.3.5</bundleDef>
<bundleDef>org.apache.httpcomponents:httpcore-osgi:4.3.2</bundleDef>
--->
</bundles>
</configuration>
</execution>
[21/50] [abbrv] git commit: fixing STRATOS-918
Posted by im...@apache.org.
fixing STRATOS-918
Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/097e884b
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/097e884b
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/097e884b
Branch: refs/heads/docker-grouping-merge
Commit: 097e884bd2e5c5942c3023eb5b5cbbf6d82331bf
Parents: dd210b5
Author: Isuru Haththotuwa <is...@apache.org>
Authored: Tue Oct 28 12:13:04 2014 +0530
Committer: Isuru Haththotuwa <is...@apache.org>
Committed: Tue Oct 28 12:13:04 2014 +0530
----------------------------------------------------------------------
.../topology/AutoscalerTopologyEventReceiver.java | 13 +++++++++++++
1 file changed, 13 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/stratos/blob/097e884b/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 9109d50..e5bbd55 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
@@ -27,6 +27,7 @@ import org.apache.stratos.autoscaler.deployment.policy.DeploymentPolicy;
import org.apache.stratos.autoscaler.exception.DependencyBuilderException;
import org.apache.stratos.autoscaler.exception.TerminationException;
import org.apache.stratos.autoscaler.exception.TopologyInConsistentException;
+import org.apache.stratos.autoscaler.grouping.topic.StatusEventPublisher;
import org.apache.stratos.autoscaler.monitor.AbstractClusterMonitor;
import org.apache.stratos.autoscaler.monitor.ApplicationMonitorFactory;
import org.apache.stratos.autoscaler.monitor.application.ApplicationMonitor;
@@ -364,11 +365,13 @@ public class AutoscalerTopologyEventReceiver implements Runnable {
// 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();
clusterMonitor.setStatus(ClusterStatus.Terminating);
@@ -377,9 +380,19 @@ public class AutoscalerTopologyEventReceiver implements Runnable {
}
}
+ // 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 {
[22/50] [abbrv] git commit: adding the valid transition check for
status changes
Posted by im...@apache.org.
adding the valid transition check for status changes
Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/2ae7e2b9
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/2ae7e2b9
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/2ae7e2b9
Branch: refs/heads/docker-grouping-merge
Commit: 2ae7e2b947f9ad1635fecad739643f2379807efe
Parents: 097e884
Author: reka <rt...@gmail.com>
Authored: Tue Oct 28 13:14:40 2014 +0530
Committer: reka <rt...@gmail.com>
Committed: Tue Oct 28 13:14:48 2014 +0530
----------------------------------------------------------------------
.../grouping/topic/StatusEventPublisher.java | 198 ++++++++++++++-----
.../AutoscalerTopologyEventReceiver.java | 22 ++-
.../monitor/AbstractClusterMonitor.java | 24 +--
.../monitor/application/ApplicationMonitor.java | 4 +-
.../autoscaler/monitor/group/GroupMonitor.java | 17 +-
5 files changed, 183 insertions(+), 82 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/stratos/blob/2ae7e2b9/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/StatusEventPublisher.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/StatusEventPublisher.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/StatusEventPublisher.java
index fece506..5b09a21 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/StatusEventPublisher.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/StatusEventPublisher.java
@@ -7,13 +7,6 @@ import org.apache.stratos.messaging.broker.publish.EventPublisherPool;
import org.apache.stratos.messaging.domain.topology.*;
import org.apache.stratos.messaging.event.Event;
import org.apache.stratos.messaging.event.application.status.*;
-import org.apache.stratos.messaging.event.application.status.AppStatusApplicationActivatedEvent;
-import org.apache.stratos.messaging.event.application.status.AppStatusApplicationInactivatedEvent;
-import org.apache.stratos.messaging.event.application.status.AppStatusApplicationTerminatedEvent;
-import org.apache.stratos.messaging.event.application.status.AppStatusApplicationTerminatingEvent;
-import org.apache.stratos.messaging.event.application.status.AppStatusClusterActivatedEvent;
-import org.apache.stratos.messaging.event.application.status.AppStatusClusterInactivateEvent;
-import org.apache.stratos.messaging.event.application.status.AppStatusGroupActivatedEvent;
import org.apache.stratos.messaging.message.receiver.topology.TopologyManager;
import org.apache.stratos.messaging.util.Constants;
@@ -32,10 +25,23 @@ public class StatusEventPublisher {
" [cluster]: " + clusterId);
}
- AppStatusClusterActivatedEvent clusterActivatedEvent =
- new AppStatusClusterActivatedEvent(appId, serviceName, clusterId);
-
- publishEvent(clusterActivatedEvent);
+ try {
+ TopologyManager.acquireReadLockForCluster(serviceName, clusterId);
+ Service service = TopologyManager.getTopology().getService(serviceName);
+ if (service != null) {
+ Cluster cluster = service.getCluster(clusterId);
+ if (cluster.isStateTransitionValid(ClusterStatus.Active)) {
+ AppStatusClusterActivatedEvent clusterActivatedEvent =
+ new AppStatusClusterActivatedEvent(appId, serviceName, clusterId);
+
+ publishEvent(clusterActivatedEvent);
+ } else {
+ log.warn("Active is not in the possible state list of [cluster] " + clusterId);
+ }
+ }
+ } finally {
+ TopologyManager.releaseReadLockForCluster(serviceName, clusterId);
+ }
}
public static void sendClusterInActivateEvent(String appId, String serviceName, String clusterId) {
@@ -45,36 +51,77 @@ public class StatusEventPublisher {
" [cluster]: " + clusterId);
}
- AppStatusClusterInactivateEvent clusterInActivateEvent =
- new AppStatusClusterInactivateEvent(appId, serviceName, clusterId);
+ try {
+ TopologyManager.acquireReadLockForCluster(serviceName, clusterId);
+ Service service = TopologyManager.getTopology().getService(serviceName);
+ if (service != null) {
+ Cluster cluster = service.getCluster(clusterId);
+ if (cluster.isStateTransitionValid(ClusterStatus.Inactive)) {
+ AppStatusClusterInactivateEvent clusterInActivateEvent =
+ new AppStatusClusterInactivateEvent(appId, serviceName, clusterId);
+
+ publishEvent(clusterInActivateEvent);
+ } else {
+ log.warn("In-active is not in the possible state list of [cluster] " + clusterId);
+ }
+ }
+ } finally {
+ TopologyManager.releaseReadLockForCluster(serviceName, clusterId);
- publishEvent(clusterInActivateEvent);
+ }
}
public static void sendClusterTerminatingEvent(String appId, String serviceName, String clusterId) {
if (log.isInfoEnabled()) {
- log.info("Publishing Cluster in-activate event for [application]: " + appId +
+ log.info("Publishing Cluster Terminating event for [application]: " + appId +
" [cluster]: " + clusterId);
}
- //TODO
- AppStatusClusterTerminatingEvent appStatusClusterTerminatingEvent =
- new AppStatusClusterTerminatingEvent(appId, serviceName, clusterId);
+ try {
+ TopologyManager.acquireReadLockForCluster(serviceName, clusterId);
+ Service service = TopologyManager.getTopology().getService(serviceName);
+ if (service != null) {
+ Cluster cluster = service.getCluster(clusterId);
+ if (cluster.isStateTransitionValid(ClusterStatus.Terminating)) {
+ AppStatusClusterTerminatingEvent appStatusClusterTerminatingEvent =
+ new AppStatusClusterTerminatingEvent(appId, serviceName, clusterId);
+
+ publishEvent(appStatusClusterTerminatingEvent);
+ } else {
+ log.warn("Terminating is not in the possible state list of [cluster] " + clusterId);
+ }
+ }
+ } finally {
+ TopologyManager.releaseReadLockForCluster(serviceName, clusterId);
+
+ }
- publishEvent(appStatusClusterTerminatingEvent);
}
public static void sendClusterTerminatedEvent(String appId, String serviceName, String clusterId) {
if (log.isInfoEnabled()) {
- log.info("Publishing Cluster in-activate event for [application]: " + appId +
+ log.info("Publishing Cluster terminated event for [application]: " + appId +
" [cluster]: " + clusterId);
}
+ try {
+ TopologyManager.acquireReadLockForCluster(serviceName, clusterId);
+ Service service = TopologyManager.getTopology().getService(serviceName);
+ if (service != null) {
+ Cluster cluster = service.getCluster(clusterId);
+ if (cluster.isStateTransitionValid(ClusterStatus.Terminated)) {
+ AppStatusClusterTerminatedEvent appStatusClusterTerminatedEvent =
+ new AppStatusClusterTerminatedEvent(appId, serviceName, clusterId);
+
+ publishEvent(appStatusClusterTerminatedEvent);
+ } else {
+ log.warn("Terminated is not in the possible state list of [cluster] " + clusterId);
+ }
+ }
+ } finally {
+ TopologyManager.releaseReadLockForCluster(serviceName, clusterId);
- AppStatusClusterTerminatedEvent appStatusClusterTerminatedEvent =
- new AppStatusClusterTerminatedEvent(appId, serviceName, clusterId);
-
- publishEvent(appStatusClusterTerminatedEvent);
+ }
}
public static void sendGroupActivatedEvent(String appId, String groupId) {
@@ -87,9 +134,9 @@ public class StatusEventPublisher {
try {
TopologyManager.acquireReadLockForApplication(appId);
Application application = TopologyManager.getTopology().getApplication(appId);
- if(application != null) {
+ if (application != null) {
Group group = application.getGroupRecursively(groupId);
- if(group.getStatus().getNextStates().contains(GroupStatus.Active)) {
+ if (group.isStateTransitionValid(GroupStatus.Active)) {
AppStatusGroupActivatedEvent groupActivatedEvent =
new AppStatusGroupActivatedEvent(appId, groupId);
@@ -101,8 +148,6 @@ public class StatusEventPublisher {
} finally {
TopologyManager.releaseReadLockForApplication(appId);
}
-
-
}
public static void sendGroupInActivateEvent(String appId, String groupId) {
@@ -114,10 +159,10 @@ public class StatusEventPublisher {
try {
TopologyManager.acquireReadLockForApplication(appId);
Application application = TopologyManager.getTopology().getApplication(appId);
- if(application != null) {
+ if (application != null) {
Group group = application.getGroupRecursively(groupId);
- if(group.getStatus().getNextStates().contains(GroupStatus.Inactive)) {
- AppStatusGroupInactivateEvent appStatusGroupInactivateEvent= new
+ if (group.isStateTransitionValid(GroupStatus.Inactive)) {
+ AppStatusGroupInactivateEvent appStatusGroupInactivateEvent = new
AppStatusGroupInactivateEvent(appId, groupId);
publishEvent(appStatusGroupInactivateEvent);
@@ -128,8 +173,6 @@ public class StatusEventPublisher {
} finally {
TopologyManager.releaseReadLockForApplication(appId);
}
-
-
}
public static void sendGroupTerminatingEvent(String appId, String groupId) {
@@ -141,9 +184,9 @@ public class StatusEventPublisher {
try {
TopologyManager.acquireReadLockForApplication(appId);
Application application = TopologyManager.getTopology().getApplication(appId);
- if(application != null) {
+ if (application != null) {
Group group = application.getGroupRecursively(groupId);
- if(group.getStatus().getNextStates().contains(GroupStatus.Terminating)) {
+ if (group.isStateTransitionValid(GroupStatus.Terminating)) {
AppStatusGroupTerminatingEvent groupInTerminatingEvent =
new AppStatusGroupTerminatingEvent(appId, groupId);
publishEvent(groupInTerminatingEvent);
@@ -166,9 +209,9 @@ public class StatusEventPublisher {
try {
TopologyManager.acquireReadLockForApplication(appId);
Application application = TopologyManager.getTopology().getApplication(appId);
- if(application != null) {
+ if (application != null) {
Group group = application.getGroupRecursively(groupId);
- if(group.getStatus().getNextStates().contains(GroupStatus.Terminated)) {
+ if (group.isStateTransitionValid(GroupStatus.Terminated)) {
AppStatusGroupTerminatedEvent groupInTerminatedEvent =
new AppStatusGroupTerminatedEvent(appId, groupId);
publishEvent(groupInTerminatedEvent);
@@ -189,40 +232,87 @@ public class StatusEventPublisher {
log.info("Publishing Application activated event for [application]: " + appId);
}
- AppStatusApplicationActivatedEvent applicationActivatedEvent = new AppStatusApplicationActivatedEvent(appId);
+ try {
+ TopologyManager.acquireReadLockForApplication(appId);
+ Application application = TopologyManager.getTopology().getApplication(appId);
+ if (application != null) {
+ if (application.isStateTransitionValid(ApplicationStatus.Active)) {
+ AppStatusApplicationActivatedEvent applicationActivatedEvent =
+ new AppStatusApplicationActivatedEvent(appId);
- publishEvent(applicationActivatedEvent);
+ publishEvent(applicationActivatedEvent);
+ } else {
+ log.warn("Active is not in the possible state list of [application] " + appId);
+ }
+ }
+ } finally {
+ TopologyManager.releaseReadLockForApplication(appId);
+ }
}
- public static void sendApplicationInactivatedEvent(String appId){
+ public static void sendApplicationInactivatedEvent(String appId) {
if (log.isInfoEnabled()) {
- log.info("Publishing Application Inactivated event for [application]: " + appId);
+ log.info("Publishing Application In-activated event for [application]: " + appId);
}
- AppStatusApplicationInactivatedEvent applicationInActivatedEvent = new AppStatusApplicationInactivatedEvent(appId);
-
- publishEvent(applicationInActivatedEvent);
+ try {
+ TopologyManager.acquireReadLockForApplication(appId);
+ Application application = TopologyManager.getTopology().getApplication(appId);
+ if (application != null) {
+ if (application.isStateTransitionValid(ApplicationStatus.Inactive)) {
+ AppStatusApplicationInactivatedEvent applicationInActivatedEvent =
+ new AppStatusApplicationInactivatedEvent(appId);
+ publishEvent(applicationInActivatedEvent);
+ } else {
+ log.warn("Inactive is not in the possible state list of [application] " + appId);
+ }
+ }
+ } finally {
+ TopologyManager.releaseReadLockForApplication(appId);
+ }
}
- public static void sendApplicationTerminatingEvent (String appId) {
+ public static void sendApplicationTerminatingEvent(String appId) {
if (log.isInfoEnabled()) {
log.info("Publishing Application terminated event for [application]: " + appId);
}
- AppStatusApplicationTerminatingEvent applicationTerminatingEvent = new AppStatusApplicationTerminatingEvent(appId);
-
- publishEvent(applicationTerminatingEvent);
+ try {
+ TopologyManager.acquireReadLockForApplication(appId);
+ Application application = TopologyManager.getTopology().getApplication(appId);
+ if (application != null) {
+ if (application.isStateTransitionValid(ApplicationStatus.Terminating)) {
+ AppStatusApplicationTerminatingEvent applicationTerminatingEvent =
+ new AppStatusApplicationTerminatingEvent(appId);
+ publishEvent(applicationTerminatingEvent);
+ } else {
+ log.warn("Terminating is not in the possible state list of [application] " + appId);
+ }
+ }
+ } finally {
+ TopologyManager.releaseReadLockForApplication(appId);
+ }
}
- public static void sendApplicationTerminatedEvent (String appId, Set<ClusterDataHolder> clusterData) {
+ public static void sendApplicationTerminatedEvent(String appId, Set<ClusterDataHolder> clusterData) {
if (log.isInfoEnabled()) {
log.info("Publishing Application terminated event for [application]: " + appId);
}
-
- AppStatusApplicationTerminatedEvent applicationTerminatedEvent =
- new AppStatusApplicationTerminatedEvent(appId, clusterData);
-
- publishEvent(applicationTerminatedEvent);
+ try {
+ TopologyManager.acquireReadLockForApplication(appId);
+ Application application = TopologyManager.getTopology().getApplication(appId);
+ if (application != null) {
+ if (application.isStateTransitionValid(ApplicationStatus.Terminated)) {
+ AppStatusApplicationTerminatedEvent applicationTerminatedEvent =
+ new AppStatusApplicationTerminatedEvent(appId, clusterData);
+ publishEvent(applicationTerminatedEvent);
+ } else {
+ log.warn("Terminated is not in the possible state list of [application] " + appId);
+ }
+ }
+ } finally {
+ TopologyManager.releaseReadLockForApplication(appId);
+ }
}
public static void publishEvent(Event event) {
http://git-wip-us.apache.org/repos/asf/stratos/blob/2ae7e2b9/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 e5bbd55..99aa69c 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
@@ -39,10 +39,6 @@ import org.apache.stratos.autoscaler.status.checker.StatusChecker;
import org.apache.stratos.messaging.domain.topology.*;
import org.apache.stratos.messaging.event.Event;
import org.apache.stratos.messaging.event.topology.*;
-import org.apache.stratos.messaging.event.topology.ApplicationActivatedEvent;
-import org.apache.stratos.messaging.event.topology.ApplicationCreatedEvent;
-import org.apache.stratos.messaging.event.topology.ClusterActivatedEvent;
-import org.apache.stratos.messaging.event.topology.GroupActivatedEvent;
import org.apache.stratos.messaging.listener.topology.*;
import org.apache.stratos.messaging.message.receiver.topology.TopologyEventReceiver;
import org.apache.stratos.messaging.message.receiver.topology.TopologyManager;
@@ -237,7 +233,9 @@ public class AutoscalerTopologyEventReceiver implements Runnable {
(AbstractClusterMonitor) AutoscalerContext.getInstance().getMonitor(clusterId);
//changing the status in the monitor, will notify its parent monitor
- clusterMonitor.setStatus(ClusterStatus.Terminated);
+ if (clusterMonitor != null) {
+ clusterMonitor.setStatus(ClusterStatus.Terminated);
+ }
//starting the status checker to decide on the status of it's parent
//StatusChecker.getInstance().onClusterStatusChange(clusterId, appId);
@@ -258,7 +256,7 @@ public class AutoscalerTopologyEventReceiver implements Runnable {
GroupMonitor monitor = (GroupMonitor) appMonitor.findGroupMonitorWithId(groupId);
//changing the status in the monitor, will notify its parent monitor
- if(monitor != null) {
+ if (monitor != null) {
monitor.setStatus(GroupStatus.Active);
}
@@ -279,7 +277,9 @@ public class AutoscalerTopologyEventReceiver implements Runnable {
GroupMonitor monitor = (GroupMonitor) appMonitor.findGroupMonitorWithId(groupId);
//changing the status in the monitor, will notify its parent monitor
- monitor.setStatus(GroupStatus.Inactive);
+ if (monitor != null) {
+ monitor.setStatus(GroupStatus.Inactive);
+ }
}
});
@@ -298,7 +298,9 @@ public class AutoscalerTopologyEventReceiver implements Runnable {
GroupMonitor monitor = (GroupMonitor) appMonitor.findGroupMonitorWithId(groupId);
//changing the status in the monitor, will notify its parent monitor
- monitor.setStatus(GroupStatus.Terminating);
+ if (monitor != null) {
+ monitor.setStatus(GroupStatus.Terminating);
+ }
}
});
@@ -317,7 +319,9 @@ public class AutoscalerTopologyEventReceiver implements Runnable {
GroupMonitor monitor = (GroupMonitor) appMonitor.findGroupMonitorWithId(groupId);
//changing the status in the monitor, will notify its parent monitor
- monitor.setStatus(GroupStatus.Terminated);
+ if (monitor != null) {
+ monitor.setStatus(GroupStatus.Terminated);
+ }
}
});
http://git-wip-us.apache.org/repos/asf/stratos/blob/2ae7e2b9/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/AbstractClusterMonitor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/AbstractClusterMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/AbstractClusterMonitor.java
index 588d2c4..0a9d628 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/AbstractClusterMonitor.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/AbstractClusterMonitor.java
@@ -228,17 +228,19 @@ abstract public class AbstractClusterMonitor extends Monitor implements Runnable
public void setStatus(ClusterStatus status) {
log.info(String.format("[Monitor] %s is notifying the parent" +
"on its state change from %s to %s", clusterId, this.status, status));
- this.status = status;
- /**
- * notifying the parent monitor about the state change
- * If the cluster in_active and if it is a in_dependent cluster,
- * then won't send the notification to parent.
- */
- if(status == ClusterStatus.Inactive && !this.hasDependent) {
- log.info("[Cluster] " + clusterId + "is not notifying the parent, " +
- "since it is identified as the independent unit");
- } else {
- MonitorStatusEventBuilder.handleClusterStatusEvent(this.parent, this.status, this.clusterId);
+ if(this.status != status) {
+ this.status = status;
+ /**
+ * notifying the parent monitor about the state change
+ * If the cluster in_active and if it is a in_dependent cluster,
+ * then won't send the notification to parent.
+ */
+ if (status == ClusterStatus.Inactive && !this.hasDependent) {
+ log.info("[Cluster] " + clusterId + "is not notifying the parent, " +
+ "since it is identified as the independent unit");
+ } else {
+ MonitorStatusEventBuilder.handleClusterStatusEvent(this.parent, this.status, this.clusterId);
+ }
}
}
http://git-wip-us.apache.org/repos/asf/stratos/blob/2ae7e2b9/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 66044ef..966c8b2 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
@@ -142,7 +142,9 @@ public class ApplicationMonitor extends ParentComponentMonitor {
public void setStatus(ApplicationStatus status) {
log.info(String.format("[ApplicationMonitor] %s " +
"state changes from %s to %s", id, this.status, status));
- this.status = status;
+ if(this.status != status) {
+ this.status = status;
+ }
}
@Override
http://git-wip-us.apache.org/repos/asf/stratos/blob/2ae7e2b9/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java
index dff0bba..ab3ef16 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java
@@ -140,13 +140,16 @@ public class GroupMonitor extends ParentComponentMonitor implements EventHandler
public void setStatus(GroupStatus status) {
log.info(String.format("[Monitor] %s is notifying the parent" +
"on its state change from %s to %s", id, this.status, status));
- this.status = status;
- //notifying the parent
- if (status == GroupStatus.Inactive && !this.hasDependent) {
- log.info("[Group] " + this.id + "is not notifying the parent, " +
- "since it is identified as the independent unit");
- } else {
- MonitorStatusEventBuilder.handleGroupStatusEvent(this.parent, this.status, this.id);
+ if(this.status != status) {
+ this.status = status;
+ //notifying the parent
+ if (status == GroupStatus.Inactive && !this.hasDependent) {
+ log.info("[Group] " + this.id + "is not notifying the parent, " +
+ "since it is identified as the independent unit");
+ } else {
+ MonitorStatusEventBuilder.handleGroupStatusEvent(this.parent, this.status, this.id);
+ }
}
+
}
}
[08/50] [abbrv] git commit: fixing fault handling issue in autoscaler
Posted by im...@apache.org.
fixing fault handling issue in autoscaler
Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/07c51099
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/07c51099
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/07c51099
Branch: refs/heads/docker-grouping-merge
Commit: 07c510997acbcbd7ab377fcbff1bd808181c3bd1
Parents: 7a5797d
Author: reka <rt...@gmail.com>
Authored: Mon Oct 27 14:11:38 2014 +0530
Committer: reka <rt...@gmail.com>
Committed: Mon Oct 27 14:14:22 2014 +0530
----------------------------------------------------------------------
.../receiver/health/AutoscalerHealthStatEventReceiver.java | 2 +-
.../apache/stratos/autoscaler/status/checker/StatusChecker.java | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/stratos/blob/07c51099/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/health/AutoscalerHealthStatEventReceiver.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/health/AutoscalerHealthStatEventReceiver.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/health/AutoscalerHealthStatEventReceiver.java
index b909749..f090fcb 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/health/AutoscalerHealthStatEventReceiver.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/health/AutoscalerHealthStatEventReceiver.java
@@ -663,7 +663,7 @@ public class AutoscalerHealthStatEventReceiver implements Runnable {
// remove from active member list
partitionCtxt.removeActiveMemberById(memberId);
//Check the clusterStatus as part of the member fault event
- StatusChecker.getInstance().onMemberFaultEvent(clusterId, "appId", partitionCtxt);
+ StatusChecker.getInstance().onMemberFaultEvent(clusterId, partitionCtxt);
if (log.isInfoEnabled()) {
http://git-wip-us.apache.org/repos/asf/stratos/blob/07c51099/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java
index 7019d0b..6309e02 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java
@@ -124,12 +124,12 @@ public class StatusChecker {
/**
* @param clusterId
- * @param appId
* @param partitionContext is to decide in which partition has less members while others have active members
*/
- public void onMemberFaultEvent(final String clusterId, final String appId, final PartitionContext partitionContext) {
+ public void onMemberFaultEvent(final String clusterId, final PartitionContext partitionContext) {
ClusterMonitor monitor = (ClusterMonitor) AutoscalerContext.getInstance().getMonitor(clusterId);
boolean clusterInActive = getClusterInActive(monitor, partitionContext);
+ String appId = monitor.getAppId();
if (clusterInActive) {
//TODO evaluate life cycle
//send cluster In-Active event to cluster status topic
[03/50] [abbrv] rename application status events,
listeners and processors with prefix appstatus
Posted by im...@apache.org.
http://git-wip-us.apache.org/repos/asf/stratos/blob/4e4ba5b3/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusMessageProcessorChain.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusMessageProcessorChain.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusMessageProcessorChain.java
new file mode 100644
index 0000000..14b8bc2
--- /dev/null
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusMessageProcessorChain.java
@@ -0,0 +1,126 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.stratos.messaging.message.processor.application.status;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.messaging.listener.EventListener;
+import org.apache.stratos.messaging.listener.application.status.*;
+import org.apache.stratos.messaging.message.processor.MessageProcessorChain;
+
+/**
+ * Application Status processor chain is to handle the list processors to parse the application
+ * status.
+ */
+public class AppStatusMessageProcessorChain extends MessageProcessorChain {
+ private static final Log log = LogFactory.getLog(AppStatusMessageProcessorChain.class);
+
+ private AppStatusClusterActivatedMessageProcessor clusterActivatedMessageProcessor;
+ private AppStatusClusterInactivateMessageProcessor clusterInActivateMessageProcessor;
+ private AppStatusClusterTerminatingMessageProcessor clusterTerminatingMessageProcessor;
+ private AppStatusClusterTerminatedMessageProcessor clusterTerminatedMessageProcessor;
+ private AppStatusGroupActivatedMessageProcessor groupActivatedMessageProcessor;
+ private AppStatusGroupInactivatedMessageProcessor groupInActivateMessageProcessor;
+ private AppStatusApplicationActivatedMessageProcessor appActivatedMessageProcessor;
+ private AppStatusApplicationCreatedMessageProcessor applicationStatusAppCreatedMessageProcessor;
+ private AppStatusApplicationInactivatedMessageProcessor applicationStatusAppInActivatedMessageProcessor;
+ private AppStatusApplicationTerminatedMessageProcessor applicationStatusAppTerminatedMessageProcessor;
+ private AppStatusApplicationTerminatingMessageProcessor applicationStatusAppTerminatingMessageProcessor;
+
+ private AppStatusGroupTerminatedMessageProcessor groupTerminatedMessageProcessor;
+ private AppStatusGroupTerminatingMessageProcessor groupTerminatingMessageProcessor;
+
+ public void initialize() {
+ // Add instance notifier event processors
+ clusterActivatedMessageProcessor = new AppStatusClusterActivatedMessageProcessor();
+ add(clusterActivatedMessageProcessor);
+
+ clusterInActivateMessageProcessor = new AppStatusClusterInactivateMessageProcessor();
+ add(clusterInActivateMessageProcessor);
+
+ clusterTerminatingMessageProcessor = new AppStatusClusterTerminatingMessageProcessor();
+ add(clusterTerminatingMessageProcessor);
+ clusterTerminatedMessageProcessor = new AppStatusClusterTerminatedMessageProcessor();
+ add(clusterTerminatedMessageProcessor);
+
+ groupActivatedMessageProcessor = new AppStatusGroupActivatedMessageProcessor();
+ add(groupActivatedMessageProcessor);
+
+ groupInActivateMessageProcessor = new AppStatusGroupInactivatedMessageProcessor();
+ add(groupInActivateMessageProcessor);
+
+ appActivatedMessageProcessor = new AppStatusApplicationActivatedMessageProcessor();
+ add(appActivatedMessageProcessor);
+
+ applicationStatusAppCreatedMessageProcessor = new AppStatusApplicationCreatedMessageProcessor();
+ this.add(applicationStatusAppCreatedMessageProcessor);
+
+ applicationStatusAppInActivatedMessageProcessor = new AppStatusApplicationInactivatedMessageProcessor();
+ this.add(applicationStatusAppInActivatedMessageProcessor);
+
+ applicationStatusAppTerminatedMessageProcessor = new AppStatusApplicationTerminatedMessageProcessor();
+ this.add(applicationStatusAppTerminatedMessageProcessor);
+
+ applicationStatusAppTerminatingMessageProcessor = new AppStatusApplicationTerminatingMessageProcessor();
+ this.add(applicationStatusAppTerminatingMessageProcessor);
+
+ groupTerminatedMessageProcessor = new AppStatusGroupTerminatedMessageProcessor();
+ this.add(groupTerminatedMessageProcessor);
+
+ groupTerminatingMessageProcessor = new AppStatusGroupTerminatingMessageProcessor();
+ this.add(groupTerminatingMessageProcessor);
+
+ if (log.isDebugEnabled()) {
+ log.debug("Instance notifier message processor chain initialized");
+ }
+ }
+
+ public void addEventListener(EventListener eventListener) {
+ if (eventListener instanceof AppStatusClusterActivatedEventListener) {
+ clusterActivatedMessageProcessor.addEventListener(eventListener);
+ } else if (eventListener instanceof AppStatusClusterInactivateEventListener) {
+ clusterInActivateMessageProcessor.addEventListener(eventListener);
+ } else if (eventListener instanceof AppStatusGroupActivatedEventListener) {
+ groupActivatedMessageProcessor.addEventListener(eventListener);
+ } else if(eventListener instanceof AppStatusClusterTerminatedEventListener){
+ clusterTerminatedMessageProcessor.addEventListener(eventListener);
+ } else if(eventListener instanceof AppStatusClusterTerminatingEventListener){
+ clusterTerminatingMessageProcessor.addEventListener(eventListener);
+ }else if (eventListener instanceof AppStatusGroupInactivateEventListener) {
+ groupInActivateMessageProcessor.addEventListener(eventListener);
+ } else if (eventListener instanceof AppStatusApplicationActivatedEventListener) {
+ appActivatedMessageProcessor.addEventListener(eventListener);
+ } else if(eventListener instanceof AppStatusApplicationInactivatedEventListener){
+ applicationStatusAppInActivatedMessageProcessor.addEventListener(eventListener);
+ } else if(eventListener instanceof AppStatusApplicationCreatedEventListener){
+ applicationStatusAppCreatedMessageProcessor.addEventListener(eventListener);
+ } else if(eventListener instanceof AppStatusApplicationTerminatingEventListener){
+ applicationStatusAppTerminatingMessageProcessor.addEventListener(eventListener);
+ } else if(eventListener instanceof AppStatusApplicationTerminatedEventListener){
+ applicationStatusAppTerminatedMessageProcessor.addEventListener(eventListener);
+ } else if (eventListener instanceof AppStatusGroupTerminatingEventListener){
+ groupTerminatingMessageProcessor.addEventListener(eventListener);
+ } else if (eventListener instanceof AppStatusGroupTerminatedEventListener){
+ groupTerminatedMessageProcessor.addEventListener(eventListener);
+ } else
+ {
+ throw new RuntimeException("Unknown event listener " + eventListener.toString());
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/4e4ba5b3/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/ApplicationStatusAppActivatedMessageProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/ApplicationStatusAppActivatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/ApplicationStatusAppActivatedMessageProcessor.java
deleted file mode 100644
index 1a46cdf..0000000
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/ApplicationStatusAppActivatedMessageProcessor.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.stratos.messaging.message.processor.application.status;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.messaging.event.application.status.ApplicationActivatedEvent;
-import org.apache.stratos.messaging.event.application.status.ClusterActivatedEvent;
-import org.apache.stratos.messaging.event.application.status.GroupActivatedEvent;
-import org.apache.stratos.messaging.message.processor.MessageProcessor;
-import org.apache.stratos.messaging.util.Util;
-
-/**
- * Created by reka on 9/25/14.
- */
-public class ApplicationStatusAppActivatedMessageProcessor extends MessageProcessor {
- private static final Log log =
- LogFactory.getLog(ApplicationStatusAppActivatedMessageProcessor.class);
-
-
- private MessageProcessor nextProcessor;
- @Override
- public void setNext(MessageProcessor nextProcessor) {
- this.nextProcessor = nextProcessor;
-
- }
-
- @Override
- public boolean process(String type, String message, Object object) {
- if (ApplicationActivatedEvent.class.getName().equals(type)) {
- // Parse complete message and build event
- ApplicationActivatedEvent event =
- (ApplicationActivatedEvent) Util.jsonToObject(message, ApplicationActivatedEvent.class);
-
- if (log.isDebugEnabled()) {
- log.debug("Received ApplicationActivatedEvent in application status topic: " + event.toString());
- }
- // Notify event listeners
- notifyEventListeners(event);
- return true;
- } else {
- if (nextProcessor != null) {
- return nextProcessor.process(type, message, object);
- } else {
- throw new RuntimeException(
- String.format("Failed to process group activated message " +
- "using available message processors: [type] %s [body] %s", type, message));
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/4e4ba5b3/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/ApplicationStatusAppCreatedMessageProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/ApplicationStatusAppCreatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/ApplicationStatusAppCreatedMessageProcessor.java
deleted file mode 100644
index 66448ac..0000000
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/ApplicationStatusAppCreatedMessageProcessor.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.stratos.messaging.message.processor.application.status;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.messaging.event.topology.ApplicationCreatedEvent;
-import org.apache.stratos.messaging.message.processor.MessageProcessor;
-import org.apache.stratos.messaging.util.Util;
-
-public class ApplicationStatusAppCreatedMessageProcessor extends MessageProcessor {
- private static final Log log =
- LogFactory.getLog(ApplicationStatusAppCreatedMessageProcessor.class);
-
-
- private MessageProcessor nextProcessor;
-
- @Override
- public void setNext(MessageProcessor nextProcessor) {
- this.nextProcessor = nextProcessor;
-
- }
-
- @Override
- public boolean process(String type, String message, Object object) {
- if (ApplicationCreatedEvent.class.getName().equals(type)) {
- // Parse complete message and build event
- ApplicationCreatedEvent event =
- (ApplicationCreatedEvent) Util.jsonToObject(message, ApplicationCreatedEvent.class);
-
- if (log.isDebugEnabled()) {
- log.debug("Received ApplicationCreated Event in application status topic: " + event.toString());
- }
- // Notify event listeners
- notifyEventListeners(event);
- return true;
- } else {
- if (nextProcessor != null) {
- return nextProcessor.process(type, message, object);
- } else {
- throw new RuntimeException(
- String.format("Failed to process group activated message " +
- "using available message processors: [type] %s [body] %s", type, message));
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/4e4ba5b3/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/ApplicationStatusAppInActivatedMessageProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/ApplicationStatusAppInActivatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/ApplicationStatusAppInActivatedMessageProcessor.java
deleted file mode 100644
index 20e0e12..0000000
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/ApplicationStatusAppInActivatedMessageProcessor.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.stratos.messaging.message.processor.application.status;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.messaging.event.application.status.ApplicationInactivatedEvent;
-import org.apache.stratos.messaging.message.processor.MessageProcessor;
-import org.apache.stratos.messaging.util.Util;
-
-public class ApplicationStatusAppInActivatedMessageProcessor extends MessageProcessor {
- private static final Log log =
- LogFactory.getLog(ApplicationStatusAppInActivatedMessageProcessor.class);
-
-
- private MessageProcessor nextProcessor;
-
- @Override
- public void setNext(MessageProcessor nextProcessor) {
- this.nextProcessor = nextProcessor;
-
- }
-
- @Override
- public boolean process(String type, String message, Object object) {
- if (ApplicationInactivatedEvent.class.getName().equals(type)) {
- // Parse complete message and build event
- ApplicationInactivatedEvent event =
- (ApplicationInactivatedEvent) Util.jsonToObject(message, ApplicationInactivatedEvent.class);
-
- if (log.isDebugEnabled()) {
- log.debug("Received ApplicationInActivatedEvent in application status topic: " + event.toString());
- }
- // Notify event listeners
- notifyEventListeners(event);
- return true;
- } else {
- if (nextProcessor != null) {
- return nextProcessor.process(type, message, object);
- } else {
- throw new RuntimeException(
- String.format("Failed to process group activated message " +
- "using available message processors: [type] %s [body] %s", type, message));
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/4e4ba5b3/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/ApplicationStatusAppTerminatedMessageProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/ApplicationStatusAppTerminatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/ApplicationStatusAppTerminatedMessageProcessor.java
deleted file mode 100644
index ad5565a..0000000
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/ApplicationStatusAppTerminatedMessageProcessor.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.stratos.messaging.message.processor.application.status;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.messaging.event.application.status.ApplicationTerminatedEvent;
-import org.apache.stratos.messaging.message.processor.MessageProcessor;
-import org.apache.stratos.messaging.util.Util;
-
-public class ApplicationStatusAppTerminatedMessageProcessor extends MessageProcessor {
- private static final Log log =
- LogFactory.getLog(ApplicationStatusAppTerminatedMessageProcessor.class);
-
-
- private MessageProcessor nextProcessor;
-
- @Override
- public void setNext(MessageProcessor nextProcessor) {
- this.nextProcessor = nextProcessor;
-
- }
-
- @Override
- public boolean process(String type, String message, Object object) {
- if (ApplicationTerminatedEvent.class.getName().equals(type)) {
- // Parse complete message and build event
- ApplicationTerminatedEvent event =
- (ApplicationTerminatedEvent) Util.jsonToObject(message, ApplicationTerminatedEvent.class);
-
- if (log.isDebugEnabled()) {
- log.debug("Received ApplicationTerminatedEvent in application status topic: " + event.toString());
- }
- // Notify event listeners
- notifyEventListeners(event);
- return true;
- } else {
- if (nextProcessor != null) {
- return nextProcessor.process(type, message, object);
- } else {
- throw new RuntimeException(
- String.format("Failed to process group activated message " +
- "using available message processors: [type] %s [body] %s", type, message));
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/4e4ba5b3/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/ApplicationStatusAppTerminatingMessageProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/ApplicationStatusAppTerminatingMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/ApplicationStatusAppTerminatingMessageProcessor.java
deleted file mode 100644
index 2ace24b..0000000
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/ApplicationStatusAppTerminatingMessageProcessor.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.stratos.messaging.message.processor.application.status;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.messaging.event.application.status.ApplicationTerminatingEvent;
-import org.apache.stratos.messaging.message.processor.MessageProcessor;
-import org.apache.stratos.messaging.util.Util;
-
-public class ApplicationStatusAppTerminatingMessageProcessor extends MessageProcessor {
- private static final Log log =
- LogFactory.getLog(ApplicationStatusAppTerminatingMessageProcessor.class);
-
-
- private MessageProcessor nextProcessor;
-
- @Override
- public void setNext(MessageProcessor nextProcessor) {
- this.nextProcessor = nextProcessor;
-
- }
-
- @Override
- public boolean process(String type, String message, Object object) {
- if (ApplicationTerminatingEvent.class.getName().equals(type)) {
- // Parse complete message and build event
- ApplicationTerminatingEvent event =
- (ApplicationTerminatingEvent) Util.jsonToObject(message, ApplicationTerminatingEvent.class);
-
- if (log.isDebugEnabled()) {
- log.debug("Received ApplicationTerminatingEvent in application status topic: " + event.toString());
- }
- // Notify event listeners
- notifyEventListeners(event);
- return true;
- } else {
- if (nextProcessor != null) {
- return nextProcessor.process(type, message, object);
- } else {
- throw new RuntimeException(
- String.format("Failed to process group activated message " +
- "using available message processors: [type] %s [body] %s", type, message));
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/4e4ba5b3/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/ApplicationStatusClusterActivatedMessageProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/ApplicationStatusClusterActivatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/ApplicationStatusClusterActivatedMessageProcessor.java
deleted file mode 100644
index 249a6da..0000000
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/ApplicationStatusClusterActivatedMessageProcessor.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.stratos.messaging.message.processor.application.status;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.messaging.event.application.status.ClusterActivatedEvent;
-import org.apache.stratos.messaging.message.processor.MessageProcessor;
-import org.apache.stratos.messaging.util.Util;
-
-
-public class ApplicationStatusClusterActivatedMessageProcessor extends MessageProcessor {
- private static final Log log = LogFactory.getLog(ApplicationStatusClusterActivatedMessageProcessor.class);
- private MessageProcessor nextProcessor;
-
- @Override
- public void setNext(MessageProcessor nextProcessor) {
- this.nextProcessor = nextProcessor;
- }
-
- @Override
- public boolean process(String type, String message, Object object) {
- if (ClusterActivatedEvent.class.getName().equals(type)) {
- // Parse complete message and build event
- ClusterActivatedEvent event = (ClusterActivatedEvent) Util.jsonToObject(message, ClusterActivatedEvent.class);
-
- if(log.isDebugEnabled()) {
- log.debug("Received ClusterActivatedEvent: " + event.toString());
- }
- // Notify event listeners
- notifyEventListeners(event);
- return true;
- } else {
- if (nextProcessor != null) {
- return nextProcessor.process(type, message, object);
- } else {
- throw new RuntimeException(String.format("Failed to process cluster activated message using available message processors: [type] %s [body] %s", type, message));
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/4e4ba5b3/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/ApplicationStatusClusterInActivateMessageProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/ApplicationStatusClusterInActivateMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/ApplicationStatusClusterInActivateMessageProcessor.java
deleted file mode 100644
index 4e2fe7c..0000000
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/ApplicationStatusClusterInActivateMessageProcessor.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.stratos.messaging.message.processor.application.status;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.messaging.event.application.status.ClusterActivatedEvent;
-import org.apache.stratos.messaging.event.application.status.ClusterInActivateEvent;
-import org.apache.stratos.messaging.message.processor.MessageProcessor;
-import org.apache.stratos.messaging.util.Util;
-
-
-public class ApplicationStatusClusterInActivateMessageProcessor extends MessageProcessor {
- private static final Log log = LogFactory.getLog(ApplicationStatusClusterInActivateMessageProcessor.class);
- private MessageProcessor nextProcessor;
-
- @Override
- public void setNext(MessageProcessor nextProcessor) {
- this.nextProcessor = nextProcessor;
- }
-
- @Override
- public boolean process(String type, String message, Object object) {
- if (ClusterInActivateEvent.class.getName().equals(type)) {
- // Parse complete message and build event
- ClusterInActivateEvent event = (ClusterInActivateEvent) Util.
- jsonToObject(message, ClusterInActivateEvent.class);
-
- if(log.isDebugEnabled()) {
- log.debug("Received ClusterInActivateEvent: " + event.toString());
- }
- // Notify event listeners
- notifyEventListeners(event);
- return true;
- } else {
- if (nextProcessor != null) {
- return nextProcessor.process(type, message, object);
- } else {
- throw new RuntimeException(String.format("Failed to process cluster activated message using available message processors: [type] %s [body] %s", type, message));
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/4e4ba5b3/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/ApplicationStatusGroupActivatedMessageProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/ApplicationStatusGroupActivatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/ApplicationStatusGroupActivatedMessageProcessor.java
deleted file mode 100644
index 01c3fa6..0000000
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/ApplicationStatusGroupActivatedMessageProcessor.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.stratos.messaging.message.processor.application.status;
-
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.messaging.event.application.status.ClusterActivatedEvent;
-import org.apache.stratos.messaging.event.application.status.GroupActivatedEvent;
-import org.apache.stratos.messaging.message.processor.MessageProcessor;
-import org.apache.stratos.messaging.util.Util;
-
-public class ApplicationStatusGroupActivatedMessageProcessor extends MessageProcessor {
- private static final Log log =
- LogFactory.getLog(ApplicationStatusGroupActivatedMessageProcessor.class);
- private MessageProcessor nextProcessor;
-
- @Override
- public void setNext(MessageProcessor nextProcessor) {
- this.nextProcessor = nextProcessor;
- }
-
- @Override
- public boolean process(String type, String message, Object object) {
- if (GroupActivatedEvent.class.getName().equals(type)) {
- // Parse complete message and build event
- GroupActivatedEvent event =
- (GroupActivatedEvent) Util.jsonToObject(message, GroupActivatedEvent.class);
-
- if (log.isDebugEnabled()) {
- log.debug("Received GroupActivatedEvent: " + event.toString());
- }
- // Notify event listeners
- notifyEventListeners(event);
- return true;
- } else {
- if (nextProcessor != null) {
- return nextProcessor.process(type, message, object);
- } else {
- throw new RuntimeException(
- String.format("Failed to process group activated message " +
- "using available message processors: [type] %s [body] %s", type, message));
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/4e4ba5b3/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/ApplicationStatusGroupInActivatedMessageProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/ApplicationStatusGroupInActivatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/ApplicationStatusGroupInActivatedMessageProcessor.java
deleted file mode 100644
index 2f7f231..0000000
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/ApplicationStatusGroupInActivatedMessageProcessor.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.stratos.messaging.message.processor.application.status;
-
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.messaging.event.application.status.GroupInactivateEvent;
-import org.apache.stratos.messaging.message.processor.MessageProcessor;
-import org.apache.stratos.messaging.util.Util;
-
-public class ApplicationStatusGroupInActivatedMessageProcessor extends MessageProcessor {
- private static final Log log =
- LogFactory.getLog(ApplicationStatusGroupInActivatedMessageProcessor.class);
- private MessageProcessor nextProcessor;
-
- @Override
- public void setNext(MessageProcessor nextProcessor) {
- this.nextProcessor = nextProcessor;
- }
-
- @Override
- public boolean process(String type, String message, Object object) {
- if (GroupInactivateEvent.class.getName().equals(type)) {
- // Parse complete message and build event
- GroupInactivateEvent event =
- (GroupInactivateEvent) Util.jsonToObject(message, GroupInactivateEvent.class);
-
- if (log.isDebugEnabled()) {
- log.debug("Received GroupInActivateEvent: " + event.toString());
- }
- // Notify event listeners
- notifyEventListeners(event);
- return true;
- } else {
- if (nextProcessor != null) {
- return nextProcessor.process(type, message, object);
- } else {
- throw new RuntimeException(
- String.format("Failed to process group in activated message " +
- "using available message processors: [type] %s [body] %s", type, message));
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/4e4ba5b3/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/ApplicationStatusGroupTerminatedMessageProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/ApplicationStatusGroupTerminatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/ApplicationStatusGroupTerminatedMessageProcessor.java
deleted file mode 100644
index 93dd750..0000000
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/ApplicationStatusGroupTerminatedMessageProcessor.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.stratos.messaging.message.processor.application.status;
-
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.messaging.event.application.status.GroupInTerminatedEvent;
-import org.apache.stratos.messaging.message.processor.MessageProcessor;
-import org.apache.stratos.messaging.util.Util;
-
-public class ApplicationStatusGroupTerminatedMessageProcessor extends MessageProcessor {
- private static final Log log =
- LogFactory.getLog(ApplicationStatusGroupTerminatedMessageProcessor.class);
- private MessageProcessor nextProcessor;
-
- @Override
- public void setNext(MessageProcessor nextProcessor) {
- this.nextProcessor = nextProcessor;
- }
-
- @Override
- public boolean process(String type, String message, Object object) {
- if (GroupInTerminatedEvent.class.getName().equals(type)) {
- // Parse complete message and build event
- GroupInTerminatedEvent event =
- (GroupInTerminatedEvent) Util.jsonToObject(message, GroupInTerminatedEvent.class);
-
- if (log.isDebugEnabled()) {
- log.debug("Received GroupTerminatingEvent: " + event.toString());
- }
- // Notify event listeners
- notifyEventListeners(event);
- return true;
- } else {
- if (nextProcessor != null) {
- return nextProcessor.process(type, message, object);
- } else {
- throw new RuntimeException(
- String.format("Failed to process group in GroupTerminatingEvent message " +
- "using available message processors: [type] %s [body] %s", type, message));
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/4e4ba5b3/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/ApplicationStatusGroupTerminatingMessageProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/ApplicationStatusGroupTerminatingMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/ApplicationStatusGroupTerminatingMessageProcessor.java
deleted file mode 100644
index 493bd6c..0000000
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/ApplicationStatusGroupTerminatingMessageProcessor.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.stratos.messaging.message.processor.application.status;
-
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.messaging.event.topology.GroupTerminatingEvent;
-import org.apache.stratos.messaging.message.processor.MessageProcessor;
-import org.apache.stratos.messaging.util.Util;
-
-public class ApplicationStatusGroupTerminatingMessageProcessor extends MessageProcessor {
- private static final Log log =
- LogFactory.getLog(ApplicationStatusGroupTerminatingMessageProcessor.class);
- private MessageProcessor nextProcessor;
-
- @Override
- public void setNext(MessageProcessor nextProcessor) {
- this.nextProcessor = nextProcessor;
- }
-
- @Override
- public boolean process(String type, String message, Object object) {
- if (GroupTerminatingEvent.class.getName().equals(type)) {
- // Parse complete message and build event
- GroupTerminatingEvent event =
- (GroupTerminatingEvent) Util.jsonToObject(message, GroupTerminatingEvent.class);
-
- if (log.isDebugEnabled()) {
- log.debug("Received GroupTerminatingEvent: " + event.toString());
- }
- // Notify event listeners
- notifyEventListeners(event);
- return true;
- } else {
- if (nextProcessor != null) {
- return nextProcessor.process(type, message, object);
- } else {
- throw new RuntimeException(
- String.format("Failed to process group in GroupTerminatingEvent message " +
- "using available message processors: [type] %s [body] %s", type, message));
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/4e4ba5b3/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/ApplicationStatusMessageProcessorChain.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/ApplicationStatusMessageProcessorChain.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/ApplicationStatusMessageProcessorChain.java
deleted file mode 100644
index 8d2cdf6..0000000
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/ApplicationStatusMessageProcessorChain.java
+++ /dev/null
@@ -1,126 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.stratos.messaging.message.processor.application.status;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.messaging.listener.EventListener;
-import org.apache.stratos.messaging.listener.application.status.*;
-import org.apache.stratos.messaging.message.processor.MessageProcessorChain;
-
-/**
- * Application Status processor chain is to handle the list processors to parse the application
- * status.
- */
-public class ApplicationStatusMessageProcessorChain extends MessageProcessorChain {
- private static final Log log = LogFactory.getLog(ApplicationStatusMessageProcessorChain.class);
-
- private ApplicationStatusClusterActivatedMessageProcessor clusterActivatedMessageProcessor;
- private ApplicationStatusClusterInActivateMessageProcessor clusterInActivateMessageProcessor;
- private AppStatusClusterTerminatingMessageProcessor clusterTerminatingMessageProcessor;
- private AppStatusClusterTerminatedMessageProcessor clusterTerminatedMessageProcessor;
- private ApplicationStatusGroupActivatedMessageProcessor groupActivatedMessageProcessor;
- private ApplicationStatusGroupInActivatedMessageProcessor groupInActivateMessageProcessor;
- private ApplicationStatusAppActivatedMessageProcessor appActivatedMessageProcessor;
- private ApplicationStatusAppCreatedMessageProcessor applicationStatusAppCreatedMessageProcessor;
- private ApplicationStatusAppInActivatedMessageProcessor applicationStatusAppInActivatedMessageProcessor;
- private ApplicationStatusAppTerminatedMessageProcessor applicationStatusAppTerminatedMessageProcessor;
- private ApplicationStatusAppTerminatingMessageProcessor applicationStatusAppTerminatingMessageProcessor;
-
- private ApplicationStatusGroupTerminatedMessageProcessor groupTerminatedMessageProcessor;
- private ApplicationStatusGroupTerminatingMessageProcessor groupTerminatingMessageProcessor;
-
- public void initialize() {
- // Add instance notifier event processors
- clusterActivatedMessageProcessor = new ApplicationStatusClusterActivatedMessageProcessor();
- add(clusterActivatedMessageProcessor);
-
- clusterInActivateMessageProcessor = new ApplicationStatusClusterInActivateMessageProcessor();
- add(clusterInActivateMessageProcessor);
-
- clusterTerminatingMessageProcessor = new AppStatusClusterTerminatingMessageProcessor();
- add(clusterTerminatingMessageProcessor);
- clusterTerminatedMessageProcessor = new AppStatusClusterTerminatedMessageProcessor();
- add(clusterTerminatedMessageProcessor);
-
- groupActivatedMessageProcessor = new ApplicationStatusGroupActivatedMessageProcessor();
- add(groupActivatedMessageProcessor);
-
- groupInActivateMessageProcessor = new ApplicationStatusGroupInActivatedMessageProcessor();
- add(groupInActivateMessageProcessor);
-
- appActivatedMessageProcessor = new ApplicationStatusAppActivatedMessageProcessor();
- add(appActivatedMessageProcessor);
-
- applicationStatusAppCreatedMessageProcessor = new ApplicationStatusAppCreatedMessageProcessor();
- this.add(applicationStatusAppCreatedMessageProcessor);
-
- applicationStatusAppInActivatedMessageProcessor = new ApplicationStatusAppInActivatedMessageProcessor();
- this.add(applicationStatusAppInActivatedMessageProcessor);
-
- applicationStatusAppTerminatedMessageProcessor = new ApplicationStatusAppTerminatedMessageProcessor();
- this.add(applicationStatusAppTerminatedMessageProcessor);
-
- applicationStatusAppTerminatingMessageProcessor = new ApplicationStatusAppTerminatingMessageProcessor();
- this.add(applicationStatusAppTerminatingMessageProcessor);
-
- groupTerminatedMessageProcessor = new ApplicationStatusGroupTerminatedMessageProcessor();
- this.add(groupTerminatedMessageProcessor);
-
- groupTerminatingMessageProcessor = new ApplicationStatusGroupTerminatingMessageProcessor();
- this.add(groupTerminatingMessageProcessor);
-
- if (log.isDebugEnabled()) {
- log.debug("Instance notifier message processor chain initialized");
- }
- }
-
- public void addEventListener(EventListener eventListener) {
- if (eventListener instanceof ClusterActivatedEventListener) {
- clusterActivatedMessageProcessor.addEventListener(eventListener);
- } else if (eventListener instanceof ClusterInActivateEventListener) {
- clusterInActivateMessageProcessor.addEventListener(eventListener);
- } else if (eventListener instanceof GroupActivatedEventListener) {
- groupActivatedMessageProcessor.addEventListener(eventListener);
- } else if(eventListener instanceof AppStatusClusterTerminatedEventListener){
- clusterTerminatedMessageProcessor.addEventListener(eventListener);
- } else if(eventListener instanceof AppStatusClusterTerminatingEventListener){
- clusterTerminatingMessageProcessor.addEventListener(eventListener);
- }else if (eventListener instanceof GroupInactivateEventListener) {
- groupInActivateMessageProcessor.addEventListener(eventListener);
- } else if (eventListener instanceof ApplicationActivatedEventListener) {
- appActivatedMessageProcessor.addEventListener(eventListener);
- } else if(eventListener instanceof ApplicationInActivatedEventListener){
- applicationStatusAppInActivatedMessageProcessor.addEventListener(eventListener);
- } else if(eventListener instanceof ApplicationCreatedEventListener){
- applicationStatusAppCreatedMessageProcessor.addEventListener(eventListener);
- } else if(eventListener instanceof ApplicationTerminatingEventListener){
- applicationStatusAppTerminatingMessageProcessor.addEventListener(eventListener);
- } else if(eventListener instanceof ApplicationTerminatedEventListener){
- applicationStatusAppTerminatedMessageProcessor.addEventListener(eventListener);
- } else if (eventListener instanceof GroupTerminatingEventListener){
- groupTerminatingMessageProcessor.addEventListener(eventListener);
- } else if (eventListener instanceof GroupTerminatedEventListener){
- groupTerminatedMessageProcessor.addEventListener(eventListener);
- } else
- {
- throw new RuntimeException("Unknown event listener " + eventListener.toString());
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/4e4ba5b3/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/application/status/ApplicationStatusEventMessageDelegator.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/application/status/ApplicationStatusEventMessageDelegator.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/application/status/ApplicationStatusEventMessageDelegator.java
index 2b1ad5b..9eda9e0 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/application/status/ApplicationStatusEventMessageDelegator.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/application/status/ApplicationStatusEventMessageDelegator.java
@@ -22,7 +22,7 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.stratos.messaging.listener.EventListener;
import org.apache.stratos.messaging.message.processor.MessageProcessorChain;
-import org.apache.stratos.messaging.message.processor.application.status.ApplicationStatusMessageProcessorChain;
+import org.apache.stratos.messaging.message.processor.application.status.AppStatusMessageProcessorChain;
import org.apache.stratos.messaging.util.Constants;
import javax.jms.TextMessage;
@@ -36,7 +36,7 @@ public class ApplicationStatusEventMessageDelegator implements Runnable {
public ApplicationStatusEventMessageDelegator(ApplicationStatusEventMessageQueue messageQueue) {
this.messageQueue = messageQueue;
- this.processorChain = new ApplicationStatusMessageProcessorChain();
+ this.processorChain = new AppStatusMessageProcessorChain();
}
public void addEventListener(EventListener eventListener) {
[30/50] [abbrv] git commit: add metadataservice conf to sh
Posted by im...@apache.org.
add metadataservice conf to sh
Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/01315a74
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/01315a74
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/01315a74
Branch: refs/heads/docker-grouping-merge
Commit: 01315a7455a2a10c24285b605d7db4e5e2cb390c
Parents: 128fe3e
Author: Udara Liyanage <ud...@wso2.com>
Authored: Tue Oct 28 21:28:14 2014 +0530
Committer: Udara Liyanage <ud...@wso2.com>
Committed: Tue Oct 28 21:28:45 2014 +0530
----------------------------------------------------------------------
products/stratos/modules/distribution/src/bin/stratos.sh | 1 +
1 file changed, 1 insertion(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/stratos/blob/01315a74/products/stratos/modules/distribution/src/bin/stratos.sh
----------------------------------------------------------------------
diff --git a/products/stratos/modules/distribution/src/bin/stratos.sh b/products/stratos/modules/distribution/src/bin/stratos.sh
index eda3730..a289a87 100755
--- a/products/stratos/modules/distribution/src/bin/stratos.sh
+++ b/products/stratos/modules/distribution/src/bin/stratos.sh
@@ -300,6 +300,7 @@ do
-Dfile.encoding=UTF8 \
-Ddisable.cassandra.server.startup=true \
-Djndi.properties.dir="$CARBON_HOME/repository/conf" \
+ -DMETADATA_CLIENT_CONFIG_FILE="$CARBON_HOME/repository/conf/metadataservice.xml" \
org.wso2.carbon.bootstrap.Bootstrap $*
status=$?
done
[11/50] [abbrv] git commit: fixing fault handling and fixing when
setting hasDependent to child monitors
Posted by im...@apache.org.
fixing fault handling and fixing when setting hasDependent to child monitors
Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/1b224bd8
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/1b224bd8
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/1b224bd8
Branch: refs/heads/docker-grouping-merge
Commit: 1b224bd86e726db82ee92b155c53c4486fd7fec8
Parents: 0300d17
Author: reka <rt...@gmail.com>
Authored: Mon Oct 27 15:29:13 2014 +0530
Committer: reka <rt...@gmail.com>
Committed: Mon Oct 27 15:29:44 2014 +0530
----------------------------------------------------------------------
.../health/AutoscalerHealthStatEventReceiver.java | 2 +-
.../autoscaler/monitor/AbstractClusterMonitor.java | 5 ++++-
.../autoscaler/monitor/ApplicationMonitorFactory.java | 11 +++++++++--
.../org/apache/stratos/autoscaler/monitor/Monitor.java | 4 ++--
4 files changed, 16 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/stratos/blob/1b224bd8/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/health/AutoscalerHealthStatEventReceiver.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/health/AutoscalerHealthStatEventReceiver.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/health/AutoscalerHealthStatEventReceiver.java
index f090fcb..6986fbb 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/health/AutoscalerHealthStatEventReceiver.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/health/AutoscalerHealthStatEventReceiver.java
@@ -494,7 +494,7 @@ public class AutoscalerHealthStatEventReceiver implements Runnable {
}
return null;
}
- return null;
+ return monitor;
}
http://git-wip-us.apache.org/repos/asf/stratos/blob/1b224bd8/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/AbstractClusterMonitor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/AbstractClusterMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/AbstractClusterMonitor.java
index e816a42..838929c 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/AbstractClusterMonitor.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/AbstractClusterMonitor.java
@@ -234,8 +234,11 @@ abstract public class AbstractClusterMonitor extends Monitor implements Runnable
* If the cluster in_active and if it is a in_dependent cluster,
* then won't send the notification to parent.
*/
- if(!(status == ClusterStatus.Inactive && !this.hasDependent)) {
+ if((status == ClusterStatus.Inactive && this.hasDependent)) {
MonitorStatusEventBuilder.handleClusterStatusEvent(this.parent, this.status, this.clusterId);
+ } else {
+ log.info("[Cluster] " + clusterId + "is not notifying the parent, " +
+ "since it is identified as the independent unit");
}
}
http://git-wip-us.apache.org/repos/asf/stratos/blob/1b224bd8/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ApplicationMonitorFactory.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ApplicationMonitorFactory.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ApplicationMonitorFactory.java
index 92b3eb8..b60e645 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ApplicationMonitorFactory.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ApplicationMonitorFactory.java
@@ -108,8 +108,11 @@ public class ApplicationMonitorFactory {
groupMonitor.setAppId(appId);
if(parentMonitor != null) {
groupMonitor.setParent(parentMonitor);
- if(!parentMonitor.isHasDependent() && !context.hasChild()) {
+ //Setting the dependent behaviour of the monitor
+ if(parentMonitor.hasMonitors() && (parentMonitor.isDependent() || context.hasChild())) {
groupMonitor.setHasDependent(true);
+ } else {
+ groupMonitor.setHasDependent(false);
}
//TODO make sure when it is async
@@ -146,6 +149,8 @@ public class ApplicationMonitorFactory {
Application application = TopologyManager.getTopology().getApplication(appId);
if (application != null) {
applicationMonitor = new ApplicationMonitor(application);
+ applicationMonitor.setHasDependent(false);
+
} else {
String msg = "[Application] " + appId + " cannot be found in the Topology";
throw new TopologyInConsistentException(msg);
@@ -286,8 +291,10 @@ public class ApplicationMonitorFactory {
clusterMonitor.addNetworkPartitionCtxt(networkPartitionContext);
clusterMonitor.setParent(parentMonitor);
- if(!parentMonitor.isHasDependent() && !context.hasChild()) {
+ if(parentMonitor.hasActiveMonitors() && (parentMonitor.isDependent() || context.hasChild())) {
clusterMonitor.setHasDependent(true);
+ } else {
+ clusterMonitor.setHasDependent(false);
}
AutoscalerContext.getInstance().addMonitor(clusterMonitor);
if (log.isInfoEnabled()) {
http://git-wip-us.apache.org/repos/asf/stratos/blob/1b224bd8/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/Monitor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/Monitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/Monitor.java
index 7199ee8..b1e2eb3 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/Monitor.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/Monitor.java
@@ -75,7 +75,7 @@ public abstract class Monitor implements EventHandler {
public boolean hasActiveMonitors() {
boolean hasMonitor = false;
- if(this.aliasToActiveMonitorsMap != null ) {
+ if(this.aliasToActiveMonitorsMap != null && !this.aliasToActiveMonitorsMap.isEmpty()) {
hasMonitor = true;
}
return hasMonitor;
@@ -86,7 +86,7 @@ public abstract class Monitor implements EventHandler {
return this.aliasToActiveMonitorsMap != null || this.aliasToInActiveMonitorsMap != null;
}
- public boolean isHasDependent() {
+ public boolean isDependent() {
return hasDependent;
}
[05/50] [abbrv] git commit: rename application status events,
listeners and processors with prefix appstatus
Posted by im...@apache.org.
rename application status events, listeners and processors with prefix appstatus
Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/4e4ba5b3
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/4e4ba5b3
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/4e4ba5b3
Branch: refs/heads/docker-grouping-merge
Commit: 4e4ba5b38b5917468987e4d9329050e40a9cfb43
Parents: 4f59f4b
Author: Udara Liyanage <ud...@wso2.com>
Authored: Mon Oct 27 11:00:25 2014 +0530
Committer: Udara Liyanage <ud...@wso2.com>
Committed: Mon Oct 27 11:00:25 2014 +0530
----------------------------------------------------------------------
.../grouping/topic/StatusEventPublisher.java | 39 +++---
.../ApplicationStatusTopicReceiver.java | 40 +++---
.../controller/topology/TopologyBuilder.java | 38 +++---
.../AppStatusApplicationActivatedEvent.java | 38 ++++++
.../AppStatusApplicationCreatedEvent.java | 38 ++++++
.../AppStatusApplicationInactivatedEvent.java | 38 ++++++
.../AppStatusApplicationTerminatedEvent.java | 47 +++++++
.../AppStatusApplicationTerminatingEvent.java | 38 ++++++
.../status/AppStatusClusterActivatedEvent.java | 50 ++++++++
.../status/AppStatusClusterInactivateEvent.java | 50 ++++++++
.../AppStatusClusterMaintenanceModeEvent.java | 49 ++++++++
.../AppStatusClusterReadyToShutdownEvent.java | 47 +++++++
.../status/AppStatusGroupActivatedEvent.java | 44 +++++++
.../status/AppStatusGroupInactivateEvent.java | 44 +++++++
.../AppStatusGroupMaintenanceModeEvent.java | 41 ++++++
.../AppStatusGroupReadyToShutdownEvent.java | 40 ++++++
.../status/AppStatusGroupTerminatedEvent.java | 44 +++++++
.../status/AppStatusGroupTerminatingEvent.java | 44 +++++++
.../status/ApplicationActivatedEvent.java | 38 ------
.../status/ApplicationCreatedEvent.java | 38 ------
.../status/ApplicationInactivatedEvent.java | 38 ------
.../status/ApplicationTerminatedEvent.java | 47 -------
.../status/ApplicationTerminatingEvent.java | 38 ------
.../status/ClusterActivatedEvent.java | 52 --------
.../status/ClusterInActivateEvent.java | 50 --------
.../status/ClusterMaintenanceModeEvent.java | 49 --------
.../status/ClusterReadyToShutdownEvent.java | 47 -------
.../application/status/GroupActivatedEvent.java | 44 -------
.../status/GroupInTerminatedEvent.java | 44 -------
.../status/GroupInTerminatingEvent.java | 44 -------
.../status/GroupInactivateEvent.java | 44 -------
.../status/GroupMaintenanceModeEvent.java | 41 ------
.../status/GroupReadyToShutdownEvent.java | 40 ------
...StatusApplicationActivatedEventListener.java | 27 ++++
...ppStatusApplicationCreatedEventListener.java | 27 ++++
...atusApplicationInactivatedEventListener.java | 27 ++++
...tatusApplicationTerminatedEventListener.java | 27 ++++
...atusApplicationTerminatingEventListener.java | 27 ++++
.../AppStatusClusterActivatedEventListener.java | 24 ++++
...AppStatusClusterInactivateEventListener.java | 24 ++++
.../AppStatusGroupActivatedEventListener.java | 27 ++++
.../AppStatusGroupInactivateEventListener.java | 27 ++++
.../AppStatusGroupTerminatedEventListener.java | 24 ++++
.../AppStatusGroupTerminatingEventListener.java | 27 ++++
.../ApplicationActivatedEventListener.java | 27 ----
.../status/ApplicationCreatedEventListener.java | 27 ----
.../ApplicationInActivatedEventListener.java | 27 ----
.../ApplicationTerminatedEventListener.java | 27 ----
.../ApplicationTerminatingEventListener.java | 27 ----
.../status/ClusterActivatedEventListener.java | 24 ----
.../status/ClusterInActivateEventListener.java | 24 ----
.../status/GroupActivatedEventListener.java | 27 ----
.../status/GroupInactivateEventListener.java | 27 ----
.../status/GroupTerminatedEventListener.java | 24 ----
.../status/GroupTerminatingEventListener.java | 27 ----
...tusApplicationActivatedMessageProcessor.java | 65 ++++++++++
...tatusApplicationCreatedMessageProcessor.java | 63 ++++++++++
...sApplicationInactivatedMessageProcessor.java | 63 ++++++++++
...usApplicationTerminatedMessageProcessor.java | 63 ++++++++++
...sApplicationTerminatingMessageProcessor.java | 63 ++++++++++
...pStatusClusterActivatedMessageProcessor.java | 57 +++++++++
...StatusClusterInactivateMessageProcessor.java | 58 +++++++++
...AppStatusGroupActivatedMessageProcessor.java | 61 +++++++++
...pStatusGroupInactivatedMessageProcessor.java | 61 +++++++++
...ppStatusGroupTerminatedMessageProcessor.java | 61 +++++++++
...pStatusGroupTerminatingMessageProcessor.java | 61 +++++++++
.../status/AppStatusMessageProcessorChain.java | 126 +++++++++++++++++++
...ationStatusAppActivatedMessageProcessor.java | 67 ----------
...icationStatusAppCreatedMessageProcessor.java | 63 ----------
...ionStatusAppInActivatedMessageProcessor.java | 63 ----------
...tionStatusAppTerminatedMessageProcessor.java | 63 ----------
...ionStatusAppTerminatingMessageProcessor.java | 63 ----------
...nStatusClusterActivatedMessageProcessor.java | 57 ---------
...StatusClusterInActivateMessageProcessor.java | 59 ---------
...ionStatusGroupActivatedMessageProcessor.java | 62 ---------
...nStatusGroupInActivatedMessageProcessor.java | 61 ---------
...onStatusGroupTerminatedMessageProcessor.java | 61 ---------
...nStatusGroupTerminatingMessageProcessor.java | 61 ---------
.../ApplicationStatusMessageProcessorChain.java | 126 -------------------
.../ApplicationStatusEventMessageDelegator.java | 4 +-
80 files changed, 1802 insertions(+), 1809 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/stratos/blob/4e4ba5b3/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/StatusEventPublisher.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/StatusEventPublisher.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/StatusEventPublisher.java
index c0c64ac..3a3af88 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/StatusEventPublisher.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/StatusEventPublisher.java
@@ -7,14 +7,13 @@ import org.apache.stratos.messaging.broker.publish.EventPublisherPool;
import org.apache.stratos.messaging.domain.topology.ClusterDataHolder;
import org.apache.stratos.messaging.event.Event;
import org.apache.stratos.messaging.event.application.status.*;
-import org.apache.stratos.messaging.event.application.status.ApplicationActivatedEvent;
-import org.apache.stratos.messaging.event.application.status.ApplicationInactivatedEvent;
-import org.apache.stratos.messaging.event.application.status.ApplicationTerminatedEvent;
-import org.apache.stratos.messaging.event.application.status.ApplicationTerminatingEvent;
-import org.apache.stratos.messaging.event.application.status.ClusterActivatedEvent;
-import org.apache.stratos.messaging.event.application.status.ClusterInActivateEvent;
-import org.apache.stratos.messaging.event.application.status.ClusterMaintenanceModeEvent;
-import org.apache.stratos.messaging.event.application.status.GroupActivatedEvent;
+import org.apache.stratos.messaging.event.application.status.AppStatusApplicationActivatedEvent;
+import org.apache.stratos.messaging.event.application.status.AppStatusApplicationInactivatedEvent;
+import org.apache.stratos.messaging.event.application.status.AppStatusApplicationTerminatedEvent;
+import org.apache.stratos.messaging.event.application.status.AppStatusApplicationTerminatingEvent;
+import org.apache.stratos.messaging.event.application.status.AppStatusClusterActivatedEvent;
+import org.apache.stratos.messaging.event.application.status.AppStatusClusterInactivateEvent;
+import org.apache.stratos.messaging.event.application.status.AppStatusGroupActivatedEvent;
import org.apache.stratos.messaging.event.topology.*;
import org.apache.stratos.messaging.event.topology.GroupInactivateEvent;
import org.apache.stratos.messaging.util.Constants;
@@ -47,8 +46,8 @@ public class StatusEventPublisher {
" [cluster]: " + clusterId);
}
- ClusterActivatedEvent clusterActivatedEvent =
- new ClusterActivatedEvent(appId, serviceName, clusterId);
+ AppStatusClusterActivatedEvent clusterActivatedEvent =
+ new AppStatusClusterActivatedEvent(appId, serviceName, clusterId);
publishEvent(clusterActivatedEvent);
}
@@ -60,8 +59,8 @@ public class StatusEventPublisher {
" [cluster]: " + clusterId);
}
- ClusterInActivateEvent clusterInActivateEvent =
- new ClusterInActivateEvent(appId, serviceName, clusterId);
+ AppStatusClusterInactivateEvent clusterInActivateEvent =
+ new AppStatusClusterInactivateEvent(appId, serviceName, clusterId);
publishEvent(clusterInActivateEvent);
}
@@ -99,7 +98,7 @@ public class StatusEventPublisher {
" [group]: " + groupId);
}
- GroupActivatedEvent groupActivatedEvent = new GroupActivatedEvent(appId, groupId);
+ AppStatusGroupActivatedEvent groupActivatedEvent = new AppStatusGroupActivatedEvent(appId, groupId);
publishEvent(groupActivatedEvent);
}
@@ -123,7 +122,7 @@ public class StatusEventPublisher {
" [group]: " + groupId);
}
- GroupInTerminatingEvent groupInTerminatingEvent = new GroupInTerminatingEvent(appId, groupId);
+ AppStatusGroupTerminatingEvent groupInTerminatingEvent = new AppStatusGroupTerminatingEvent(appId, groupId);
publishEvent(groupInTerminatingEvent);
}
@@ -134,7 +133,7 @@ public class StatusEventPublisher {
" [group]: " + groupId);
}
- GroupInTerminatedEvent groupInTerminatedEvent = new GroupInTerminatedEvent(appId, groupId);
+ AppStatusGroupTerminatedEvent groupInTerminatedEvent = new AppStatusGroupTerminatedEvent(appId, groupId);
publishEvent(groupInTerminatedEvent);
}
@@ -144,7 +143,7 @@ public class StatusEventPublisher {
log.info("Publishing Application activated event for [application]: " + appId);
}
- ApplicationActivatedEvent applicationActivatedEvent = new ApplicationActivatedEvent(appId);
+ AppStatusApplicationActivatedEvent applicationActivatedEvent = new AppStatusApplicationActivatedEvent(appId);
publishEvent(applicationActivatedEvent);
}
@@ -154,7 +153,7 @@ public class StatusEventPublisher {
log.info("Publishing Application Inactivated event for [application]: " + appId);
}
- ApplicationInactivatedEvent applicationInActivatedEvent = new ApplicationInactivatedEvent(appId);
+ AppStatusApplicationInactivatedEvent applicationInActivatedEvent = new AppStatusApplicationInactivatedEvent(appId);
publishEvent(applicationInActivatedEvent);
}
@@ -164,7 +163,7 @@ public class StatusEventPublisher {
log.info("Publishing Application terminated event for [application]: " + appId);
}
- ApplicationTerminatingEvent applicationTerminatingEvent = new ApplicationTerminatingEvent(appId);
+ AppStatusApplicationTerminatingEvent applicationTerminatingEvent = new AppStatusApplicationTerminatingEvent(appId);
publishEvent(applicationTerminatingEvent);
}
@@ -174,8 +173,8 @@ public class StatusEventPublisher {
log.info("Publishing Application terminated event for [application]: " + appId);
}
- ApplicationTerminatedEvent applicationTerminatedEvent =
- new ApplicationTerminatedEvent(appId, clusterData);
+ AppStatusApplicationTerminatedEvent applicationTerminatedEvent =
+ new AppStatusApplicationTerminatedEvent(appId, clusterData);
publishEvent(applicationTerminatedEvent);
}
http://git-wip-us.apache.org/repos/asf/stratos/blob/4e4ba5b3/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/status/receiver/ApplicationStatusTopicReceiver.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/status/receiver/ApplicationStatusTopicReceiver.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/status/receiver/ApplicationStatusTopicReceiver.java
index 1a62fef..ca93dce 100644
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/status/receiver/ApplicationStatusTopicReceiver.java
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/status/receiver/ApplicationStatusTopicReceiver.java
@@ -64,10 +64,10 @@ public class ApplicationStatusTopicReceiver implements Runnable {
private void addEventListeners() {
// Listen to topology events that affect clusters
- statusEventReceiver.addEventListener(new ClusterActivatedEventListener() {
+ statusEventReceiver.addEventListener(new AppStatusClusterActivatedEventListener() {
@Override
protected void onEvent(Event event) {
- TopologyBuilder.handleClusterActivatedEvent((ClusterActivatedEvent) event);
+ TopologyBuilder.handleClusterActivatedEvent((AppStatusClusterActivatedEvent) event);
}
});
@@ -85,75 +85,75 @@ public class ApplicationStatusTopicReceiver implements Runnable {
}
});
- statusEventReceiver.addEventListener(new ClusterInActivateEventListener() {
+ statusEventReceiver.addEventListener(new AppStatusClusterInactivateEventListener() {
@Override
protected void onEvent(Event event) {
- TopologyBuilder.handleClusterInActivateEvent((ClusterInActivateEvent) event);
+ TopologyBuilder.handleClusterInActivateEvent((AppStatusClusterInactivateEvent) event);
}
});
- statusEventReceiver.addEventListener(new GroupActivatedEventListener() {
+ statusEventReceiver.addEventListener(new AppStatusGroupActivatedEventListener() {
@Override
protected void onEvent(Event event) {
- TopologyBuilder.handleGroupActivatedEvent((GroupActivatedEvent) event);
+ TopologyBuilder.handleGroupActivatedEvent((AppStatusGroupActivatedEvent) event);
}
});
- statusEventReceiver.addEventListener(new GroupTerminatedEventListener() {
+ statusEventReceiver.addEventListener(new AppStatusGroupTerminatedEventListener() {
@Override
protected void onEvent(Event event) {
- TopologyBuilder.handleGroupTerminatedEvent((GroupInTerminatedEvent) event);
+ TopologyBuilder.handleGroupTerminatedEvent((AppStatusGroupTerminatedEvent) event);
}
});
- statusEventReceiver.addEventListener(new GroupTerminatingEventListener() {
+ statusEventReceiver.addEventListener(new AppStatusGroupTerminatingEventListener() {
@Override
protected void onEvent(Event event) {
- TopologyBuilder.handleGroupTerminatingEvent((GroupInTerminatingEvent) event);
+ TopologyBuilder.handleGroupTerminatingEvent((AppStatusGroupTerminatingEvent) event);
}
});
- statusEventReceiver.addEventListener(new ApplicationActivatedEventListener() {
+ statusEventReceiver.addEventListener(new AppStatusApplicationActivatedEventListener() {
@Override
protected void onEvent(Event event) {
- TopologyBuilder.handleApplicationActivatedEvent((ApplicationActivatedEvent) event);
+ TopologyBuilder.handleApplicationActivatedEvent((AppStatusApplicationActivatedEvent) event);
}
});
- statusEventReceiver.addEventListener(new ApplicationInActivatedEventListener() {
+ statusEventReceiver.addEventListener(new AppStatusApplicationInactivatedEventListener() {
@Override
protected void onEvent(Event event) {
- TopologyBuilder.handleApplicationInActivatedEvent((ApplicationInactivatedEvent) event);
+ TopologyBuilder.handleApplicationInActivatedEvent((AppStatusApplicationInactivatedEvent) event);
}
});
- statusEventReceiver.addEventListener(new ApplicationCreatedEventListener() {
+ statusEventReceiver.addEventListener(new AppStatusApplicationCreatedEventListener() {
@Override
protected void onEvent(Event event) {
- TopologyBuilder.handleApplicationCreatedEvent((ApplicationCreatedEvent) event);
+ TopologyBuilder.handleApplicationCreatedEvent((AppStatusApplicationCreatedEvent) event);
}
});
- statusEventReceiver.addEventListener(new ApplicationTerminatingEventListener() {
+ statusEventReceiver.addEventListener(new AppStatusApplicationTerminatingEventListener() {
@Override
protected void onEvent(Event event) {
- TopologyBuilder.handleApplicationTerminatingEvent((ApplicationTerminatingEvent) event);
+ TopologyBuilder.handleApplicationTerminatingEvent((AppStatusApplicationTerminatingEvent) event);
}
});
- statusEventReceiver.addEventListener(new ApplicationTerminatedEventListener() {
+ statusEventReceiver.addEventListener(new AppStatusApplicationTerminatedEventListener() {
@Override
protected void onEvent(Event event) {
- TopologyBuilder.handleApplicationTerminatedEvent((ApplicationTerminatedEvent) event);
+ TopologyBuilder.handleApplicationTerminatedEvent((AppStatusApplicationTerminatedEvent) event);
}
});
http://git-wip-us.apache.org/repos/asf/stratos/blob/4e4ba5b3/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java
index 4d929b1..3e04311 100644
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java
@@ -32,14 +32,14 @@ import org.apache.stratos.cloud.controller.util.CloudControllerUtil;
import org.apache.stratos.messaging.domain.topology.*;
import org.apache.stratos.messaging.domain.topology.util.CompositeApplicationBuilder;
import org.apache.stratos.messaging.event.application.status.*;
-import org.apache.stratos.messaging.event.application.status.ApplicationActivatedEvent;
-import org.apache.stratos.messaging.event.application.status.ApplicationCreatedEvent;
-import org.apache.stratos.messaging.event.application.status.ApplicationInactivatedEvent;
-import org.apache.stratos.messaging.event.application.status.ApplicationTerminatedEvent;
-import org.apache.stratos.messaging.event.application.status.ApplicationTerminatingEvent;
-import org.apache.stratos.messaging.event.application.status.ClusterActivatedEvent;
-import org.apache.stratos.messaging.event.application.status.GroupActivatedEvent;
-import org.apache.stratos.messaging.event.application.status.GroupInactivateEvent;
+import org.apache.stratos.messaging.event.application.status.AppStatusApplicationActivatedEvent;
+import org.apache.stratos.messaging.event.application.status.AppStatusApplicationCreatedEvent;
+import org.apache.stratos.messaging.event.application.status.AppStatusApplicationInactivatedEvent;
+import org.apache.stratos.messaging.event.application.status.AppStatusApplicationTerminatedEvent;
+import org.apache.stratos.messaging.event.application.status.AppStatusApplicationTerminatingEvent;
+import org.apache.stratos.messaging.event.application.status.AppStatusClusterActivatedEvent;
+import org.apache.stratos.messaging.event.application.status.AppStatusGroupActivatedEvent;
+import org.apache.stratos.messaging.event.application.status.AppStatusGroupInactivateEvent;
import org.apache.stratos.messaging.event.instance.status.InstanceActivatedEvent;
import org.apache.stratos.messaging.event.instance.status.InstanceMaintenanceModeEvent;
import org.apache.stratos.messaging.event.instance.status.InstanceReadyToShutdownEvent;
@@ -743,7 +743,7 @@ public class TopologyBuilder {
}
- public static void handleClusterActivatedEvent(ClusterActivatedEvent clusterActivatedEvent) {
+ public static void handleClusterActivatedEvent(AppStatusClusterActivatedEvent clusterActivatedEvent) {
Topology topology = TopologyManager.getTopology();
Service service = topology.getService(clusterActivatedEvent.getServiceName());
//update the status of the cluster
@@ -781,7 +781,7 @@ public class TopologyBuilder {
}
public static void handleClusterInActivateEvent(
- org.apache.stratos.messaging.event.application.status.ClusterInActivateEvent clusterInActivateEvent) {
+ AppStatusClusterInactivateEvent clusterInActivateEvent) {
Topology topology = TopologyManager.getTopology();
Service service = topology.getService(clusterInActivateEvent.getServiceName());
//update the status of the cluster
@@ -818,7 +818,7 @@ public class TopologyBuilder {
TopologyEventPublisher.sendClusterInActivateEvent(clusterActivatedEvent1);
}
- public static void handleGroupActivatedEvent(GroupActivatedEvent groupActivatedEvent) {
+ public static void handleGroupActivatedEvent(AppStatusGroupActivatedEvent groupActivatedEvent) {
Topology topology = TopologyManager.getTopology();
Application application = topology.getApplication(groupActivatedEvent.getAppId());
//update the status of the Group
@@ -852,7 +852,7 @@ public class TopologyBuilder {
TopologyEventPublisher.sendGroupActivatedEvent(groupActivatedEvent1);
}
- public static void handleApplicationActivatedEvent(ApplicationActivatedEvent applicationActivatedEvent) {
+ public static void handleApplicationActivatedEvent(AppStatusApplicationActivatedEvent applicationActivatedEvent) {
Topology topology = TopologyManager.getTopology();
Application application = topology.getApplication(applicationActivatedEvent.getAppId());
//update the status of the Group
@@ -878,7 +878,7 @@ public class TopologyBuilder {
TopologyEventPublisher.sendApplicationActivatedEvent(applicationActivatedEvent1);
}
- public static void handleApplicationInActivatedEvent(ApplicationInactivatedEvent event) {
+ public static void handleApplicationInActivatedEvent(AppStatusApplicationInactivatedEvent event) {
Topology topology = TopologyManager.getTopology();
Application application = topology.getApplication(event.getAppId());
//update the status of the Group
@@ -904,7 +904,7 @@ public class TopologyBuilder {
TopologyEventPublisher.sendApplicationInactivatedEvent(applicationActivatedEvent);
}
- public static void handleApplicationCreatedEvent(ApplicationCreatedEvent event) {
+ public static void handleApplicationCreatedEvent(AppStatusApplicationCreatedEvent event) {
Topology topology = TopologyManager.getTopology();
Application application = topology.getApplication(event.getAppId());
//update the status of the Group
@@ -937,7 +937,7 @@ public class TopologyBuilder {
TopologyEventPublisher.sendApplicationCreatedEvent(applicationActivatedEvent);
}
- public static void handleApplicationTerminatingEvent(ApplicationTerminatingEvent event) {
+ public static void handleApplicationTerminatingEvent(AppStatusApplicationTerminatingEvent event) {
String applicationId = event.getAppId();
@@ -986,7 +986,7 @@ public class TopologyBuilder {
}
}
- public static void handleApplicationTerminatedEvent(ApplicationTerminatedEvent event) {
+ public static void handleApplicationTerminatedEvent(AppStatusApplicationTerminatedEvent event) {
Topology topology = TopologyManager.getTopology();
@@ -1053,7 +1053,7 @@ public class TopologyBuilder {
}
}
- public static void handleGroupInActiveEvent(GroupInactivateEvent event) {
+ public static void handleGroupInActiveEvent(AppStatusGroupInactivateEvent event) {
Topology topology = TopologyManager.getTopology();
Application application = topology.getApplication(event.getAppId());
//update the status of the Group
@@ -1088,7 +1088,7 @@ public class TopologyBuilder {
}
- public static void handleGroupTerminatedEvent(GroupInTerminatedEvent event) {
+ public static void handleGroupTerminatedEvent(AppStatusGroupTerminatedEvent event) {
Topology topology = TopologyManager.getTopology();
Application application = topology.getApplication(event.getAppId());
//update the status of the Group
@@ -1122,7 +1122,7 @@ public class TopologyBuilder {
TopologyEventPublisher.sendGroupTerminatedEvent(groupTerminatedTopologyEvent);
}
- public static void handleGroupTerminatingEvent(GroupInTerminatingEvent event) {
+ public static void handleGroupTerminatingEvent(AppStatusGroupTerminatingEvent event) {
Topology topology = TopologyManager.getTopology();
Application application = topology.getApplication(event.getAppId());
//update the status of the Group
http://git-wip-us.apache.org/repos/asf/stratos/blob/4e4ba5b3/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusApplicationActivatedEvent.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusApplicationActivatedEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusApplicationActivatedEvent.java
new file mode 100644
index 0000000..f04ae02
--- /dev/null
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusApplicationActivatedEvent.java
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.stratos.messaging.event.application.status;
+
+import java.io.Serializable;
+
+/**
+ * This event will be fired upon the application activated is detected.
+ */
+public class AppStatusApplicationActivatedEvent extends StatusEvent implements Serializable {
+ private static final long serialVersionUID = 2625412714611885089L;
+
+ private String appId;
+
+ public AppStatusApplicationActivatedEvent(String appId) {
+ this.appId = appId;
+ }
+
+ public String getAppId() {
+ return appId;
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/4e4ba5b3/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusApplicationCreatedEvent.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusApplicationCreatedEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusApplicationCreatedEvent.java
new file mode 100644
index 0000000..c432e14
--- /dev/null
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusApplicationCreatedEvent.java
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.stratos.messaging.event.application.status;
+
+import java.io.Serializable;
+
+/**
+ * This event will be fired upon the application created is detected.
+ */
+public class AppStatusApplicationCreatedEvent extends StatusEvent implements Serializable {
+ private static final long serialVersionUID = 2625412714611885089L;
+
+ private String appId;
+
+ public AppStatusApplicationCreatedEvent(String appId) {
+ this.appId = appId;
+ }
+
+ public String getAppId() {
+ return appId;
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/4e4ba5b3/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusApplicationInactivatedEvent.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusApplicationInactivatedEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusApplicationInactivatedEvent.java
new file mode 100644
index 0000000..f00a97a
--- /dev/null
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusApplicationInactivatedEvent.java
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.stratos.messaging.event.application.status;
+
+import java.io.Serializable;
+
+/**
+ * This event will be fired upon the application inactivated is detected.
+ */
+public class AppStatusApplicationInactivatedEvent extends StatusEvent implements Serializable {
+ private static final long serialVersionUID = 2625412714611885089L;
+
+ private String appId;
+
+ public AppStatusApplicationInactivatedEvent(String appId) {
+ this.appId = appId;
+ }
+
+ public String getAppId() {
+ return appId;
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/4e4ba5b3/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusApplicationTerminatedEvent.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusApplicationTerminatedEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusApplicationTerminatedEvent.java
new file mode 100644
index 0000000..3fbb368
--- /dev/null
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusApplicationTerminatedEvent.java
@@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.stratos.messaging.event.application.status;
+
+import org.apache.stratos.messaging.domain.topology.ClusterDataHolder;
+
+import java.io.Serializable;
+import java.util.Set;
+
+/**
+ * This event will be fired upon the application terminated is detected.
+ */
+public class AppStatusApplicationTerminatedEvent extends StatusEvent implements Serializable {
+ private static final long serialVersionUID = 2625412714611885089L;
+
+ private String appId;
+ private Set<ClusterDataHolder> clusterData;
+
+ public AppStatusApplicationTerminatedEvent(String appId, Set<ClusterDataHolder> clusterData) {
+ this.appId = appId;
+ this.clusterData = clusterData;
+ }
+
+ public String getAppId() {
+ return appId;
+ }
+
+ public Set<ClusterDataHolder> getClusterData() {
+ return clusterData;
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/4e4ba5b3/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusApplicationTerminatingEvent.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusApplicationTerminatingEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusApplicationTerminatingEvent.java
new file mode 100644
index 0000000..e2a3a09
--- /dev/null
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusApplicationTerminatingEvent.java
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.stratos.messaging.event.application.status;
+
+import java.io.Serializable;
+
+/**
+ * This event will be fired upon the application terminating is detected.
+ */
+public class AppStatusApplicationTerminatingEvent extends StatusEvent implements Serializable {
+ private static final long serialVersionUID = 2625412714611885089L;
+
+ private String appId;
+
+ public AppStatusApplicationTerminatingEvent(String appId) {
+ this.appId = appId;
+ }
+
+ public String getAppId() {
+ return appId;
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/4e4ba5b3/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusClusterActivatedEvent.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusClusterActivatedEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusClusterActivatedEvent.java
new file mode 100644
index 0000000..c5737c6
--- /dev/null
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusClusterActivatedEvent.java
@@ -0,0 +1,50 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.stratos.messaging.event.application.status;
+
+/**
+ * This event is fired by cartridge agent when it has started the server and
+ * applications are ready to serve the incoming requests.
+ */
+public class AppStatusClusterActivatedEvent extends StatusEvent {
+ private static final long serialVersionUID = 2625412714611885089L;
+
+ private final String serviceName;
+ private final String clusterId;
+ private String appId;
+
+ public AppStatusClusterActivatedEvent(String appId, String serviceName, String clusterId) {
+ this.serviceName = serviceName;
+ this.clusterId = clusterId;
+ this.appId = appId;
+ }
+
+ public String getServiceName() {
+ return serviceName;
+ }
+
+ public String getClusterId() {
+ return clusterId;
+ }
+
+ public String getAppId() {
+ return appId;
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/4e4ba5b3/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusClusterInactivateEvent.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusClusterInactivateEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusClusterInactivateEvent.java
new file mode 100644
index 0000000..6d8ed46
--- /dev/null
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusClusterInactivateEvent.java
@@ -0,0 +1,50 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.stratos.messaging.event.application.status;
+
+/**
+ * This event is fired by cartridge agent when it has started the server and
+ * applications are ready to serve the incoming requests.
+ */
+public class AppStatusClusterInactivateEvent extends StatusEvent {
+ private static final long serialVersionUID = 2625412714611885089L;
+
+ private final String serviceName;
+ private final String clusterId;
+ private String appId;
+
+ public AppStatusClusterInactivateEvent(String appId, String serviceName, String clusterId) {
+ this.serviceName = serviceName;
+ this.clusterId = clusterId;
+ this.appId = appId;
+ }
+
+ public String getServiceName() {
+ return serviceName;
+ }
+
+ public String getClusterId() {
+ return clusterId;
+ }
+
+ public String getAppId() {
+ return appId;
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/4e4ba5b3/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusClusterMaintenanceModeEvent.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusClusterMaintenanceModeEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusClusterMaintenanceModeEvent.java
new file mode 100644
index 0000000..527d86e
--- /dev/null
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusClusterMaintenanceModeEvent.java
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.stratos.messaging.event.application.status;
+
+import java.io.Serializable;
+
+/**
+ * This will be fired upon the cluster instability detection by either cep/autoscaler.
+ */
+public class AppStatusClusterMaintenanceModeEvent extends StatusEvent implements Serializable {
+ private final String serviceName;
+ private final String clusterId;
+ private String appId;
+
+ public AppStatusClusterMaintenanceModeEvent(String appId, String serviceName, String clusterId) {
+ this.serviceName = serviceName;
+ this.clusterId = clusterId;
+ this.appId = appId;
+ }
+
+ public String getServiceName() {
+ return serviceName;
+ }
+
+ public String getClusterId() {
+ return clusterId;
+ }
+
+
+ public String getAppId() {
+ return appId;
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/4e4ba5b3/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusClusterReadyToShutdownEvent.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusClusterReadyToShutdownEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusClusterReadyToShutdownEvent.java
new file mode 100644
index 0000000..7841d9c
--- /dev/null
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusClusterReadyToShutdownEvent.java
@@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.stratos.messaging.event.application.status;
+
+/**
+ * This event is fired by autoscaler before actually terminate a cluster.
+ */
+public class AppStatusClusterReadyToShutdownEvent extends StatusEvent {
+ private final String serviceName;
+ private final String clusterId;
+ private String appId;
+
+ public AppStatusClusterReadyToShutdownEvent(String appId, String serviceName, String clusterId) {
+ this.serviceName = serviceName;
+ this.clusterId = clusterId;
+ this.appId = appId;
+ }
+
+ public String getServiceName() {
+ return serviceName;
+ }
+
+ public String getClusterId() {
+ return clusterId;
+ }
+
+
+ public String getAppId() {
+ return appId;
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/4e4ba5b3/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusGroupActivatedEvent.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusGroupActivatedEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusGroupActivatedEvent.java
new file mode 100644
index 0000000..3da8667
--- /dev/null
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusGroupActivatedEvent.java
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.stratos.messaging.event.application.status;
+
+/**
+ * This event is fired by cartridge agent when it has started the server and
+ * applications are ready to serve the incoming requests.
+ */
+public class AppStatusGroupActivatedEvent extends StatusEvent {
+ private static final long serialVersionUID = 2625412714611885089L;
+
+ private String groupId;
+ private String appId;
+
+ public AppStatusGroupActivatedEvent(String appId, String groupId) {
+ this.appId = appId;
+ this.groupId = groupId;
+ }
+
+ public String getGroupId() {
+ return this.groupId;
+ }
+
+ public String getAppId() {
+ return appId;
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/4e4ba5b3/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusGroupInactivateEvent.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusGroupInactivateEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusGroupInactivateEvent.java
new file mode 100644
index 0000000..ee26292
--- /dev/null
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusGroupInactivateEvent.java
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.stratos.messaging.event.application.status;
+
+/**
+ * This event is fired by cartridge agent when it has started the server and
+ * applications are ready to serve the incoming requests.
+ */
+public class AppStatusGroupInactivateEvent extends StatusEvent {
+ private static final long serialVersionUID = 2625412714611885089L;
+
+ private String groupId;
+ private String appId;
+
+ public AppStatusGroupInactivateEvent(String appId, String groupId) {
+ this.appId = appId;
+ this.groupId = groupId;
+ }
+
+ public String getGroupId() {
+ return this.groupId;
+ }
+
+ public String getAppId() {
+ return appId;
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/4e4ba5b3/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusGroupMaintenanceModeEvent.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusGroupMaintenanceModeEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusGroupMaintenanceModeEvent.java
new file mode 100644
index 0000000..a1a787c
--- /dev/null
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusGroupMaintenanceModeEvent.java
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.stratos.messaging.event.application.status;
+
+/**
+ * This event will be fired upon the instability of group detection by autoscaler.
+ */
+public class AppStatusGroupMaintenanceModeEvent extends StatusEvent {
+ private String groupId;
+ private String appId;
+
+ public AppStatusGroupMaintenanceModeEvent(String appId, String groupId) {
+ this.appId = appId;
+ this.groupId = groupId;
+ }
+
+ public String getGroupId(String groupId) {
+ return this.groupId;
+ }
+
+ public String getAppId() {
+ return appId;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/4e4ba5b3/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusGroupReadyToShutdownEvent.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusGroupReadyToShutdownEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusGroupReadyToShutdownEvent.java
new file mode 100644
index 0000000..eaba17d
--- /dev/null
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusGroupReadyToShutdownEvent.java
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.stratos.messaging.event.application.status;
+
+/**
+ * This event is fired by autoscaler before actually terminate a group.
+ */
+public class AppStatusGroupReadyToShutdownEvent extends StatusEvent {
+ private String groupId;
+ private String appId;
+
+ public AppStatusGroupReadyToShutdownEvent(String appId, String groupId) {
+ this.appId = appId;
+ this.groupId = groupId;
+ }
+
+ public String getGroupId(String groupId) {
+ return this.groupId;
+ }
+
+ public String getAppId() {
+ return appId;
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/4e4ba5b3/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusGroupTerminatedEvent.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusGroupTerminatedEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusGroupTerminatedEvent.java
new file mode 100644
index 0000000..db31b64
--- /dev/null
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusGroupTerminatedEvent.java
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.stratos.messaging.event.application.status;
+
+/**
+ * This event is fired by cartridge agent when it has started the server and
+ * applications are ready to serve the incoming requests.
+ */
+public class AppStatusGroupTerminatedEvent extends StatusEvent {
+ private static final long serialVersionUID = 2625412714611885089L;
+
+ private String groupId;
+ private String appId;
+
+ public AppStatusGroupTerminatedEvent(String appId, String groupId) {
+ this.appId = appId;
+ this.groupId = groupId;
+ }
+
+ public String getGroupId() {
+ return this.groupId;
+ }
+
+ public String getAppId() {
+ return appId;
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/4e4ba5b3/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusGroupTerminatingEvent.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusGroupTerminatingEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusGroupTerminatingEvent.java
new file mode 100644
index 0000000..52db5fb
--- /dev/null
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusGroupTerminatingEvent.java
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.stratos.messaging.event.application.status;
+
+/**
+ * This event is fired by cartridge agent when it has started the server and
+ * applications are ready to serve the incoming requests.
+ */
+public class AppStatusGroupTerminatingEvent extends StatusEvent {
+ private static final long serialVersionUID = 2625412714611885089L;
+
+ private String groupId;
+ private String appId;
+
+ public AppStatusGroupTerminatingEvent(String appId, String groupId) {
+ this.appId = appId;
+ this.groupId = groupId;
+ }
+
+ public String getGroupId() {
+ return this.groupId;
+ }
+
+ public String getAppId() {
+ return appId;
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/4e4ba5b3/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/ApplicationActivatedEvent.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/ApplicationActivatedEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/ApplicationActivatedEvent.java
deleted file mode 100644
index 1f64c7a..0000000
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/ApplicationActivatedEvent.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.stratos.messaging.event.application.status;
-
-import java.io.Serializable;
-
-/**
- * This event will be fired upon the application activated is detected.
- */
-public class ApplicationActivatedEvent extends StatusEvent implements Serializable {
- private static final long serialVersionUID = 2625412714611885089L;
-
- private String appId;
-
- public ApplicationActivatedEvent(String appId) {
- this.appId = appId;
- }
-
- public String getAppId() {
- return appId;
- }
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/4e4ba5b3/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/ApplicationCreatedEvent.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/ApplicationCreatedEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/ApplicationCreatedEvent.java
deleted file mode 100644
index b2f02e5..0000000
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/ApplicationCreatedEvent.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.stratos.messaging.event.application.status;
-
-import java.io.Serializable;
-
-/**
- * This event will be fired upon the application created is detected.
- */
-public class ApplicationCreatedEvent extends StatusEvent implements Serializable {
- private static final long serialVersionUID = 2625412714611885089L;
-
- private String appId;
-
- public ApplicationCreatedEvent(String appId) {
- this.appId = appId;
- }
-
- public String getAppId() {
- return appId;
- }
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/4e4ba5b3/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/ApplicationInactivatedEvent.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/ApplicationInactivatedEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/ApplicationInactivatedEvent.java
deleted file mode 100644
index c082981..0000000
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/ApplicationInactivatedEvent.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.stratos.messaging.event.application.status;
-
-import java.io.Serializable;
-
-/**
- * This event will be fired upon the application inactivated is detected.
- */
-public class ApplicationInactivatedEvent extends StatusEvent implements Serializable {
- private static final long serialVersionUID = 2625412714611885089L;
-
- private String appId;
-
- public ApplicationInactivatedEvent(String appId) {
- this.appId = appId;
- }
-
- public String getAppId() {
- return appId;
- }
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/4e4ba5b3/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/ApplicationTerminatedEvent.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/ApplicationTerminatedEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/ApplicationTerminatedEvent.java
deleted file mode 100644
index 5151501..0000000
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/ApplicationTerminatedEvent.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.stratos.messaging.event.application.status;
-
-import org.apache.stratos.messaging.domain.topology.ClusterDataHolder;
-
-import java.io.Serializable;
-import java.util.Set;
-
-/**
- * This event will be fired upon the application terminated is detected.
- */
-public class ApplicationTerminatedEvent extends StatusEvent implements Serializable {
- private static final long serialVersionUID = 2625412714611885089L;
-
- private String appId;
- private Set<ClusterDataHolder> clusterData;
-
- public ApplicationTerminatedEvent(String appId, Set<ClusterDataHolder> clusterData) {
- this.appId = appId;
- this.clusterData = clusterData;
- }
-
- public String getAppId() {
- return appId;
- }
-
- public Set<ClusterDataHolder> getClusterData() {
- return clusterData;
- }
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/4e4ba5b3/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/ApplicationTerminatingEvent.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/ApplicationTerminatingEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/ApplicationTerminatingEvent.java
deleted file mode 100644
index 9d3f966..0000000
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/ApplicationTerminatingEvent.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.stratos.messaging.event.application.status;
-
-import java.io.Serializable;
-
-/**
- * This event will be fired upon the application terminating is detected.
- */
-public class ApplicationTerminatingEvent extends StatusEvent implements Serializable {
- private static final long serialVersionUID = 2625412714611885089L;
-
- private String appId;
-
- public ApplicationTerminatingEvent(String appId) {
- this.appId = appId;
- }
-
- public String getAppId() {
- return appId;
- }
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/4e4ba5b3/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/ClusterActivatedEvent.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/ClusterActivatedEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/ClusterActivatedEvent.java
deleted file mode 100644
index c1434dd..0000000
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/ClusterActivatedEvent.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.stratos.messaging.event.application.status;
-
-import java.io.Serializable;
-
-/**
- * This event is fired by cartridge agent when it has started the server and
- * applications are ready to serve the incoming requests.
- */
-public class ClusterActivatedEvent extends StatusEvent {
- private static final long serialVersionUID = 2625412714611885089L;
-
- private final String serviceName;
- private final String clusterId;
- private String appId;
-
- public ClusterActivatedEvent(String appId, String serviceName, String clusterId) {
- this.serviceName = serviceName;
- this.clusterId = clusterId;
- this.appId = appId;
- }
-
- public String getServiceName() {
- return serviceName;
- }
-
- public String getClusterId() {
- return clusterId;
- }
-
- public String getAppId() {
- return appId;
- }
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/4e4ba5b3/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/ClusterInActivateEvent.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/ClusterInActivateEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/ClusterInActivateEvent.java
deleted file mode 100644
index e2a5887..0000000
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/ClusterInActivateEvent.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.stratos.messaging.event.application.status;
-
-/**
- * This event is fired by cartridge agent when it has started the server and
- * applications are ready to serve the incoming requests.
- */
-public class ClusterInActivateEvent extends StatusEvent {
- private static final long serialVersionUID = 2625412714611885089L;
-
- private final String serviceName;
- private final String clusterId;
- private String appId;
-
- public ClusterInActivateEvent(String appId, String serviceName, String clusterId) {
- this.serviceName = serviceName;
- this.clusterId = clusterId;
- this.appId = appId;
- }
-
- public String getServiceName() {
- return serviceName;
- }
-
- public String getClusterId() {
- return clusterId;
- }
-
- public String getAppId() {
- return appId;
- }
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/4e4ba5b3/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/ClusterMaintenanceModeEvent.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/ClusterMaintenanceModeEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/ClusterMaintenanceModeEvent.java
deleted file mode 100644
index b9f6158..0000000
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/ClusterMaintenanceModeEvent.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.stratos.messaging.event.application.status;
-
-import java.io.Serializable;
-
-/**
- * This will be fired upon the cluster instability detection by either cep/autoscaler.
- */
-public class ClusterMaintenanceModeEvent extends StatusEvent implements Serializable {
- private final String serviceName;
- private final String clusterId;
- private String appId;
-
- public ClusterMaintenanceModeEvent(String appId, String serviceName, String clusterId) {
- this.serviceName = serviceName;
- this.clusterId = clusterId;
- this.appId = appId;
- }
-
- public String getServiceName() {
- return serviceName;
- }
-
- public String getClusterId() {
- return clusterId;
- }
-
-
- public String getAppId() {
- return appId;
- }
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/4e4ba5b3/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/ClusterReadyToShutdownEvent.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/ClusterReadyToShutdownEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/ClusterReadyToShutdownEvent.java
deleted file mode 100644
index b76bb7e..0000000
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/ClusterReadyToShutdownEvent.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.stratos.messaging.event.application.status;
-
-/**
- * This event is fired by autoscaler before actually terminate a cluster.
- */
-public class ClusterReadyToShutdownEvent extends StatusEvent {
- private final String serviceName;
- private final String clusterId;
- private String appId;
-
- public ClusterReadyToShutdownEvent(String appId, String serviceName, String clusterId) {
- this.serviceName = serviceName;
- this.clusterId = clusterId;
- this.appId = appId;
- }
-
- public String getServiceName() {
- return serviceName;
- }
-
- public String getClusterId() {
- return clusterId;
- }
-
-
- public String getAppId() {
- return appId;
- }
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/4e4ba5b3/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/GroupActivatedEvent.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/GroupActivatedEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/GroupActivatedEvent.java
deleted file mode 100644
index 2357881..0000000
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/GroupActivatedEvent.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.stratos.messaging.event.application.status;
-
-/**
- * This event is fired by cartridge agent when it has started the server and
- * applications are ready to serve the incoming requests.
- */
-public class GroupActivatedEvent extends StatusEvent {
- private static final long serialVersionUID = 2625412714611885089L;
-
- private String groupId;
- private String appId;
-
- public GroupActivatedEvent(String appId, String groupId) {
- this.appId = appId;
- this.groupId = groupId;
- }
-
- public String getGroupId() {
- return this.groupId;
- }
-
- public String getAppId() {
- return appId;
- }
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/4e4ba5b3/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/GroupInTerminatedEvent.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/GroupInTerminatedEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/GroupInTerminatedEvent.java
deleted file mode 100644
index 16cc0c7..0000000
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/GroupInTerminatedEvent.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.stratos.messaging.event.application.status;
-
-/**
- * This event is fired by cartridge agent when it has started the server and
- * applications are ready to serve the incoming requests.
- */
-public class GroupInTerminatedEvent extends StatusEvent {
- private static final long serialVersionUID = 2625412714611885089L;
-
- private String groupId;
- private String appId;
-
- public GroupInTerminatedEvent(String appId, String groupId) {
- this.appId = appId;
- this.groupId = groupId;
- }
-
- public String getGroupId() {
- return this.groupId;
- }
-
- public String getAppId() {
- return appId;
- }
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/4e4ba5b3/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/GroupInTerminatingEvent.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/GroupInTerminatingEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/GroupInTerminatingEvent.java
deleted file mode 100644
index 6eaf5c3..0000000
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/GroupInTerminatingEvent.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.stratos.messaging.event.application.status;
-
-/**
- * This event is fired by cartridge agent when it has started the server and
- * applications are ready to serve the incoming requests.
- */
-public class GroupInTerminatingEvent extends StatusEvent {
- private static final long serialVersionUID = 2625412714611885089L;
-
- private String groupId;
- private String appId;
-
- public GroupInTerminatingEvent(String appId, String groupId) {
- this.appId = appId;
- this.groupId = groupId;
- }
-
- public String getGroupId() {
- return this.groupId;
- }
-
- public String getAppId() {
- return appId;
- }
-}
[32/50] [abbrv] git commit: moving force termination to a separate
thread
Posted by im...@apache.org.
moving force termination to a separate thread
Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/d474b136
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/d474b136
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/d474b136
Branch: refs/heads/docker-grouping-merge
Commit: d474b13671ccdfc4fdff31d15795dc71f5ad62f9
Parents: 1b7064d
Author: Isuru Haththotuwa <is...@apache.org>
Authored: Wed Oct 29 11:51:16 2014 +0530
Committer: Isuru Haththotuwa <is...@apache.org>
Committed: Wed Oct 29 11:51:27 2014 +0530
----------------------------------------------------------------------
.../AutoscalerTopologyEventReceiver.java | 14 ++---
.../monitor/cluster/ClusterMonitor.java | 57 ++++++++++++++++----
2 files changed, 55 insertions(+), 16 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/stratos/blob/d474b136/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 7b411b8..608100a 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
@@ -389,12 +389,14 @@ public class AutoscalerTopologyEventReceiver implements Runnable {
} else {
// if not active, forcefully terminate
clusterMonitor.setStatus(ClusterStatus.Terminating);
- try {
- CloudControllerClient.getInstance().terminateAllInstances(clusterData.getClusterId());
- } catch (TerminationException e) {
- log.error("Unable to terminate instances for [ cluster id ] " +
- clusterData.getClusterId(), e);
- }
+ 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());
http://git-wip-us.apache.org/repos/asf/stratos/blob/d474b136/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 d67b4f4..69dac23 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
@@ -22,7 +22,9 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.stratos.autoscaler.NetworkPartitionContext;
import org.apache.stratos.autoscaler.PartitionContext;
+import org.apache.stratos.autoscaler.client.cloud.controller.CloudControllerClient;
import org.apache.stratos.autoscaler.deployment.policy.DeploymentPolicy;
+import org.apache.stratos.autoscaler.exception.TerminationException;
import org.apache.stratos.autoscaler.monitor.AbstractClusterMonitor;
import org.apache.stratos.autoscaler.monitor.events.MonitorStatusEvent;
import org.apache.stratos.autoscaler.policy.model.AutoscalePolicy;
@@ -101,17 +103,52 @@ public class ClusterMonitor extends AbstractClusterMonitor {
@Override
public void terminateAllMembers() {
- for (NetworkPartitionContext networkPartitionContext : networkPartitionCtxts.values()) {
- for (PartitionContext partitionContext : networkPartitionContext.getPartitionCtxts().values()) {
- //if (log.isDebugEnabled()) {
- log.info("Starting to terminate all members in Network Partition [ " +
- networkPartitionContext.getId() + " ], Partition [ " +
- partitionContext.getPartitionId() + " ]");
- // }
-
- terminateAllFactHandle = AutoscalerRuleEvaluator.evaluateTerminateAll
- (terminateAllKnowledgeSession, terminateAllFactHandle, partitionContext);
+ Thread memberTerminator = new Thread(new Runnable(){
+ public void run(){
+
+ for (NetworkPartitionContext networkPartitionContext : networkPartitionCtxts.values()) {
+ for (PartitionContext partitionContext : networkPartitionContext.getPartitionCtxts().values()) {
+ //if (log.isDebugEnabled()) {
+ log.info("Starting to terminate all members in Network Partition [ " +
+ networkPartitionContext.getId() + " ], Partition [ " +
+ partitionContext.getPartitionId() + " ]");
+ // }
+ // need to terminate active, pending and obsolete members
+
+ // active members
+ for (MemberContext activeMemberCtxt : partitionContext.getActiveMembers()) {
+ log.info("Terminating active member [member id] " + activeMemberCtxt.getMemberId());
+ terminateMember(activeMemberCtxt.getMemberId());
+ }
+
+ // pending members
+ for (MemberContext pendingMemberCtxt : partitionContext.getPendingMembers()) {
+ log.info("Terminating pending member [member id] " + pendingMemberCtxt.getMemberId());
+ terminateMember(pendingMemberCtxt.getMemberId());
+ }
+
+ // obsolete members
+ for (String obsoleteMemberId : partitionContext.getObsoletedMembers()) {
+ log.info("Terminating obsolete member [member id] " + obsoleteMemberId);
+ terminateMember(obsoleteMemberId);
+ }
+
+// terminateAllFactHandle = AutoscalerRuleEvaluator.evaluateTerminateAll
+// (terminateAllKnowledgeSession, terminateAllFactHandle, partitionContext);
+ }
+ }
}
+ }, "Member Terminator - [cluster id] " + this.clusterId);
+
+ memberTerminator.start();
+ }
+
+ private static void terminateMember (String memberId) {
+ try {
+ CloudControllerClient.getInstance().terminate(memberId);
+
+ } catch (TerminationException e) {
+ log.error("Unable to terminate member [member id ] " + memberId, e);
}
}
[14/50] [abbrv] git commit: using correct events and processors
Posted by im...@apache.org.
using correct events and processors
Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/2f1b92be
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/2f1b92be
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/2f1b92be
Branch: refs/heads/docker-grouping-merge
Commit: 2f1b92be4b4f74b90da78cc0655523c232225a96
Parents: aef9c12
Author: reka <rt...@gmail.com>
Authored: Mon Oct 27 18:43:28 2014 +0530
Committer: reka <rt...@gmail.com>
Committed: Mon Oct 27 18:43:28 2014 +0530
----------------------------------------------------------------------
.../grouping/topic/StatusEventPublisher.java | 20 +++-----------------
.../topology/GroupInActivateProcessor.java | 2 +-
2 files changed, 4 insertions(+), 18 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/stratos/blob/2f1b92be/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/StatusEventPublisher.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/StatusEventPublisher.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/StatusEventPublisher.java
index 3a3af88..ee75f74 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/StatusEventPublisher.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/StatusEventPublisher.java
@@ -14,8 +14,6 @@ import org.apache.stratos.messaging.event.application.status.AppStatusApplicatio
import org.apache.stratos.messaging.event.application.status.AppStatusClusterActivatedEvent;
import org.apache.stratos.messaging.event.application.status.AppStatusClusterInactivateEvent;
import org.apache.stratos.messaging.event.application.status.AppStatusGroupActivatedEvent;
-import org.apache.stratos.messaging.event.topology.*;
-import org.apache.stratos.messaging.event.topology.GroupInactivateEvent;
import org.apache.stratos.messaging.util.Constants;
import java.util.Set;
@@ -26,19 +24,6 @@ import java.util.Set;
public class StatusEventPublisher {
private static final Log log = LogFactory.getLog(StatusEventPublisher.class);
- public static void sendClusterCreatedEvent(String appId, String serviceName, String clusterId) {
-
- if (log.isInfoEnabled()) {
- log.info("Publishing Cluster activated event for [application]: " + appId +
- " [cluster]: " + clusterId);
- }
-
-
- ClusterCreatedEvent clusterCreatedEvent = new ClusterCreatedEvent(appId, serviceName, clusterId);
-
- publishEvent(clusterCreatedEvent);
- }
-
public static void sendClusterActivatedEvent(String appId, String serviceName, String clusterId) {
if (log.isInfoEnabled()) {
@@ -110,9 +95,10 @@ public class StatusEventPublisher {
" [group]: " + groupId);
}
- GroupInactivateEvent groupInactivateEvent = new GroupInactivateEvent(appId, groupId);
+ AppStatusGroupInactivateEvent appStatusGroupInactivateEvent= new
+ AppStatusGroupInactivateEvent(appId, groupId);
- publishEvent(groupInactivateEvent);
+ publishEvent(appStatusGroupInactivateEvent);
}
public static void sendGroupTerminatingEvent(String appId, String groupId) {
http://git-wip-us.apache.org/repos/asf/stratos/blob/2f1b92be/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupInActivateProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupInActivateProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupInActivateProcessor.java
index f8fe705..094196b 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupInActivateProcessor.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupInActivateProcessor.java
@@ -46,7 +46,7 @@ public class GroupInActivateProcessor extends MessageProcessor {
public boolean process(String type, String message, Object object) {
Topology topology = (Topology) object;
- if (GroupActivatedEvent.class.getName().equals(type)) {
+ if (GroupInactivateEvent.class.getName().equals(type)) {
// Return if topology has not been initialized
if (!topology.isInitialized())
return false;
[09/50] [abbrv] git commit: fixing cep listening on topology issue by
merging with master
Posted by im...@apache.org.
fixing cep listening on topology issue by merging with master
Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/7a5797df
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/7a5797df
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/7a5797df
Branch: refs/heads/docker-grouping-merge
Commit: 7a5797df08bbf92483cd5993e6ce9ca576686e3d
Parents: bea691b
Author: reka <rt...@gmail.com>
Authored: Mon Oct 27 14:10:15 2014 +0530
Committer: reka <rt...@gmail.com>
Committed: Mon Oct 27 14:14:22 2014 +0530
----------------------------------------------------------------------
.../cep/extension/CEPTopologyEventReceiver.java | 125 +++++++++++
.../extension/FaultHandlingWindowProcessor.java | 217 ++++++++++++-------
2 files changed, 267 insertions(+), 75 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/stratos/blob/7a5797df/extensions/cep/stratos-cep-extension/src/main/java/org/apache/stratos/cep/extension/CEPTopologyEventReceiver.java
----------------------------------------------------------------------
diff --git a/extensions/cep/stratos-cep-extension/src/main/java/org/apache/stratos/cep/extension/CEPTopologyEventReceiver.java b/extensions/cep/stratos-cep-extension/src/main/java/org/apache/stratos/cep/extension/CEPTopologyEventReceiver.java
new file mode 100644
index 0000000..90c67f0
--- /dev/null
+++ b/extensions/cep/stratos-cep-extension/src/main/java/org/apache/stratos/cep/extension/CEPTopologyEventReceiver.java
@@ -0,0 +1,125 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.stratos.cep.extension;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.messaging.event.Event;
+import org.apache.stratos.messaging.event.topology.CompleteTopologyEvent;
+import org.apache.stratos.messaging.event.topology.MemberActivatedEvent;
+import org.apache.stratos.messaging.event.topology.MemberTerminatedEvent;
+import org.apache.stratos.messaging.listener.topology.CompleteTopologyEventListener;
+import org.apache.stratos.messaging.listener.topology.MemberActivatedEventListener;
+import org.apache.stratos.messaging.listener.topology.MemberTerminatedEventListener;
+import org.apache.stratos.messaging.message.receiver.topology.TopologyEventReceiver;
+import org.apache.stratos.messaging.message.receiver.topology.TopologyManager;
+
+/**
+ * CEP Topology Receiver for Fault Handling Window Processor.
+ */
+public class CEPTopologyEventReceiver implements Runnable {
+
+ private static final Log log = LogFactory.getLog(CEPTopologyEventReceiver.class);
+
+ private TopologyEventReceiver topologyEventReceiver;
+ private boolean terminated;
+ private FaultHandlingWindowProcessor faultHandler;
+
+ public CEPTopologyEventReceiver(FaultHandlingWindowProcessor faultHandler) {
+ this.topologyEventReceiver = new TopologyEventReceiver();
+ this.faultHandler = faultHandler;
+ addEventListeners();
+ }
+
+ private void addEventListeners() {
+ // Load member time stamp map from the topology as a one time task
+ topologyEventReceiver.addEventListener(new CompleteTopologyEventListener() {
+ private boolean initialized;
+
+ @Override
+ protected void onEvent(Event event) {
+ if (!initialized) {
+ try {
+ TopologyManager.acquireReadLock();
+ log.info("Complete topology event received to fault handling window processor.");
+ CompleteTopologyEvent completeTopologyEvent = (CompleteTopologyEvent) event;
+ initialized = faultHandler.loadTimeStampMapFromTopology(completeTopologyEvent.getTopology());
+ } catch (Exception e) {
+ log.error("Error loading member time stamp map from complete topology event.", e);
+ } finally {
+ TopologyManager.releaseReadLock();
+ }
+ }
+ }
+ });
+
+ // Remove member from the time stamp map when MemberTerminated event is received.
+ topologyEventReceiver.addEventListener(new MemberTerminatedEventListener() {
+ @Override
+ protected void onEvent(Event event) {
+ MemberTerminatedEvent memberTerminatedEvent = (MemberTerminatedEvent) event;
+ faultHandler.getMemberTimeStampMap().remove(memberTerminatedEvent.getMemberId());
+ log.info("Member [member id] " + memberTerminatedEvent.getMemberId() +
+ " was removed from the time stamp map.");
+ }
+ });
+
+ // Add member to time stamp map whenever member is activated
+ topologyEventReceiver.addEventListener(new MemberActivatedEventListener() {
+ @Override
+ protected void onEvent(Event event) {
+ MemberActivatedEvent memberActivatedEvent = (MemberActivatedEvent) event;
+
+ // do not put this member if we have already received a health event
+ faultHandler.getMemberTimeStampMap().putIfAbsent(memberActivatedEvent.getMemberId(), System.currentTimeMillis());
+ log.info("Member [member id] " + memberActivatedEvent.getMemberId() +
+ " was added to the time stamp map.");
+ }
+ });
+ }
+
+ @Override
+ public void run() {
+ try {
+ Thread.sleep(15000);
+ } catch (InterruptedException ignore) {
+ }
+ Thread thread = new Thread(topologyEventReceiver);
+ thread.start();
+ log.info("CEP topology receiver thread started");
+
+ // Keep the thread live until terminated
+ while (!terminated) {
+ try {
+ Thread.sleep(1000);
+ } catch (InterruptedException ignore) {
+ }
+ }
+ log.info("CEP topology receiver thread terminated");
+ }
+
+ /**
+ * Terminate CEP topology receiver thread.
+ */
+ public void terminate() {
+ topologyEventReceiver.terminate();
+ terminated = true;
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/stratos/blob/7a5797df/extensions/cep/stratos-cep-extension/src/main/java/org/apache/stratos/cep/extension/FaultHandlingWindowProcessor.java
----------------------------------------------------------------------
diff --git a/extensions/cep/stratos-cep-extension/src/main/java/org/apache/stratos/cep/extension/FaultHandlingWindowProcessor.java b/extensions/cep/stratos-cep-extension/src/main/java/org/apache/stratos/cep/extension/FaultHandlingWindowProcessor.java
index 80174f4..0104a03 100644
--- a/extensions/cep/stratos-cep-extension/src/main/java/org/apache/stratos/cep/extension/FaultHandlingWindowProcessor.java
+++ b/extensions/cep/stratos-cep-extension/src/main/java/org/apache/stratos/cep/extension/FaultHandlingWindowProcessor.java
@@ -18,14 +18,19 @@
*/
package org.apache.stratos.cep.extension;
+import org.apache.commons.lang3.StringUtils;
import org.apache.log4j.Logger;
import org.apache.stratos.messaging.broker.publish.EventPublisher;
import org.apache.stratos.messaging.broker.publish.EventPublisherPool;
-import org.apache.stratos.messaging.domain.topology.Cluster;
-import org.apache.stratos.messaging.domain.topology.Member;
-import org.apache.stratos.messaging.domain.topology.MemberStatus;
-import org.apache.stratos.messaging.domain.topology.Service;
+import org.apache.stratos.messaging.domain.topology.*;
+import org.apache.stratos.messaging.event.Event;
import org.apache.stratos.messaging.event.health.stat.MemberFaultEvent;
+import org.apache.stratos.messaging.event.topology.CompleteTopologyEvent;
+import org.apache.stratos.messaging.event.topology.MemberActivatedEvent;
+import org.apache.stratos.messaging.event.topology.MemberTerminatedEvent;
+import org.apache.stratos.messaging.listener.topology.CompleteTopologyEventListener;
+import org.apache.stratos.messaging.listener.topology.MemberActivatedEventListener;
+import org.apache.stratos.messaging.listener.topology.MemberTerminatedEventListener;
import org.apache.stratos.messaging.message.receiver.topology.TopologyEventReceiver;
import org.apache.stratos.messaging.message.receiver.topology.TopologyManager;
import org.apache.stratos.messaging.util.Constants;
@@ -52,23 +57,31 @@ import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
+/**
+ * CEP window processor to handle faulty member instances. This window processor is responsible for
+ * publishing MemberFault event if health stats are not received within a given time window.
+ */
@SiddhiExtension(namespace = "stratos", function = "faultHandling")
public class FaultHandlingWindowProcessor extends WindowProcessor implements RunnableWindowProcessor {
private static final int TIME_OUT = 60 * 1000;
static final Logger log = Logger.getLogger(FaultHandlingWindowProcessor.class);
- private ScheduledExecutorService eventRemoverScheduler;
- private int subjectedAttrIndex;
+ private ScheduledExecutorService faultHandleScheduler;
private ThreadBarrier threadBarrier;
private long timeToKeep;
private ISchedulerSiddhiQueue<StreamEvent> window;
+ private EventPublisher healthStatPublisher = EventPublisherPool.getPublisher(Constants.HEALTH_STAT_TOPIC);
+ private Map<String, Object> MemberFaultEventMap = new HashMap<String, Object>();
+ private Map<String, Object> memberFaultEventMessageMap = new HashMap<String, Object>();
+
+ // Map of member id's to their last received health event time stamp
private ConcurrentHashMap<String, Long> memberTimeStampMap = new ConcurrentHashMap<String, Long>();
- private ConcurrentHashMap<String, Member> memberIdMap = new ConcurrentHashMap<String, Member>();
- EventPublisher healthStatPublisher = EventPublisherPool.getPublisher(Constants.HEALTH_STAT_TOPIC);
- Map<String, Object> MemberFaultEventMap = new HashMap<String, Object>();
- Map<String, Object> memberFaultEventMessageMap = new HashMap<String, Object>();
- private TopologyEventReceiver topologyEventReceiver;
- private String memberID;
+
+ // Event receiver to receive topology events published by cloud-controller
+ private CEPTopologyEventReceiver cepTopologyEventReceiver = new CEPTopologyEventReceiver(this);
+
+ // Stratos member id attribute index in stream execution plan
+ private int memberIdAttrIndex;
@Override
protected void processEvent(InEvent event) {
@@ -77,20 +90,34 @@ public class FaultHandlingWindowProcessor extends WindowProcessor implements Run
@Override
protected void processEvent(InListEvent listEvent) {
- System.out.println(listEvent);
for (int i = 0, size = listEvent.getActiveEvents(); i < size; i++) {
addDataToMap((InEvent) listEvent.getEvent(i));
}
}
+ /**
+ * Add new entry to time stamp map from the received event.
+ *
+ * @param event Event received by Siddhi.
+ */
protected void addDataToMap(InEvent event) {
- if (memberID != null) {
- String id = (String)event.getData()[subjectedAttrIndex];
+ String id = (String) event.getData()[memberIdAttrIndex];
+ //checking whether this member is the topology.
+ //sometimes there can be a delay between publishing member terminated events
+ //and actually terminating instances. Hence CEP might get events for already terminated members
+ //so we are checking the topology for the member existence
+ Member member = getMemberFromId(id);
+ if (null == member) {
+ log.debug("Member not found in the toplogy. Event rejected");
+ return;
+ }
+ if (StringUtils.isNotEmpty(id)) {
memberTimeStampMap.put(id, event.getTimeStamp());
- log.debug("Event received from [member-id] " + id);
+ } else {
+ log.warn("NULL member id found in the event received. Event rejected.");
}
- else {
- log.error("NULL member ID in the event received");
+ if (log.isDebugEnabled()){
+ log.debug("Event received from [member-id] " + id + " [time-stamp] " + event.getTimeStamp());
}
}
@@ -108,55 +135,88 @@ public class FaultHandlingWindowProcessor extends WindowProcessor implements Run
}
}
- /*
- * Retrieve the current activated member list from the topology and put them into the
- * memberTimeStampMap if not already exists. This will allow the system to recover
- * from any inconsistent state caused by MB/CEP failures.
- */
- private void loadFromTopology(){
- if (TopologyManager.getTopology().isInitialized()){
- TopologyManager.acquireReadLock();
- memberIdMap.clear();
- long currentTimeStamp = System.currentTimeMillis();
- Iterator<Service> servicesItr = TopologyManager.getTopology().getServices().iterator();
- while(servicesItr.hasNext()){
- Service service = servicesItr.next();
- Iterator<Cluster> clusterItr = service.getClusters().iterator();
- while(clusterItr.hasNext()){
- Cluster cluster = clusterItr.next();
- Iterator<Member> memberItr = cluster.getMembers().iterator();
- while(memberItr.hasNext()){
- Member member = memberItr.next();
- if (member.getStatus().equals(MemberStatus.Activated)){
- memberTimeStampMap.putIfAbsent(member.getMemberId(), currentTimeStamp);
- memberIdMap.put(member.getMemberId(), member);
+ /**
+ * Retrieve the current activated members from the topology and initialize the time stamp map.
+ * This will allow the system to recover from a restart
+ *
+ * @param topology Topology model object
+ */
+ boolean loadTimeStampMapFromTopology(Topology topology){
+
+ long currentTimeStamp = System.currentTimeMillis();
+ if (topology == null || topology.getServices() == null){
+ return false;
+ }
+ // TODO make this efficient by adding APIs to messaging component
+ for (Service service : topology.getServices()) {
+ if (service.getClusters() != null) {
+ for (Cluster cluster : service.getClusters()) {
+ if (cluster.getMembers() != null) {
+ for (Member member : cluster.getMembers()) {
+ // we are checking faulty status only in previously activated members
+ if (member != null && MemberStatus.Activated.equals(member.getStatus())) {
+ // Initialize the member time stamp map from the topology at the beginning
+ memberTimeStampMap.putIfAbsent(member.getMemberId(), currentTimeStamp);
+ }
}
}
}
}
- TopologyManager.releaseReadLock();
}
+
+ log.info("Member time stamp map was successfully loaded from the topology.");
if (log.isDebugEnabled()){
log.debug("Member TimeStamp Map: " + memberTimeStampMap);
- log.debug("Member ID Map: " + memberIdMap);
}
+ return true;
}
- private void publishMemberFault(String memberID){
- Member member = memberIdMap.get(memberID);
+ private Member getMemberFromId(String memberId){
+ if (StringUtils.isEmpty(memberId)){
+ return null;
+ }
+ if (TopologyManager.getTopology().isInitialized()){
+ try {
+ TopologyManager.acquireReadLock();
+ if (TopologyManager.getTopology().getServices() == null){
+ return null;
+ }
+ // TODO make this efficient by adding APIs to messaging component
+ for (Service service : TopologyManager.getTopology().getServices()) {
+ if (service.getClusters() != null) {
+ for (Cluster cluster : service.getClusters()) {
+ if (cluster.getMembers() != null) {
+ for (Member member : cluster.getMembers()){
+ if (memberId.equals(member.getMemberId())){
+ return member;
+ }
+ }
+ }
+ }
+ }
+ }
+ } catch (Exception e) {
+ log.error("Error while reading topology" + e);
+ } finally {
+ TopologyManager.releaseReadLock();
+ }
+ }
+ return null;
+ }
+
+ private void publishMemberFault(String memberId){
+ Member member = getMemberFromId(memberId);
if (member == null){
- log.error("Failed to publish MemberFault event. Member having [member-id] " + memberID + " does not exist in topology");
+ log.error("Failed to publish member fault event. Member having [member-id] " + memberId +
+ " does not exist in topology");
return;
}
- MemberFaultEvent memberFaultEvent = new MemberFaultEvent(member.getClusterId(), member.getMemberId(), member.getPartitionId(), 0);
- memberFaultEventMessageMap.put("message", memberFaultEvent);
- Properties headers = new Properties();
- headers.put(Constants.EVENT_CLASS_NAME, memberFaultEvent.getClass().getName());
- healthStatPublisher.publish(MemberFaultEventMap, headers, true);
+ log.info("Publishing member fault event for [member-id] " + memberId);
- if (log.isDebugEnabled()){
- log.debug("Published MemberFault event for [member-id] " + memberID);
- }
+ MemberFaultEvent memberFaultEvent = new MemberFaultEvent(member.getClusterId(), member.getMemberId(),
+ member.getPartitionId(), 0);
+ memberFaultEventMessageMap.put("message", memberFaultEvent);
+ healthStatPublisher.publish(MemberFaultEventMap, true);
}
@@ -164,26 +224,26 @@ public class FaultHandlingWindowProcessor extends WindowProcessor implements Run
public void run() {
try {
threadBarrier.pass();
- loadFromTopology();
- Iterator it = memberTimeStampMap.entrySet().iterator();
- while ( it.hasNext() ) {
- Map.Entry pair = (Map.Entry)it.next();
+ for (Object o : memberTimeStampMap.entrySet()) {
+ Map.Entry pair = (Map.Entry) o;
long currentTime = System.currentTimeMillis();
Long eventTimeStamp = (Long) pair.getValue();
if ((currentTime - eventTimeStamp) > TIME_OUT) {
- log.info("Faulty member detected [member-id] " + pair.getKey() + " with [last time-stamp] " + eventTimeStamp + " [time-out] " + TIME_OUT + " milliseconds");
- it.remove();
+ log.info("Faulty member detected [member-id] " + pair.getKey() + " with [last time-stamp] " +
+ eventTimeStamp + " [time-out] " + TIME_OUT + " milliseconds");
publishMemberFault((String) pair.getKey());
}
}
if (log.isDebugEnabled()){
- log.debug("Fault handling processor iteration completed with [time-stamp map length] " + memberTimeStampMap.size() + " [activated member-count] " + memberIdMap.size());
+ log.debug("Fault handling processor iteration completed with [time-stamp map length] " +
+ memberTimeStampMap.size() + " [time-stamp map] " + memberTimeStampMap);
}
- eventRemoverScheduler.schedule(this, timeToKeep, TimeUnit.MILLISECONDS);
} catch (Throwable t) {
log.error(t.getMessage(), t);
+ } finally {
+ faultHandleScheduler.schedule(this, timeToKeep, TimeUnit.MILLISECONDS);
}
}
@@ -200,17 +260,16 @@ public class FaultHandlingWindowProcessor extends WindowProcessor implements Run
}
@Override
- protected void init(Expression[] parameters, QueryPostProcessingElement nextProcessor, AbstractDefinition streamDefinition, String elementId, boolean async, SiddhiContext siddhiContext) {
+ protected void init(Expression[] parameters, QueryPostProcessingElement nextProcessor,
+ AbstractDefinition streamDefinition, String elementId, boolean async, SiddhiContext siddhiContext) {
if (parameters[0] instanceof IntConstant) {
timeToKeep = ((IntConstant) parameters[0]).getValue();
} else {
timeToKeep = ((LongConstant) parameters[0]).getValue();
}
- memberID = ((Variable)parameters[1]).getAttributeName();
-
- String subjectedAttr = ((Variable)parameters[1]).getAttributeName();
- subjectedAttrIndex = streamDefinition.getAttributePosition(subjectedAttr);
+ String memberIdAttrName = ((Variable) parameters[1]).getAttributeName();
+ memberIdAttrIndex = streamDefinition.getAttributePosition(memberIdAttrName);
if (this.siddhiContext.isDistributedProcessingEnabled()) {
window = new SchedulerSiddhiQueueGrid<StreamEvent>(elementId, this, this.siddhiContext, this.async);
@@ -218,29 +277,32 @@ public class FaultHandlingWindowProcessor extends WindowProcessor implements Run
window = new SchedulerSiddhiQueue<StreamEvent>(this);
}
MemberFaultEventMap.put("org.apache.stratos.messaging.event.health.stat.MemberFaultEvent", memberFaultEventMessageMap);
- this.topologyEventReceiver = new TopologyEventReceiver();
- Thread thread = new Thread(topologyEventReceiver);
- thread.start();
- log.info("WSO2 CEP topology receiver thread started");
+
+ Thread topologyTopicSubscriberThread = new Thread(cepTopologyEventReceiver);
+ topologyTopicSubscriberThread.start();
//Ordinary scheduling
window.schedule();
-
+ if (log.isDebugEnabled()){
+ log.debug("Fault handling window processor initialized with [timeToKeep] " + timeToKeep +
+ ", [memberIdAttrName] " + memberIdAttrName + ", [memberIdAttrIndex] " + memberIdAttrIndex +
+ ", [distributed-enabled] " + this.siddhiContext.isDistributedProcessingEnabled());
+ }
}
@Override
public void schedule() {
- eventRemoverScheduler.schedule(this, timeToKeep, TimeUnit.MILLISECONDS);
+ faultHandleScheduler.schedule(this, timeToKeep, TimeUnit.MILLISECONDS);
}
@Override
public void scheduleNow() {
- eventRemoverScheduler.schedule(this, 0, TimeUnit.MILLISECONDS);
+ faultHandleScheduler.schedule(this, 0, TimeUnit.MILLISECONDS);
}
@Override
public void setScheduledExecutorService(ScheduledExecutorService scheduledExecutorService) {
- this.eventRemoverScheduler = scheduledExecutorService;
+ this.faultHandleScheduler = scheduledExecutorService;
}
@Override
@@ -250,7 +312,12 @@ public class FaultHandlingWindowProcessor extends WindowProcessor implements Run
@Override
public void destroy(){
- this.topologyEventReceiver.terminate();
+ // terminate topology listener thread
+ cepTopologyEventReceiver.terminate();
window = null;
}
+
+ public ConcurrentHashMap<String, Long> getMemberTimeStampMap() {
+ return memberTimeStampMap;
+ }
}
[10/50] [abbrv] git commit: converting non-critical info logs to
debug in TopologyLockHierarchy class
Posted by im...@apache.org.
converting non-critical info logs to debug in TopologyLockHierarchy class
Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/0300d17d
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/0300d17d
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/0300d17d
Branch: refs/heads/docker-grouping-merge
Commit: 0300d17d905f5e1629b76e2805317a1a7016dee3
Parents: 07c5109
Author: Isuru Haththotuwa <is...@apache.org>
Authored: Mon Oct 27 14:19:28 2014 +0530
Committer: Isuru Haththotuwa <is...@apache.org>
Committed: Mon Oct 27 14:19:41 2014 +0530
----------------------------------------------------------------------
.../topology/locking/TopologyLockHierarchy.java | 24 +++++++++++++++-----
1 file changed, 18 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/stratos/blob/0300d17d/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/locking/TopologyLockHierarchy.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/locking/TopologyLockHierarchy.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/locking/TopologyLockHierarchy.java
index 015fa2e..bb6b8fa 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/locking/TopologyLockHierarchy.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/locking/TopologyLockHierarchy.java
@@ -82,7 +82,9 @@ public class TopologyLockHierarchy {
}
}
} else {
- log.warn("Topology Lock for Application " + appId + " already exists");
+ if (log.isDebugEnabled()) {
+ log.debug("Topology Lock for Application " + appId + " already exists");
+ }
}
}
@@ -100,7 +102,9 @@ public class TopologyLockHierarchy {
}
}
} else {
- log.warn("Topology Lock for Service " + serviceName + " already exists");
+ if (log.isDebugEnabled()) {
+ log.debug("Topology Lock for Service " + serviceName + " already exists");
+ }
}
}
@@ -118,7 +122,9 @@ public class TopologyLockHierarchy {
}
}
} else {
- log.warn("Topology Lock for Cluster " + clusterId + " already exists");
+ if (log.isDebugEnabled()) {
+ log.debug("Topology Lock for Cluster " + clusterId + " already exists");
+ }
}
}
@@ -130,7 +136,9 @@ public class TopologyLockHierarchy {
if (applicationIdToTopologyLockMap.remove(appId) != null) {
log.info("Removed lock for Application " + appId);
} else {
- log.info("Lock already removed for Application " + appId);
+ if (log.isDebugEnabled()) {
+ log.debug("Lock already removed for Application " + appId);
+ }
}
}
@@ -138,7 +146,9 @@ public class TopologyLockHierarchy {
if (serviceNameToTopologyLockMap.remove(serviceName) != null) {
log.info("Removed lock for Service " + serviceName);
} else {
- log.info("Lock already removed for Service " + serviceName);
+ if (log.isDebugEnabled()) {
+ log.debug("Lock already removed for Service " + serviceName);
+ }
}
}
@@ -146,7 +156,9 @@ public class TopologyLockHierarchy {
if (clusterIdToTopologyLockMap.remove(clusterId) != null) {
log.info("Removed lock for Cluster " + clusterId);
} else {
- log.info("Lock already removed for Cluster " + clusterId);
+ if (log.isDebugEnabled()) {
+ log.debug("Lock already removed for Cluster " + clusterId);
+ }
}
}
[31/50] [abbrv] git commit: adding flag upon member fault and
refactoring statusChecker
Posted by im...@apache.org.
adding flag upon member fault and refactoring statusChecker
Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/1b7064da
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/1b7064da
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/1b7064da
Branch: refs/heads/docker-grouping-merge
Commit: 1b7064daee10880ddfbf5c1a848c0fd0f108fdc0
Parents: 01315a7
Author: reka <rt...@gmail.com>
Authored: Wed Oct 29 11:33:06 2014 +0530
Committer: reka <rt...@gmail.com>
Committed: Wed Oct 29 11:33:06 2014 +0530
----------------------------------------------------------------------
.../grouping/topic/StatusEventPublisher.java | 86 ++++-----
.../AutoscalerHealthStatEventReceiver.java | 6 +-
.../AutoscalerTopologyEventReceiver.java | 15 +-
.../monitor/AbstractClusterMonitor.java | 13 +-
.../monitor/application/ApplicationMonitor.java | 4 +-
.../monitor/cluster/ClusterMonitor.java | 3 +-
.../autoscaler/monitor/group/GroupMonitor.java | 4 +-
.../status/checker/StatusChecker.java | 188 +++++++++----------
8 files changed, 155 insertions(+), 164 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/stratos/blob/1b7064da/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/StatusEventPublisher.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/StatusEventPublisher.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/StatusEventPublisher.java
index 5b09a21..7bbe8ce 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/StatusEventPublisher.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/StatusEventPublisher.java
@@ -19,18 +19,16 @@ public class StatusEventPublisher {
private static final Log log = LogFactory.getLog(StatusEventPublisher.class);
public static void sendClusterActivatedEvent(String appId, String serviceName, String clusterId) {
-
- if (log.isInfoEnabled()) {
- log.info("Publishing Cluster activated event for [application]: " + appId +
- " [cluster]: " + clusterId);
- }
-
try {
TopologyManager.acquireReadLockForCluster(serviceName, clusterId);
Service service = TopologyManager.getTopology().getService(serviceName);
if (service != null) {
Cluster cluster = service.getCluster(clusterId);
if (cluster.isStateTransitionValid(ClusterStatus.Active)) {
+ if (log.isInfoEnabled()) {
+ log.info("Publishing Cluster activated event for [application]: " + appId +
+ " [cluster]: " + clusterId);
+ }
AppStatusClusterActivatedEvent clusterActivatedEvent =
new AppStatusClusterActivatedEvent(appId, serviceName, clusterId);
@@ -45,18 +43,16 @@ public class StatusEventPublisher {
}
public static void sendClusterInActivateEvent(String appId, String serviceName, String clusterId) {
-
- if (log.isInfoEnabled()) {
- log.info("Publishing Cluster in-activate event for [application]: " + appId +
- " [cluster]: " + clusterId);
- }
-
try {
TopologyManager.acquireReadLockForCluster(serviceName, clusterId);
Service service = TopologyManager.getTopology().getService(serviceName);
if (service != null) {
Cluster cluster = service.getCluster(clusterId);
if (cluster.isStateTransitionValid(ClusterStatus.Inactive)) {
+ if (log.isInfoEnabled()) {
+ log.info("Publishing Cluster in-activate event for [application]: " + appId +
+ " [cluster]: " + clusterId);
+ }
AppStatusClusterInactivateEvent clusterInActivateEvent =
new AppStatusClusterInactivateEvent(appId, serviceName, clusterId);
@@ -73,16 +69,16 @@ public class StatusEventPublisher {
public static void sendClusterTerminatingEvent(String appId, String serviceName, String clusterId) {
- if (log.isInfoEnabled()) {
- log.info("Publishing Cluster Terminating event for [application]: " + appId +
- " [cluster]: " + clusterId);
- }
try {
TopologyManager.acquireReadLockForCluster(serviceName, clusterId);
Service service = TopologyManager.getTopology().getService(serviceName);
if (service != null) {
Cluster cluster = service.getCluster(clusterId);
if (cluster.isStateTransitionValid(ClusterStatus.Terminating)) {
+ if (log.isInfoEnabled()) {
+ log.info("Publishing Cluster Terminating event for [application]: " + appId +
+ " [cluster]: " + clusterId);
+ }
AppStatusClusterTerminatingEvent appStatusClusterTerminatingEvent =
new AppStatusClusterTerminatingEvent(appId, serviceName, clusterId);
@@ -99,17 +95,16 @@ public class StatusEventPublisher {
}
public static void sendClusterTerminatedEvent(String appId, String serviceName, String clusterId) {
-
- if (log.isInfoEnabled()) {
- log.info("Publishing Cluster terminated event for [application]: " + appId +
- " [cluster]: " + clusterId);
- }
try {
TopologyManager.acquireReadLockForCluster(serviceName, clusterId);
Service service = TopologyManager.getTopology().getService(serviceName);
if (service != null) {
Cluster cluster = service.getCluster(clusterId);
if (cluster.isStateTransitionValid(ClusterStatus.Terminated)) {
+ if (log.isInfoEnabled()) {
+ log.info("Publishing Cluster terminated event for [application]: " + appId +
+ " [cluster]: " + clusterId);
+ }
AppStatusClusterTerminatedEvent appStatusClusterTerminatedEvent =
new AppStatusClusterTerminatedEvent(appId, serviceName, clusterId);
@@ -125,18 +120,16 @@ public class StatusEventPublisher {
}
public static void sendGroupActivatedEvent(String appId, String groupId) {
-
- if (log.isInfoEnabled()) {
- log.info("Publishing Group activated event for [application]: " + appId +
- " [group]: " + groupId);
- }
-
try {
TopologyManager.acquireReadLockForApplication(appId);
Application application = TopologyManager.getTopology().getApplication(appId);
if (application != null) {
Group group = application.getGroupRecursively(groupId);
if (group.isStateTransitionValid(GroupStatus.Active)) {
+ if (log.isInfoEnabled()) {
+ log.info("Publishing Group activated event for [application]: " + appId +
+ " [group]: " + groupId);
+ }
AppStatusGroupActivatedEvent groupActivatedEvent =
new AppStatusGroupActivatedEvent(appId, groupId);
@@ -151,17 +144,16 @@ public class StatusEventPublisher {
}
public static void sendGroupInActivateEvent(String appId, String groupId) {
-
- if (log.isInfoEnabled()) {
- log.info("Publishing Group in-activate event for [application]: " + appId +
- " [group]: " + groupId);
- }
try {
TopologyManager.acquireReadLockForApplication(appId);
Application application = TopologyManager.getTopology().getApplication(appId);
if (application != null) {
Group group = application.getGroupRecursively(groupId);
if (group.isStateTransitionValid(GroupStatus.Inactive)) {
+ if (log.isInfoEnabled()) {
+ log.info("Publishing Group in-activate event for [application]: " + appId +
+ " [group]: " + groupId);
+ }
AppStatusGroupInactivateEvent appStatusGroupInactivateEvent = new
AppStatusGroupInactivateEvent(appId, groupId);
@@ -176,17 +168,16 @@ public class StatusEventPublisher {
}
public static void sendGroupTerminatingEvent(String appId, String groupId) {
-
- if (log.isInfoEnabled()) {
- log.info("Publishing Group terminating event for [application]: " + appId +
- " [group]: " + groupId);
- }
try {
TopologyManager.acquireReadLockForApplication(appId);
Application application = TopologyManager.getTopology().getApplication(appId);
if (application != null) {
Group group = application.getGroupRecursively(groupId);
if (group.isStateTransitionValid(GroupStatus.Terminating)) {
+ if (log.isInfoEnabled()) {
+ log.info("Publishing Group terminating event for [application]: " + appId +
+ " [group]: " + groupId);
+ }
AppStatusGroupTerminatingEvent groupInTerminatingEvent =
new AppStatusGroupTerminatingEvent(appId, groupId);
publishEvent(groupInTerminatingEvent);
@@ -227,16 +218,14 @@ public class StatusEventPublisher {
}
public static void sendApplicationActivatedEvent(String appId) {
-
- if (log.isInfoEnabled()) {
- log.info("Publishing Application activated event for [application]: " + appId);
- }
-
try {
TopologyManager.acquireReadLockForApplication(appId);
Application application = TopologyManager.getTopology().getApplication(appId);
if (application != null) {
if (application.isStateTransitionValid(ApplicationStatus.Active)) {
+ if (log.isInfoEnabled()) {
+ log.info("Publishing Application activated event for [application]: " + appId);
+ }
AppStatusApplicationActivatedEvent applicationActivatedEvent =
new AppStatusApplicationActivatedEvent(appId);
@@ -273,15 +262,14 @@ public class StatusEventPublisher {
}
public static void sendApplicationTerminatingEvent(String appId) {
- if (log.isInfoEnabled()) {
- log.info("Publishing Application terminated event for [application]: " + appId);
- }
-
try {
TopologyManager.acquireReadLockForApplication(appId);
Application application = TopologyManager.getTopology().getApplication(appId);
if (application != null) {
if (application.isStateTransitionValid(ApplicationStatus.Terminating)) {
+ if (log.isInfoEnabled()) {
+ log.info("Publishing Application terminated event for [application]: " + appId);
+ }
AppStatusApplicationTerminatingEvent applicationTerminatingEvent =
new AppStatusApplicationTerminatingEvent(appId);
publishEvent(applicationTerminatingEvent);
@@ -295,14 +283,14 @@ public class StatusEventPublisher {
}
public static void sendApplicationTerminatedEvent(String appId, Set<ClusterDataHolder> clusterData) {
- if (log.isInfoEnabled()) {
- log.info("Publishing Application terminated event for [application]: " + appId);
- }
try {
TopologyManager.acquireReadLockForApplication(appId);
Application application = TopologyManager.getTopology().getApplication(appId);
if (application != null) {
if (application.isStateTransitionValid(ApplicationStatus.Terminated)) {
+ if (log.isInfoEnabled()) {
+ log.info("Publishing Application terminated event for [application]: " + appId);
+ }
AppStatusApplicationTerminatedEvent applicationTerminatedEvent =
new AppStatusApplicationTerminatedEvent(appId, clusterData);
publishEvent(applicationTerminatedEvent);
http://git-wip-us.apache.org/repos/asf/stratos/blob/1b7064da/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/health/AutoscalerHealthStatEventReceiver.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/health/AutoscalerHealthStatEventReceiver.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/health/AutoscalerHealthStatEventReceiver.java
index 6986fbb..cf072f3 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/health/AutoscalerHealthStatEventReceiver.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/health/AutoscalerHealthStatEventReceiver.java
@@ -656,15 +656,15 @@ public class AutoscalerHealthStatEventReceiver implements Runnable {
}
return;
}
+ //Check the clusterStatus as part of the member fault event
+ StatusChecker.getInstance().onMemberFaultEvent(clusterId, partitionCtxt);
+
// terminate the faulty member
CloudControllerClient ccClient = CloudControllerClient.getInstance();
ccClient.terminate(memberId);
// remove from active member list
partitionCtxt.removeActiveMemberById(memberId);
- //Check the clusterStatus as part of the member fault event
- StatusChecker.getInstance().onMemberFaultEvent(clusterId, partitionCtxt);
-
if (log.isInfoEnabled()) {
log.info(String.format("Faulty member is terminated and removed from the active members list: [member] %s [partition] %s [cluster] %s ",
http://git-wip-us.apache.org/repos/asf/stratos/blob/1b7064da/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 1423385..7b411b8 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
@@ -155,7 +155,9 @@ public class AutoscalerTopologyEventReceiver implements Runnable {
(AbstractClusterMonitor) AutoscalerContext.getInstance().getMonitor(clusterId);
//changing the status in the monitor, will notify its parent monitor
- clusterMonitor.setStatus(ClusterStatus.Active);
+ if(clusterMonitor!= null) {
+ clusterMonitor.setStatus(ClusterStatus.Active);
+ }
}
});
@@ -190,7 +192,9 @@ public class AutoscalerTopologyEventReceiver implements Runnable {
(AbstractClusterMonitor) AutoscalerContext.getInstance().getMonitor(clusterId);
//changing the status in the monitor, will notify its parent monitor
- clusterMonitor.setStatus(ClusterStatus.Inactive);
+ if(clusterMonitor!= null) {
+ clusterMonitor.setStatus(ClusterStatus.Inactive);
+ }
}
});
@@ -237,9 +241,6 @@ public class AutoscalerTopologyEventReceiver implements Runnable {
if (clusterMonitor != null) {
clusterMonitor.setStatus(ClusterStatus.Terminated);
}
-
- //starting the status checker to decide on the status of it's parent
- //StatusChecker.getInstance().onClusterStatusChange(clusterId, appId);
}
});
@@ -337,7 +338,9 @@ public class AutoscalerTopologyEventReceiver implements Runnable {
String appId = applicationActivatedEvent.getAppId();
ApplicationMonitor appMonitor = AutoscalerContext.getInstance().getAppMonitor(appId);
- appMonitor.setStatus(ApplicationStatus.Active);
+ if(appMonitor != null) {
+ appMonitor.setStatus(ApplicationStatus.Active);
+ }
}
});
http://git-wip-us.apache.org/repos/asf/stratos/blob/1b7064da/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/AbstractClusterMonitor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/AbstractClusterMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/AbstractClusterMonitor.java
index 0a9d628..1461b6e 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/AbstractClusterMonitor.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/AbstractClusterMonitor.java
@@ -65,6 +65,8 @@ abstract public class AbstractClusterMonitor extends Monitor implements Runnable
protected String serviceId;
protected String appId;
+ protected boolean hasFaultyMember = false;
+
protected ClusterStatus status;
//protected ParentComponentMonitor parent;
@@ -228,7 +230,7 @@ abstract public class AbstractClusterMonitor extends Monitor implements Runnable
public void setStatus(ClusterStatus status) {
log.info(String.format("[Monitor] %s is notifying the parent" +
"on its state change from %s to %s", clusterId, this.status, status));
- if(this.status != status) {
+ //if(this.status != status) {
this.status = status;
/**
* notifying the parent monitor about the state change
@@ -241,7 +243,7 @@ abstract public class AbstractClusterMonitor extends Monitor implements Runnable
} else {
MonitorStatusEventBuilder.handleClusterStatusEvent(this.parent, this.status, this.clusterId);
}
- }
+ //}
}
@@ -260,4 +262,11 @@ abstract public class AbstractClusterMonitor extends Monitor implements Runnable
}
+ public boolean isHasFaultyMember() {
+ return hasFaultyMember;
+ }
+
+ public void setHasFaultyMember(boolean hasFaultyMember) {
+ this.hasFaultyMember = hasFaultyMember;
+ }
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/stratos/blob/1b7064da/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 966c8b2..a147b35 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
@@ -142,9 +142,9 @@ public class ApplicationMonitor extends ParentComponentMonitor {
public void setStatus(ApplicationStatus status) {
log.info(String.format("[ApplicationMonitor] %s " +
"state changes from %s to %s", id, this.status, status));
- if(this.status != status) {
+ //if(this.status != status) {
this.status = status;
- }
+ //}
}
@Override
http://git-wip-us.apache.org/repos/asf/stratos/blob/1b7064da/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 a089fc6..d67b4f4 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
@@ -74,7 +74,8 @@ public class ClusterMonitor extends AbstractClusterMonitor {
while (!isDestroyed()) {
try {
if ((this.status.getCode() <= ClusterStatus.Active.getCode()) ||
- (this.status == ClusterStatus.Inactive && !hasDependent)) {
+ (this.status == ClusterStatus.Inactive && !hasDependent) ||
+ this.hasFaultyMember) {
if (log.isDebugEnabled()) {
log.debug("Cluster monitor is running.. " + this.toString());
}
http://git-wip-us.apache.org/repos/asf/stratos/blob/1b7064da/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java
index ab3ef16..261f745 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java
@@ -140,7 +140,7 @@ public class GroupMonitor extends ParentComponentMonitor implements EventHandler
public void setStatus(GroupStatus status) {
log.info(String.format("[Monitor] %s is notifying the parent" +
"on its state change from %s to %s", id, this.status, status));
- if(this.status != status) {
+ //if(this.status != status) {
this.status = status;
//notifying the parent
if (status == GroupStatus.Inactive && !this.hasDependent) {
@@ -149,7 +149,7 @@ public class GroupMonitor extends ParentComponentMonitor implements EventHandler
} else {
MonitorStatusEventBuilder.handleGroupStatusEvent(this.parent, this.status, this.id);
}
- }
+ //}
}
}
http://git-wip-us.apache.org/repos/asf/stratos/blob/1b7064da/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java
index acf6d71..d2d8b44 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java
@@ -54,40 +54,48 @@ public class StatusChecker {
*
* @param clusterId id of the cluster
*/
- public void onMemberStatusChange(String clusterId) {
- ClusterMonitor monitor = (ClusterMonitor) AutoscalerContext.getInstance().getMonitor(clusterId);
- boolean clusterActive = false;
- if(monitor != null) {
- clusterActive = clusterActive(monitor);
+ public void onMemberStatusChange(final String clusterId) {
+ Runnable group = new Runnable() {
+ public void run() {
+ ClusterMonitor monitor = (ClusterMonitor) AutoscalerContext.getInstance().getMonitor(clusterId);
+ boolean clusterActive = false;
+ if (monitor != null) {
+ clusterActive = clusterActive(monitor);
- }
- log.info("Status checker running for [cluster] " + clusterId +
- " the status [clusterActive] " + clusterActive);
- // if active then notify upper layer
- if (clusterActive) {
- //send event to cluster status topic
- StatusEventPublisher.sendClusterActivatedEvent(monitor.getAppId(),
- monitor.getServiceId(), monitor.getClusterId());
- }
+ }
+ log.info("Status checker running for [cluster] " + clusterId +
+ " the status [clusterActive] " + clusterActive);
+ // if active then notify upper layer
+ if (clusterActive) {
+ //send event to cluster status topic
+ StatusEventPublisher.sendClusterActivatedEvent(monitor.getAppId(),
+ monitor.getServiceId(), monitor.getClusterId());
+ }
+ }
+ };
+ Thread groupThread = new Thread(group);
+ groupThread.start();
}
- public void onMemberTermination(String clusterId) {
- ClusterMonitor monitor = (ClusterMonitor) AutoscalerContext.getInstance().getMonitor(clusterId);
- boolean clusterMonitorHasMembers = clusterMonitorHasMembers(monitor);
- boolean clusterActive = clusterActive(monitor);
-
- try {
- TopologyManager.acquireReadLockForCluster(monitor.getServiceId(), monitor.getClusterId());
- Service service = TopologyManager.getTopology().getService(monitor.getServiceId());
- Cluster cluster;
- if(service != null) {
- cluster = service.getCluster(monitor.getClusterId());
- if(cluster != null) {
- if(!clusterMonitorHasMembers && cluster.getStatus() == ClusterStatus.Terminating) {
- StatusEventPublisher.sendClusterTerminatedEvent(monitor.getAppId(), monitor.getServiceId(),
- monitor.getClusterId());
- } else {
- log.info("Cluster has non terminated [members] and in the [status] "
+ public void onMemberTermination(final String clusterId) {
+ Runnable group = new Runnable() {
+ public void run() {
+ ClusterMonitor monitor = (ClusterMonitor) AutoscalerContext.getInstance().getMonitor(clusterId);
+ boolean clusterMonitorHasMembers = clusterMonitorHasMembers(monitor);
+ boolean clusterActive = clusterActive(monitor);
+
+ try {
+ TopologyManager.acquireReadLockForCluster(monitor.getServiceId(), monitor.getClusterId());
+ Service service = TopologyManager.getTopology().getService(monitor.getServiceId());
+ Cluster cluster;
+ if (service != null) {
+ cluster = service.getCluster(monitor.getClusterId());
+ if (cluster != null) {
+ if (!clusterMonitorHasMembers && cluster.getStatus() == ClusterStatus.Terminating) {
+ StatusEventPublisher.sendClusterTerminatedEvent(monitor.getAppId(), monitor.getServiceId(),
+ monitor.getClusterId());
+ } else {
+ log.info("Cluster has non terminated [members] and in the [status] "
+ cluster.getStatus().toString());
/*if(!clusterActive && !(cluster.getStatus() == ClusterStatus.Inactive ||
@@ -97,15 +105,19 @@ public class StatusChecker {
monitor.getServiceId(), clusterId);
}*/
+ }
+ }
}
- }
- }
- } finally {
- TopologyManager.releaseReadLockForCluster(monitor.getServiceId(), monitor.getClusterId());
+ } finally {
+ TopologyManager.releaseReadLockForCluster(monitor.getServiceId(), monitor.getClusterId());
- }
+ }
+ }
+ };
+ Thread groupThread = new Thread(group);
+ groupThread.start();
}
@@ -147,21 +159,30 @@ public class StatusChecker {
* @param partitionContext is to decide in which partition has less members while others have active members
*/
public void onMemberFaultEvent(final String clusterId, final PartitionContext partitionContext) {
- ClusterMonitor monitor = (ClusterMonitor) AutoscalerContext.getInstance().getMonitor(clusterId);
- boolean clusterInActive = getClusterInActive(monitor, partitionContext);
- String appId = monitor.getAppId();
- if (clusterInActive) {
- //TODO evaluate life cycle
- //send cluster In-Active event to cluster status topic
- StatusEventPublisher.sendClusterInActivateEvent(appId, monitor.getServiceId(), clusterId);
+ Runnable group = new Runnable() {
+ public void run() {
+ ClusterMonitor monitor = (ClusterMonitor) AutoscalerContext.getInstance().getMonitor(clusterId);
+ boolean clusterInActive = getClusterInActive(monitor, partitionContext);
+ String appId = monitor.getAppId();
+ if (clusterInActive) {
+ //if the monitor is dependent, temporarily pausing it
+ if(monitor.isDependent()) {
+ monitor.setHasFaultyMember(true);
+ }
+ //send cluster In-Active event to cluster status topic
+ StatusEventPublisher.sendClusterInActivateEvent(appId, monitor.getServiceId(), clusterId);
+
+ } else {
+ boolean clusterActive = clusterActive(monitor);
+ if (clusterActive) {
+ StatusEventPublisher.sendClusterActivatedEvent(appId, monitor.getServiceId(), clusterId);
+ }
+ }
- } else {
- boolean clusterActive = clusterActive(monitor);
- if (clusterActive) {
- //TODO evaluate life cycle
- //send clusterActive event to cluster status topic
}
- }
+ };
+ Thread groupThread = new Thread(group);
+ groupThread.start();
}
private boolean getClusterInActive(AbstractClusterMonitor monitor, PartitionContext partitionContext) {
@@ -195,7 +216,7 @@ public class StatusChecker {
try {
TopologyManager.acquireReadLockForApplication(appId);
ParentComponent component;
- if(groupId.equals(appId)) {
+ if (groupId.equals(appId)) {
//it is an application
component = TopologyManager.getTopology().
getApplication(appId);
@@ -244,29 +265,6 @@ public class StatusChecker {
log.info("cluster found: " + clusterFound);
if (clusterFound || groups.containsKey(id)) {
childFound = true;
- /*if (!clusterData.isEmpty() && !groups.isEmpty()) {
- if (log.isDebugEnabled()) {
- log.debug("group active found: " + clusterFound);
- }
-
- if (log.isDebugEnabled()) {
- log.debug("Active cluster" + clustersActive + " and group: " + groupActive);
- }
- groupActive = clustersActive == ClusterStatus.Active && groupsActive == GroupStatus.Active;
- } else if (!groups.isEmpty()) {
- groupsActive = getGroupStatus(groups);
- if (log.isDebugEnabled()) {
- log.info("group active found: " + clusterFound);
- }
- groupActive = groupsActive == GroupStatus.Active;
- } else if (!clusterData.isEmpty()) {
- clustersActive = getClusterStatus(clusterData);
- if (log.isDebugEnabled()) {
- log.debug("Active cluster" + clustersActive + " and group: " + groupActive);
- }
- groupActive = clustersActive == ClusterStatus.Active;
- } */
-
clusterStatus = getClusterStatus(clusterData);
groupStatus = getGroupStatus(groups);
@@ -286,10 +284,10 @@ public class StatusChecker {
} else if (groups.isEmpty() && clusterStatus == ClusterStatus.Inactive ||
clusterData.isEmpty() && groupStatus == GroupStatus.Inactive ||
groupStatus == GroupStatus.Inactive && clusterStatus == ClusterStatus.Inactive) {
- //send the in activation event
- if (parent instanceof Application) {
- //send application activated event
- log.warn("Application can't be in in-active : " + appId);
+ //send the in activation event
+ if (parent instanceof Application) {
+ //send application activated event
+ log.warn("Application can't be in in-active : " + appId);
//StatusEventPublisher.sendApplicationInactivatedEvent(appId);
} else if (parent instanceof Group) {
//send activation to the parent
@@ -299,13 +297,13 @@ public class StatusChecker {
} else if (groups.isEmpty() && clusterStatus == ClusterStatus.Terminated ||
clusterData.isEmpty() && groupStatus == GroupStatus.Terminated ||
groupStatus == GroupStatus.Terminated && clusterStatus == ClusterStatus.Terminated) {
- //send the terminated event
+ //send the terminated event
if (parent instanceof Application) {
//validating the life cycle
try {
TopologyManager.acquireReadLockForApplication(appId);
Application application = TopologyManager.getTopology().getApplication(appId);
- if(application.getStatus().equals(ApplicationStatus.Terminating)) {
+ if (application.getStatus().equals(ApplicationStatus.Terminating)) {
log.info("sending app terminated: " + appId);
StatusEventPublisher.sendApplicationTerminatedEvent(appId, parent.getClusterDataRecursively());
} else {
@@ -351,33 +349,25 @@ public class StatusChecker {
}
private GroupStatus getGroupStatus(Map<String, Group> groups) {
- boolean groupActiveStatus = false;
GroupStatus status = null;
boolean groupActive = false;
boolean groupTerminated = false;
for (Group group : groups.values()) {
- /*if (group.getTempStatus() == Status.Activated) {
- groupActiveStatus = true;
- } else {
- groupActiveStatus = false;
- break;
- }*/
-
if (group.getStatus() == GroupStatus.Active) {
groupActive = true;
groupTerminated = false;
- } else if(group.getStatus() == GroupStatus.Inactive){
+ } else if (group.getStatus() == GroupStatus.Inactive) {
status = GroupStatus.Inactive;
break;
- } else if(group.getStatus() == GroupStatus.Terminated) {
+ } else if (group.getStatus() == GroupStatus.Terminated) {
groupActive = false;
groupTerminated = true;
- } else if(group.getStatus() == GroupStatus.Created) {
+ } else if (group.getStatus() == GroupStatus.Created) {
groupActive = false;
groupTerminated = false;
status = GroupStatus.Created;
- } else if(group.getStatus() == GroupStatus.Terminating) {
+ } else if (group.getStatus() == GroupStatus.Terminating) {
groupActive = false;
groupTerminated = false;
status = GroupStatus.Terminating;
@@ -385,9 +375,9 @@ public class StatusChecker {
}
}
- if(groupActive) {
+ if (groupActive) {
status = GroupStatus.Active;
- } else if(groupTerminated) {
+ } else if (groupTerminated) {
status = GroupStatus.Terminated;
}
return status;
@@ -404,28 +394,28 @@ public class StatusChecker {
if (cluster.getStatus() == ClusterStatus.Active) {
clusterActive = true;
clusterTerminated = false;
- } else if(cluster.getStatus() == ClusterStatus.Inactive){
+ } else if (cluster.getStatus() == ClusterStatus.Inactive) {
status = ClusterStatus.Inactive;
clusterActive = false;
clusterTerminated = false;
break;
- } else if(cluster.getStatus() == ClusterStatus.Terminated) {
+ } else if (cluster.getStatus() == ClusterStatus.Terminated) {
clusterActive = false;
clusterTerminated = true;
- } else if(cluster.getStatus() == ClusterStatus.Terminating) {
+ } else if (cluster.getStatus() == ClusterStatus.Terminating) {
status = ClusterStatus.Terminating;
clusterActive = false;
clusterTerminated = false;
- } else if(cluster.getStatus() == ClusterStatus.Created) {
+ } else if (cluster.getStatus() == ClusterStatus.Created) {
status = ClusterStatus.Created;
clusterActive = false;
clusterTerminated = false;
}
}
- if(clusterActive) {
+ if (clusterActive) {
status = ClusterStatus.Active;
- } else if(clusterTerminated) {
+ } else if (clusterTerminated) {
status = ClusterStatus.Terminated;
}
return status;
[19/50] [abbrv] git commit: adding Cluster details to the SM's
Topology model
Posted by im...@apache.org.
adding Cluster details to the SM's Topology model
Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/c95377ff
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/c95377ff
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/c95377ff
Branch: refs/heads/docker-grouping-merge
Commit: c95377ff9b98b0138b17b52a696b5cedcc68fa2c
Parents: 7b4e326
Author: Isuru Haththotuwa <is...@apache.org>
Authored: Tue Oct 28 10:58:12 2014 +0530
Committer: Isuru Haththotuwa <is...@apache.org>
Committed: Tue Oct 28 10:58:12 2014 +0530
----------------------------------------------------------------------
.../receiver/StratosManagerTopologyEventReceiver.java | 14 ++++++++++++++
1 file changed, 14 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/stratos/blob/c95377ff/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/topology/receiver/StratosManagerTopologyEventReceiver.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/topology/receiver/StratosManagerTopologyEventReceiver.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/topology/receiver/StratosManagerTopologyEventReceiver.java
index 6e8552b..d4e90cc 100644
--- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/topology/receiver/StratosManagerTopologyEventReceiver.java
+++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/topology/receiver/StratosManagerTopologyEventReceiver.java
@@ -36,6 +36,8 @@ import org.apache.stratos.messaging.message.receiver.topology.TopologyEventRecei
import org.apache.stratos.messaging.message.receiver.topology.TopologyManager;
import org.wso2.carbon.context.PrivilegedCarbonContext;
+import java.util.List;
+
public class StratosManagerTopologyEventReceiver implements Runnable {
private static final Log log = LogFactory.getLog(StratosManagerTopologyEventReceiver.class);
@@ -347,6 +349,18 @@ public class StratosManagerTopologyEventReceiver implements Runnable {
} finally {
PrivilegedCarbonContext.endTenantFlow();
}
+
+ // add the clusters to the topology information model
+ List<Cluster> appClusters = appCreateEvent.getClusterList();
+ if (appClusters != null && !appClusters.isEmpty()) {
+ for (Cluster appCluster : appClusters) {
+ TopologyClusterInformationModel.getInstance().addCluster(appCluster);
+ }
+ } else {
+ log.warn("No clusters were found in the Application Created event for app id [ " +
+ appId + " ] to add to Cluster Information model");
+ }
+
} finally {
//TopologyManager.releaseReadLock();
TopologyManager.releaseReadLockForApplication(appCreateEvent.getApplication().getUniqueIdentifier());
[42/50] [abbrv] git commit: correcting an issue in notify child logic
Posted by im...@apache.org.
correcting an issue in notify child logic
Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/3c43277e
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/3c43277e
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/3c43277e
Branch: refs/heads/docker-grouping-merge
Commit: 3c43277e73f2ab096a65f944d90d9e101c8c4e14
Parents: e2994c4
Author: Isuru Haththotuwa <is...@apache.org>
Authored: Wed Oct 29 17:27:57 2014 +0530
Committer: Isuru Haththotuwa <is...@apache.org>
Committed: Wed Oct 29 17:27:57 2014 +0530
----------------------------------------------------------------------
.../monitor/ParentComponentMonitor.java | 24 --------------------
.../monitor/application/ApplicationMonitor.java | 5 ++++
.../autoscaler/monitor/group/GroupMonitor.java | 11 +++++++++
3 files changed, 16 insertions(+), 24 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/stratos/blob/3c43277e/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ParentComponentMonitor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ParentComponentMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ParentComponentMonitor.java
index 298516c..fa8f425 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ParentComponentMonitor.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ParentComponentMonitor.java
@@ -106,30 +106,6 @@ public abstract class ParentComponentMonitor extends Monitor {
}
}*/
- @Override
- public void onParentEvent(MonitorStatusEvent statusEvent) {
-
- if (statusEvent.getStatus() == GroupStatus.Terminating || statusEvent.getStatus() ==
- ApplicationStatus.Terminating) {
-
- // parent monitor is in Terminating state. send Terminating event for all monitors
- for (Monitor childMonitor : this.getAliasToActiveMonitorsMap().values()) {
- if (childMonitor.hasActiveMonitors()) {
- // this is a Group Monitor, send Group Terminating
- StatusEventPublisher.sendGroupTerminatingEvent(appId, childMonitor.getId());
- markMonitorAsInactive(childMonitor.getId());
- } else {
- // this is a Cluster Monitor, send Cluster Terminating
- StatusEventPublisher.sendClusterTerminatingEvent(appId,
- ((AbstractClusterMonitor) childMonitor).getServiceId(),
- ((AbstractClusterMonitor) childMonitor).getClusterId());
- markMonitorAsInactive(((AbstractClusterMonitor) childMonitor).getClusterId());
- }
-
- }
- }
- }
-
// move to inactive monitors list to use in the Terminated event
private synchronized void markMonitorAsInactive (String monitorKey) {
http://git-wip-us.apache.org/repos/asf/stratos/blob/3c43277e/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 dc53403..1ec7399 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
@@ -180,6 +180,11 @@ public class ApplicationMonitor extends ParentComponentMonitor {
}
@Override
+ public void onParentEvent(MonitorStatusEvent statusEvent) {
+ // nothing to do
+ }
+
+ @Override
public void onEvent(MonitorTerminateAllEvent terminateAllEvent) {
}
http://git-wip-us.apache.org/repos/asf/stratos/blob/3c43277e/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java
index 64cc28c..9b9695a 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java
@@ -22,6 +22,7 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.stratos.autoscaler.exception.DependencyBuilderException;
import org.apache.stratos.autoscaler.exception.TopologyInConsistentException;
+import org.apache.stratos.autoscaler.grouping.topic.StatusEventPublisher;
import org.apache.stratos.autoscaler.monitor.EventHandler;
import org.apache.stratos.autoscaler.monitor.MonitorStatusEventBuilder;
import org.apache.stratos.autoscaler.monitor.ParentComponentMonitor;
@@ -30,6 +31,7 @@ import org.apache.stratos.autoscaler.monitor.events.MonitorScalingEvent;
import org.apache.stratos.autoscaler.monitor.events.MonitorStatusEvent;
import org.apache.stratos.autoscaler.monitor.events.MonitorTerminateAllEvent;
import org.apache.stratos.autoscaler.status.checker.StatusChecker;
+import org.apache.stratos.messaging.domain.topology.ApplicationStatus;
import org.apache.stratos.messaging.domain.topology.ClusterStatus;
import org.apache.stratos.messaging.domain.topology.Group;
import org.apache.stratos.messaging.domain.topology.GroupStatus;
@@ -89,6 +91,15 @@ public class GroupMonitor extends ParentComponentMonitor implements EventHandler
}
@Override
+ public void onParentEvent(MonitorStatusEvent statusEvent) {
+ // send the ClusterTerminating event
+ if (statusEvent.getStatus() == GroupStatus.Terminating || statusEvent.getStatus() ==
+ ApplicationStatus.Terminating) {
+ StatusEventPublisher.sendGroupTerminatingEvent(appId, id);
+ }
+ }
+
+ @Override
public void onEvent(MonitorTerminateAllEvent terminateAllEvent) {
this.terminateChildren = true;
[45/50] [abbrv] git commit: fixing a concurrent modification issue in
PartitionContext
Posted by im...@apache.org.
fixing a concurrent modification issue in PartitionContext
Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/5196529d
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/5196529d
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/5196529d
Branch: refs/heads/docker-grouping-merge
Commit: 5196529d41c0b56c3c362f5f547191e4ba237129
Parents: 08d6865
Author: Isuru Haththotuwa <is...@apache.org>
Authored: Wed Oct 29 18:22:26 2014 +0530
Committer: Isuru Haththotuwa <is...@apache.org>
Committed: Wed Oct 29 18:22:26 2014 +0530
----------------------------------------------------------------------
.../java/org/apache/stratos/autoscaler/PartitionContext.java | 6 +++---
.../stratos/autoscaler/monitor/AbstractClusterMonitor.java | 3 +--
.../apache/stratos/autoscaler/monitor/group/GroupMonitor.java | 3 +--
3 files changed, 5 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/stratos/blob/5196529d/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 613aa4f..d0886a3 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
@@ -88,9 +88,9 @@ public class PartitionContext implements Serializable{
this.setPartition(partition);
this.minimumMemberCount = partition.getPartitionMin();
this.partitionId = partition.getId();
- this.pendingMembers = new ArrayList<MemberContext>();
- this.activeMembers = new ArrayList<MemberContext>();
- this.terminationPendingMembers = new ArrayList<MemberContext>();
+ this.pendingMembers = new CopyOnWriteArrayList<MemberContext>();
+ this.activeMembers = new CopyOnWriteArrayList<MemberContext>();
+ this.terminationPendingMembers = new CopyOnWriteArrayList<MemberContext>();
this.obsoletedMembers = new CopyOnWriteArrayList<String>();
memberStatsContexts = new ConcurrentHashMap<String, MemberStatsContext>();
http://git-wip-us.apache.org/repos/asf/stratos/blob/5196529d/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/AbstractClusterMonitor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/AbstractClusterMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/AbstractClusterMonitor.java
index da4cba8..fb23985 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/AbstractClusterMonitor.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/AbstractClusterMonitor.java
@@ -228,8 +228,7 @@ abstract public class AbstractClusterMonitor extends Monitor implements Runnable
}
public void setStatus(ClusterStatus status) {
- log.info(String.format("[Monitor] %s is notifying the parent" +
- "on its state change from %s to %s", clusterId, this.status, status));
+
//if(this.status != status) {
this.status = status;
/**
http://git-wip-us.apache.org/repos/asf/stratos/blob/5196529d/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java
index 0f213a9..b42e840 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java
@@ -144,8 +144,7 @@ public class GroupMonitor extends ParentComponentMonitor implements EventHandler
* @param status
*/
public void setStatus(GroupStatus status) {
- log.info(String.format("[Monitor] %s is notifying the parent" +
- "on its state change from %s to %s", id, this.status, status));
+
//if(this.status != status) {
this.status = status;
//notifying the parent
[23/50] [abbrv] git commit: removing created headers from java files
Posted by im...@apache.org.
removing created headers from java files
Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/4bca87ee
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/4bca87ee
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/4bca87ee
Branch: refs/heads/docker-grouping-merge
Commit: 4bca87eee4bb9b0b966aaf3813acaeaeeebc0557
Parents: 2ae7e2b
Author: Udara Liyanage <ud...@wso2.com>
Authored: Tue Oct 28 10:42:51 2014 +0530
Committer: Udara Liyanage <ud...@wso2.com>
Committed: Tue Oct 28 13:22:26 2014 +0530
----------------------------------------------------------------------
.../autoscaler/grouping/dependency/context/GroupContext.java | 3 ---
.../apache/stratos/autoscaler/monitor/events/MonitorEvent.java | 3 ---
.../application/status/AppStatusGroupActivatedEventListener.java | 3 ---
.../application/status/AppStatusGroupInactivateEventListener.java | 3 ---
.../status/AppStatusGroupTerminatingEventListener.java | 3 ---
.../listener/topology/ClusterActivatedEventListener.java | 3 ---
.../listener/topology/ClusterInActivateEventListener.java | 3 ---
.../status/AppStatusApplicationActivatedMessageProcessor.java | 3 ---
8 files changed, 24 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/stratos/blob/4bca87ee/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/context/GroupContext.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/context/GroupContext.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/context/GroupContext.java
index 0e65d2b..408272a 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/context/GroupContext.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/context/GroupContext.java
@@ -18,9 +18,6 @@
*/
package org.apache.stratos.autoscaler.grouping.dependency.context;
-/**
- * Created by reka on 10/1/14.
- */
public class GroupContext extends ApplicationContext {
public GroupContext(String id, boolean killDependent) {
super(id ,killDependent);
http://git-wip-us.apache.org/repos/asf/stratos/blob/4bca87ee/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/MonitorEvent.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/MonitorEvent.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/MonitorEvent.java
index a733a0e..5231799 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/MonitorEvent.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/MonitorEvent.java
@@ -18,9 +18,6 @@
*/
package org.apache.stratos.autoscaler.monitor.events;
-/**
- * Created by reka on 10/20/14.
- */
public abstract class MonitorEvent {
protected String id;
http://git-wip-us.apache.org/repos/asf/stratos/blob/4bca87ee/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusGroupActivatedEventListener.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusGroupActivatedEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusGroupActivatedEventListener.java
index 75fe2c9..e6381e3 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusGroupActivatedEventListener.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusGroupActivatedEventListener.java
@@ -20,8 +20,5 @@ package org.apache.stratos.messaging.listener.application.status;
import org.apache.stratos.messaging.listener.EventListener;
-/**
- * Created by reka on 9/22/14.
- */
public abstract class AppStatusGroupActivatedEventListener extends EventListener {
}
http://git-wip-us.apache.org/repos/asf/stratos/blob/4bca87ee/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusGroupInactivateEventListener.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusGroupInactivateEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusGroupInactivateEventListener.java
index 5c88fae..0873a70 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusGroupInactivateEventListener.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusGroupInactivateEventListener.java
@@ -20,8 +20,5 @@ package org.apache.stratos.messaging.listener.application.status;
import org.apache.stratos.messaging.listener.EventListener;
-/**
- * Created by reka on 9/22/14.
- */
public abstract class AppStatusGroupInactivateEventListener extends EventListener {
}
http://git-wip-us.apache.org/repos/asf/stratos/blob/4bca87ee/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusGroupTerminatingEventListener.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusGroupTerminatingEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusGroupTerminatingEventListener.java
index fbd7fcc..8d56555 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusGroupTerminatingEventListener.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusGroupTerminatingEventListener.java
@@ -20,8 +20,5 @@ package org.apache.stratos.messaging.listener.application.status;
import org.apache.stratos.messaging.listener.EventListener;
-/**
- * Created by reka on 9/22/14.
- */
public abstract class AppStatusGroupTerminatingEventListener extends EventListener {
}
http://git-wip-us.apache.org/repos/asf/stratos/blob/4bca87ee/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/ClusterActivatedEventListener.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/ClusterActivatedEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/ClusterActivatedEventListener.java
index 9514541..00efcfd 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/ClusterActivatedEventListener.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/ClusterActivatedEventListener.java
@@ -20,8 +20,5 @@ package org.apache.stratos.messaging.listener.topology;
import org.apache.stratos.messaging.listener.EventListener;
-/**
- * Created by reka on 9/17/14.
- */
public abstract class ClusterActivatedEventListener extends EventListener {
}
http://git-wip-us.apache.org/repos/asf/stratos/blob/4bca87ee/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/ClusterInActivateEventListener.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/ClusterInActivateEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/ClusterInActivateEventListener.java
index 03a4768..551f1b8 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/ClusterInActivateEventListener.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/ClusterInActivateEventListener.java
@@ -20,8 +20,5 @@ package org.apache.stratos.messaging.listener.topology;
import org.apache.stratos.messaging.listener.EventListener;
-/**
- * Created by reka on 9/17/14.
- */
public abstract class ClusterInActivateEventListener extends EventListener {
}
http://git-wip-us.apache.org/repos/asf/stratos/blob/4bca87ee/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusApplicationActivatedMessageProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusApplicationActivatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusApplicationActivatedMessageProcessor.java
index a505624..8b88724 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusApplicationActivatedMessageProcessor.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusApplicationActivatedMessageProcessor.java
@@ -24,9 +24,6 @@ import org.apache.stratos.messaging.event.application.status.AppStatusApplicatio
import org.apache.stratos.messaging.message.processor.MessageProcessor;
import org.apache.stratos.messaging.util.Util;
-/**
- * Created by reka on 9/25/14.
- */
public class AppStatusApplicationActivatedMessageProcessor extends MessageProcessor {
private static final Log log =
LogFactory.getLog(AppStatusApplicationActivatedMessageProcessor.class);
[33/50] [abbrv] git commit: adding correct log message and refactoring
Posted by im...@apache.org.
adding correct log message and refactoring
Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/ed1af704
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/ed1af704
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/ed1af704
Branch: refs/heads/docker-grouping-merge
Commit: ed1af704a37b430f1926a8a39a837935673f2c8f
Parents: d474b13
Author: reka <rt...@gmail.com>
Authored: Wed Oct 29 14:23:54 2014 +0530
Committer: reka <rt...@gmail.com>
Committed: Wed Oct 29 14:24:15 2014 +0530
----------------------------------------------------------------------
.../topology/AutoscalerTopologyEventReceiver.java | 4 ++--
.../monitor/application/ApplicationMonitor.java | 2 ++
.../autoscaler/monitor/cluster/ClusterMonitor.java | 2 +-
.../stratos/cloud/controller/iaases/AWSEC2Iaas.java | 4 ++--
.../cloud/controller/topology/TopologyBuilder.java | 12 ++++++------
.../processor/topology/GroupInActivateProcessor.java | 2 +-
6 files changed, 14 insertions(+), 12 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/stratos/blob/ed1af704/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 608100a..ac8b6c9 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
@@ -203,7 +203,7 @@ public class AutoscalerTopologyEventReceiver implements Runnable {
@Override
protected void onEvent(Event event) {
- log.info("[ClusterInActivateEvent] Received: " + event.getClass());
+ log.info("[ClusterTerminatingEvent] Received: " + event.getClass());
ClusterTerminatingEvent clusterTerminatingEvent = (ClusterTerminatingEvent) event;
String appId = clusterTerminatingEvent.getAppId();
@@ -229,7 +229,7 @@ public class AutoscalerTopologyEventReceiver implements Runnable {
@Override
protected void onEvent(Event event) {
- log.info("[ClusterInActivateEvent] Received: " + event.getClass());
+ log.info("[ClusterTerminatedEvent] Received: " + event.getClass());
ClusterTerminatedEvent clusterTerminatedEvent = (ClusterTerminatedEvent) event;
String appId = clusterTerminatedEvent.getAppId();
http://git-wip-us.apache.org/repos/asf/stratos/blob/ed1af704/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 a147b35..f6a4d18 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
@@ -25,6 +25,7 @@ import org.apache.stratos.autoscaler.exception.TopologyInConsistentException;
import org.apache.stratos.autoscaler.grouping.dependency.context.ApplicationContext;
import org.apache.stratos.autoscaler.monitor.AbstractClusterMonitor;
import org.apache.stratos.autoscaler.monitor.Monitor;
+import org.apache.stratos.autoscaler.monitor.MonitorStatusEventBuilder;
import org.apache.stratos.autoscaler.monitor.ParentComponentMonitor;
import org.apache.stratos.autoscaler.monitor.events.MonitorScalingEvent;
import org.apache.stratos.autoscaler.monitor.events.MonitorStatusEvent;
@@ -144,6 +145,7 @@ public class ApplicationMonitor extends ParentComponentMonitor {
"state changes from %s to %s", id, this.status, status));
//if(this.status != status) {
this.status = status;
+
//}
}
http://git-wip-us.apache.org/repos/asf/stratos/blob/ed1af704/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 69dac23..b47fb15 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
@@ -77,7 +77,7 @@ public class ClusterMonitor extends AbstractClusterMonitor {
try {
if ((this.status.getCode() <= ClusterStatus.Active.getCode()) ||
(this.status == ClusterStatus.Inactive && !hasDependent) ||
- this.hasFaultyMember) {
+ !this.hasFaultyMember) {
if (log.isDebugEnabled()) {
log.debug("Cluster monitor is running.. " + this.toString());
}
http://git-wip-us.apache.org/repos/asf/stratos/blob/ed1af704/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/AWSEC2Iaas.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/AWSEC2Iaas.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/AWSEC2Iaas.java
index a637edc..3e46e52 100644
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/AWSEC2Iaas.java
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/AWSEC2Iaas.java
@@ -99,7 +99,7 @@ public class AWSEC2Iaas extends Iaas {
templateBuilder.locationId(iaasInfo.getType());
}
- if(iaasInfo.getProperty(CloudControllerConstants.AVAILABILITY_ZONE) != null) {
+ /*if(iaasInfo.getProperty(CloudControllerConstants.AVAILABILITY_ZONE) != null) {
Set<? extends Location> locations = iaasInfo.getComputeService().listAssignableLocations();
for(Location location : locations) {
if(location.getScope().toString().equalsIgnoreCase(CloudControllerConstants.ZONE_ELEMENT) &&
@@ -110,7 +110,7 @@ public class AWSEC2Iaas extends Iaas {
break;
}
}
- }
+ }*/
if (iaasInfo.getProperty(CloudControllerConstants.INSTANCE_TYPE) != null) {
// set instance type eg: m1.large
http://git-wip-us.apache.org/repos/asf/stratos/blob/ed1af704/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java
index fac6671..b6e3470 100644
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java
@@ -665,7 +665,7 @@ public class TopologyBuilder {
//cluster.setStatus(Status.Activated);
cluster.setStatus(ClusterStatus.Active);
- log.info("Cluster activated adding status started");
+ log.info("Cluster activated adding status started for" + cluster.getClusterId());
TopologyManager.updateTopology(topology);
} finally {
@@ -703,7 +703,7 @@ public class TopologyBuilder {
//cluster.setStatus(Status.Activated);
cluster.setStatus(ClusterStatus.Inactive);
- log.info("Cluster in-active adding status started");
+ log.info("Cluster in-active adding status started for " + cluster.getClusterId());
TopologyManager.updateTopology(topology);
} finally {
@@ -737,7 +737,7 @@ public class TopologyBuilder {
try {
TopologyManager.acquireWriteLock();
group.setStatus(GroupStatus.Active);
- log.info("Group activated adding status started");
+ log.info("Group activated adding status started for " + group.getUniqueIdentifier());
TopologyManager.updateTopology(topology);
} finally {
@@ -985,7 +985,7 @@ public class TopologyBuilder {
try {
TopologyManager.acquireWriteLock();
group.setStatus(GroupStatus.Inactive);
- log.info("Group in-active adding status started");
+ log.info("Group in-active adding status started for" + group.getUniqueIdentifier());
TopologyManager.updateTopology(topology);
} finally {
@@ -1020,7 +1020,7 @@ public class TopologyBuilder {
try {
TopologyManager.acquireWriteLock();
group.setStatus(GroupStatus.Terminated);
- log.info("Group activated adding status started");
+ log.info("Group activated adding status started for" + group.getUniqueIdentifier());
TopologyManager.updateTopology(topology);
} finally {
@@ -1054,7 +1054,7 @@ public class TopologyBuilder {
try {
TopologyManager.acquireWriteLock();
group.setStatus(GroupStatus.Terminating);
- log.info("Group activated adding status started");
+ log.info("Group activated adding status started for " + group.getUniqueIdentifier());
TopologyManager.updateTopology(topology);
} finally {
http://git-wip-us.apache.org/repos/asf/stratos/blob/ed1af704/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupInActivateProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupInActivateProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupInActivateProcessor.java
index 094196b..d5dcd65 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupInActivateProcessor.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupInActivateProcessor.java
@@ -95,7 +95,7 @@ public class GroupInActivateProcessor extends MessageProcessor {
} else {
group.setStatus(GroupStatus.Inactive);
if (log.isInfoEnabled()) {
- log.info(String.format("Group updated as activated : %s",
+ log.info(String.format("Group updated as in-activated : %s",
group.getUniqueIdentifier()));
}
}
[04/50] [abbrv] rename application status events,
listeners and processors with prefix appstatus
Posted by im...@apache.org.
http://git-wip-us.apache.org/repos/asf/stratos/blob/4e4ba5b3/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/GroupInactivateEvent.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/GroupInactivateEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/GroupInactivateEvent.java
deleted file mode 100644
index e816480..0000000
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/GroupInactivateEvent.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.stratos.messaging.event.application.status;
-
-/**
- * This event is fired by cartridge agent when it has started the server and
- * applications are ready to serve the incoming requests.
- */
-public class GroupInactivateEvent extends StatusEvent {
- private static final long serialVersionUID = 2625412714611885089L;
-
- private String groupId;
- private String appId;
-
- public GroupInactivateEvent(String appId, String groupId) {
- this.appId = appId;
- this.groupId = groupId;
- }
-
- public String getGroupId() {
- return this.groupId;
- }
-
- public String getAppId() {
- return appId;
- }
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/4e4ba5b3/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/GroupMaintenanceModeEvent.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/GroupMaintenanceModeEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/GroupMaintenanceModeEvent.java
deleted file mode 100644
index 5e6534d..0000000
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/GroupMaintenanceModeEvent.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.stratos.messaging.event.application.status;
-
-/**
- * This event will be fired upon the instability of group detection by autoscaler.
- */
-public class GroupMaintenanceModeEvent extends StatusEvent {
- private String groupId;
- private String appId;
-
- public GroupMaintenanceModeEvent(String appId, String groupId) {
- this.appId = appId;
- this.groupId = groupId;
- }
-
- public String getGroupId(String groupId) {
- return this.groupId;
- }
-
- public String getAppId() {
- return appId;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/4e4ba5b3/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/GroupReadyToShutdownEvent.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/GroupReadyToShutdownEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/GroupReadyToShutdownEvent.java
deleted file mode 100644
index d1ed012..0000000
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/GroupReadyToShutdownEvent.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.stratos.messaging.event.application.status;
-
-/**
- * This event is fired by autoscaler before actually terminate a group.
- */
-public class GroupReadyToShutdownEvent extends StatusEvent {
- private String groupId;
- private String appId;
-
- public GroupReadyToShutdownEvent(String appId, String groupId) {
- this.appId = appId;
- this.groupId = groupId;
- }
-
- public String getGroupId(String groupId) {
- return this.groupId;
- }
-
- public String getAppId() {
- return appId;
- }
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/4e4ba5b3/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusApplicationActivatedEventListener.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusApplicationActivatedEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusApplicationActivatedEventListener.java
new file mode 100644
index 0000000..4dfc8b5
--- /dev/null
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusApplicationActivatedEventListener.java
@@ -0,0 +1,27 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.stratos.messaging.listener.application.status;
+
+import org.apache.stratos.messaging.listener.EventListener;
+
+/**
+ * This listener will get triggered upon the application activated event.
+ */
+public abstract class AppStatusApplicationActivatedEventListener extends EventListener {
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/4e4ba5b3/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusApplicationCreatedEventListener.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusApplicationCreatedEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusApplicationCreatedEventListener.java
new file mode 100644
index 0000000..79a7d21
--- /dev/null
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusApplicationCreatedEventListener.java
@@ -0,0 +1,27 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.stratos.messaging.listener.application.status;
+
+import org.apache.stratos.messaging.listener.EventListener;
+
+/**
+ * This listener will get triggered upon the application created event.
+ */
+public abstract class AppStatusApplicationCreatedEventListener extends EventListener {
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/4e4ba5b3/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusApplicationInactivatedEventListener.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusApplicationInactivatedEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusApplicationInactivatedEventListener.java
new file mode 100644
index 0000000..c2a356d
--- /dev/null
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusApplicationInactivatedEventListener.java
@@ -0,0 +1,27 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.stratos.messaging.listener.application.status;
+
+import org.apache.stratos.messaging.listener.EventListener;
+
+/**
+ * This listener will get triggered upon the application inactivated event.
+ */
+public abstract class AppStatusApplicationInactivatedEventListener extends EventListener {
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/4e4ba5b3/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusApplicationTerminatedEventListener.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusApplicationTerminatedEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusApplicationTerminatedEventListener.java
new file mode 100644
index 0000000..ad1be52
--- /dev/null
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusApplicationTerminatedEventListener.java
@@ -0,0 +1,27 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.stratos.messaging.listener.application.status;
+
+import org.apache.stratos.messaging.listener.EventListener;
+
+/**
+ * This listener will get triggered upon the application terminated event.
+ */
+public abstract class AppStatusApplicationTerminatedEventListener extends EventListener {
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/4e4ba5b3/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusApplicationTerminatingEventListener.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusApplicationTerminatingEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusApplicationTerminatingEventListener.java
new file mode 100644
index 0000000..a454f16
--- /dev/null
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusApplicationTerminatingEventListener.java
@@ -0,0 +1,27 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.stratos.messaging.listener.application.status;
+
+import org.apache.stratos.messaging.listener.EventListener;
+
+/**
+ * This listener will get triggered upon the application terminating event.
+ */
+public abstract class AppStatusApplicationTerminatingEventListener extends EventListener {
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/4e4ba5b3/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusClusterActivatedEventListener.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusClusterActivatedEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusClusterActivatedEventListener.java
new file mode 100644
index 0000000..75da7b8
--- /dev/null
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusClusterActivatedEventListener.java
@@ -0,0 +1,24 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.stratos.messaging.listener.application.status;
+
+import org.apache.stratos.messaging.listener.EventListener;
+
+public abstract class AppStatusClusterActivatedEventListener extends EventListener{
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/4e4ba5b3/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusClusterInactivateEventListener.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusClusterInactivateEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusClusterInactivateEventListener.java
new file mode 100644
index 0000000..03da7f7
--- /dev/null
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusClusterInactivateEventListener.java
@@ -0,0 +1,24 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.stratos.messaging.listener.application.status;
+
+import org.apache.stratos.messaging.listener.EventListener;
+
+public abstract class AppStatusClusterInactivateEventListener extends EventListener{
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/4e4ba5b3/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusGroupActivatedEventListener.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusGroupActivatedEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusGroupActivatedEventListener.java
new file mode 100644
index 0000000..75fe2c9
--- /dev/null
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusGroupActivatedEventListener.java
@@ -0,0 +1,27 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.stratos.messaging.listener.application.status;
+
+import org.apache.stratos.messaging.listener.EventListener;
+
+/**
+ * Created by reka on 9/22/14.
+ */
+public abstract class AppStatusGroupActivatedEventListener extends EventListener {
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/4e4ba5b3/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusGroupInactivateEventListener.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusGroupInactivateEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusGroupInactivateEventListener.java
new file mode 100644
index 0000000..5c88fae
--- /dev/null
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusGroupInactivateEventListener.java
@@ -0,0 +1,27 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.stratos.messaging.listener.application.status;
+
+import org.apache.stratos.messaging.listener.EventListener;
+
+/**
+ * Created by reka on 9/22/14.
+ */
+public abstract class AppStatusGroupInactivateEventListener extends EventListener {
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/4e4ba5b3/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusGroupTerminatedEventListener.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusGroupTerminatedEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusGroupTerminatedEventListener.java
new file mode 100644
index 0000000..785abbd
--- /dev/null
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusGroupTerminatedEventListener.java
@@ -0,0 +1,24 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.stratos.messaging.listener.application.status;
+
+import org.apache.stratos.messaging.listener.EventListener;
+
+public abstract class AppStatusGroupTerminatedEventListener extends EventListener {
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/4e4ba5b3/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusGroupTerminatingEventListener.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusGroupTerminatingEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusGroupTerminatingEventListener.java
new file mode 100644
index 0000000..fbd7fcc
--- /dev/null
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusGroupTerminatingEventListener.java
@@ -0,0 +1,27 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.stratos.messaging.listener.application.status;
+
+import org.apache.stratos.messaging.listener.EventListener;
+
+/**
+ * Created by reka on 9/22/14.
+ */
+public abstract class AppStatusGroupTerminatingEventListener extends EventListener {
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/4e4ba5b3/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/ApplicationActivatedEventListener.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/ApplicationActivatedEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/ApplicationActivatedEventListener.java
deleted file mode 100644
index 22f2ac1..0000000
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/ApplicationActivatedEventListener.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.stratos.messaging.listener.application.status;
-
-import org.apache.stratos.messaging.listener.EventListener;
-
-/**
- * This listener will get triggered upon the application activated event.
- */
-public abstract class ApplicationActivatedEventListener extends EventListener {
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/4e4ba5b3/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/ApplicationCreatedEventListener.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/ApplicationCreatedEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/ApplicationCreatedEventListener.java
deleted file mode 100644
index cbeffa8..0000000
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/ApplicationCreatedEventListener.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.stratos.messaging.listener.application.status;
-
-import org.apache.stratos.messaging.listener.EventListener;
-
-/**
- * This listener will get triggered upon the application created event.
- */
-public abstract class ApplicationCreatedEventListener extends EventListener {
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/4e4ba5b3/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/ApplicationInActivatedEventListener.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/ApplicationInActivatedEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/ApplicationInActivatedEventListener.java
deleted file mode 100644
index eecf941..0000000
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/ApplicationInActivatedEventListener.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.stratos.messaging.listener.application.status;
-
-import org.apache.stratos.messaging.listener.EventListener;
-
-/**
- * This listener will get triggered upon the application inactivated event.
- */
-public abstract class ApplicationInActivatedEventListener extends EventListener {
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/4e4ba5b3/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/ApplicationTerminatedEventListener.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/ApplicationTerminatedEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/ApplicationTerminatedEventListener.java
deleted file mode 100644
index aacde3b..0000000
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/ApplicationTerminatedEventListener.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.stratos.messaging.listener.application.status;
-
-import org.apache.stratos.messaging.listener.EventListener;
-
-/**
- * This listener will get triggered upon the application terminated event.
- */
-public abstract class ApplicationTerminatedEventListener extends EventListener {
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/4e4ba5b3/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/ApplicationTerminatingEventListener.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/ApplicationTerminatingEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/ApplicationTerminatingEventListener.java
deleted file mode 100644
index b35984b..0000000
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/ApplicationTerminatingEventListener.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.stratos.messaging.listener.application.status;
-
-import org.apache.stratos.messaging.listener.EventListener;
-
-/**
- * This listener will get triggered upon the application terminating event.
- */
-public abstract class ApplicationTerminatingEventListener extends EventListener {
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/4e4ba5b3/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/ClusterActivatedEventListener.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/ClusterActivatedEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/ClusterActivatedEventListener.java
deleted file mode 100644
index 383b379..0000000
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/ClusterActivatedEventListener.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.stratos.messaging.listener.application.status;
-
-import org.apache.stratos.messaging.listener.EventListener;
-
-public abstract class ClusterActivatedEventListener extends EventListener{
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/4e4ba5b3/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/ClusterInActivateEventListener.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/ClusterInActivateEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/ClusterInActivateEventListener.java
deleted file mode 100644
index 2ae7335..0000000
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/ClusterInActivateEventListener.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.stratos.messaging.listener.application.status;
-
-import org.apache.stratos.messaging.listener.EventListener;
-
-public abstract class ClusterInActivateEventListener extends EventListener{
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/4e4ba5b3/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/GroupActivatedEventListener.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/GroupActivatedEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/GroupActivatedEventListener.java
deleted file mode 100644
index 83e5a7a..0000000
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/GroupActivatedEventListener.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.stratos.messaging.listener.application.status;
-
-import org.apache.stratos.messaging.listener.EventListener;
-
-/**
- * Created by reka on 9/22/14.
- */
-public abstract class GroupActivatedEventListener extends EventListener {
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/4e4ba5b3/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/GroupInactivateEventListener.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/GroupInactivateEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/GroupInactivateEventListener.java
deleted file mode 100644
index bcca3fd..0000000
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/GroupInactivateEventListener.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.stratos.messaging.listener.application.status;
-
-import org.apache.stratos.messaging.listener.EventListener;
-
-/**
- * Created by reka on 9/22/14.
- */
-public abstract class GroupInactivateEventListener extends EventListener {
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/4e4ba5b3/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/GroupTerminatedEventListener.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/GroupTerminatedEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/GroupTerminatedEventListener.java
deleted file mode 100644
index 6572516..0000000
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/GroupTerminatedEventListener.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.stratos.messaging.listener.application.status;
-
-import org.apache.stratos.messaging.listener.EventListener;
-
-public abstract class GroupTerminatedEventListener extends EventListener {
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/4e4ba5b3/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/GroupTerminatingEventListener.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/GroupTerminatingEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/GroupTerminatingEventListener.java
deleted file mode 100644
index afb65b8..0000000
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/GroupTerminatingEventListener.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.stratos.messaging.listener.application.status;
-
-import org.apache.stratos.messaging.listener.EventListener;
-
-/**
- * Created by reka on 9/22/14.
- */
-public abstract class GroupTerminatingEventListener extends EventListener {
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/4e4ba5b3/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusApplicationActivatedMessageProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusApplicationActivatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusApplicationActivatedMessageProcessor.java
new file mode 100644
index 0000000..a505624
--- /dev/null
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusApplicationActivatedMessageProcessor.java
@@ -0,0 +1,65 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.stratos.messaging.message.processor.application.status;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.messaging.event.application.status.AppStatusApplicationActivatedEvent;
+import org.apache.stratos.messaging.message.processor.MessageProcessor;
+import org.apache.stratos.messaging.util.Util;
+
+/**
+ * Created by reka on 9/25/14.
+ */
+public class AppStatusApplicationActivatedMessageProcessor extends MessageProcessor {
+ private static final Log log =
+ LogFactory.getLog(AppStatusApplicationActivatedMessageProcessor.class);
+
+
+ private MessageProcessor nextProcessor;
+ @Override
+ public void setNext(MessageProcessor nextProcessor) {
+ this.nextProcessor = nextProcessor;
+
+ }
+
+ @Override
+ public boolean process(String type, String message, Object object) {
+ if (AppStatusApplicationActivatedEvent.class.getName().equals(type)) {
+ // Parse complete message and build event
+ AppStatusApplicationActivatedEvent event =
+ (AppStatusApplicationActivatedEvent) Util.jsonToObject(message, AppStatusApplicationActivatedEvent.class);
+
+ if (log.isDebugEnabled()) {
+ log.debug("Received ApplicationActivatedEvent in application status topic: " + event.toString());
+ }
+ // Notify event listeners
+ notifyEventListeners(event);
+ return true;
+ } else {
+ if (nextProcessor != null) {
+ return nextProcessor.process(type, message, object);
+ } else {
+ throw new RuntimeException(
+ String.format("Failed to process group activated message " +
+ "using available message processors: [type] %s [body] %s", type, message));
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/4e4ba5b3/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusApplicationCreatedMessageProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusApplicationCreatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusApplicationCreatedMessageProcessor.java
new file mode 100644
index 0000000..4e2f97f
--- /dev/null
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusApplicationCreatedMessageProcessor.java
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.stratos.messaging.message.processor.application.status;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.messaging.event.topology.ApplicationCreatedEvent;
+import org.apache.stratos.messaging.message.processor.MessageProcessor;
+import org.apache.stratos.messaging.util.Util;
+
+public class AppStatusApplicationCreatedMessageProcessor extends MessageProcessor {
+ private static final Log log =
+ LogFactory.getLog(AppStatusApplicationCreatedMessageProcessor.class);
+
+
+ private MessageProcessor nextProcessor;
+
+ @Override
+ public void setNext(MessageProcessor nextProcessor) {
+ this.nextProcessor = nextProcessor;
+
+ }
+
+ @Override
+ public boolean process(String type, String message, Object object) {
+ if (ApplicationCreatedEvent.class.getName().equals(type)) {
+ // Parse complete message and build event
+ ApplicationCreatedEvent event =
+ (ApplicationCreatedEvent) Util.jsonToObject(message, ApplicationCreatedEvent.class);
+
+ if (log.isDebugEnabled()) {
+ log.debug("Received ApplicationCreated Event in application status topic: " + event.toString());
+ }
+ // Notify event listeners
+ notifyEventListeners(event);
+ return true;
+ } else {
+ if (nextProcessor != null) {
+ return nextProcessor.process(type, message, object);
+ } else {
+ throw new RuntimeException(
+ String.format("Failed to process group activated message " +
+ "using available message processors: [type] %s [body] %s", type, message));
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/4e4ba5b3/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusApplicationInactivatedMessageProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusApplicationInactivatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusApplicationInactivatedMessageProcessor.java
new file mode 100644
index 0000000..972fca3
--- /dev/null
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusApplicationInactivatedMessageProcessor.java
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.stratos.messaging.message.processor.application.status;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.messaging.event.application.status.AppStatusApplicationInactivatedEvent;
+import org.apache.stratos.messaging.message.processor.MessageProcessor;
+import org.apache.stratos.messaging.util.Util;
+
+public class AppStatusApplicationInactivatedMessageProcessor extends MessageProcessor {
+ private static final Log log =
+ LogFactory.getLog(AppStatusApplicationInactivatedMessageProcessor.class);
+
+
+ private MessageProcessor nextProcessor;
+
+ @Override
+ public void setNext(MessageProcessor nextProcessor) {
+ this.nextProcessor = nextProcessor;
+
+ }
+
+ @Override
+ public boolean process(String type, String message, Object object) {
+ if (AppStatusApplicationInactivatedEvent.class.getName().equals(type)) {
+ // Parse complete message and build event
+ AppStatusApplicationInactivatedEvent event =
+ (AppStatusApplicationInactivatedEvent) Util.jsonToObject(message, AppStatusApplicationInactivatedEvent.class);
+
+ if (log.isDebugEnabled()) {
+ log.debug("Received ApplicationInActivatedEvent in application status topic: " + event.toString());
+ }
+ // Notify event listeners
+ notifyEventListeners(event);
+ return true;
+ } else {
+ if (nextProcessor != null) {
+ return nextProcessor.process(type, message, object);
+ } else {
+ throw new RuntimeException(
+ String.format("Failed to process group activated message " +
+ "using available message processors: [type] %s [body] %s", type, message));
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/4e4ba5b3/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusApplicationTerminatedMessageProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusApplicationTerminatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusApplicationTerminatedMessageProcessor.java
new file mode 100644
index 0000000..b639ac0
--- /dev/null
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusApplicationTerminatedMessageProcessor.java
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.stratos.messaging.message.processor.application.status;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.messaging.event.application.status.AppStatusApplicationTerminatedEvent;
+import org.apache.stratos.messaging.message.processor.MessageProcessor;
+import org.apache.stratos.messaging.util.Util;
+
+public class AppStatusApplicationTerminatedMessageProcessor extends MessageProcessor {
+ private static final Log log =
+ LogFactory.getLog(AppStatusApplicationTerminatedMessageProcessor.class);
+
+
+ private MessageProcessor nextProcessor;
+
+ @Override
+ public void setNext(MessageProcessor nextProcessor) {
+ this.nextProcessor = nextProcessor;
+
+ }
+
+ @Override
+ public boolean process(String type, String message, Object object) {
+ if (AppStatusApplicationTerminatedEvent.class.getName().equals(type)) {
+ // Parse complete message and build event
+ AppStatusApplicationTerminatedEvent event =
+ (AppStatusApplicationTerminatedEvent) Util.jsonToObject(message, AppStatusApplicationTerminatedEvent.class);
+
+ if (log.isDebugEnabled()) {
+ log.debug("Received ApplicationTerminatedEvent in application status topic: " + event.toString());
+ }
+ // Notify event listeners
+ notifyEventListeners(event);
+ return true;
+ } else {
+ if (nextProcessor != null) {
+ return nextProcessor.process(type, message, object);
+ } else {
+ throw new RuntimeException(
+ String.format("Failed to process group activated message " +
+ "using available message processors: [type] %s [body] %s", type, message));
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/4e4ba5b3/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusApplicationTerminatingMessageProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusApplicationTerminatingMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusApplicationTerminatingMessageProcessor.java
new file mode 100644
index 0000000..143565a
--- /dev/null
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusApplicationTerminatingMessageProcessor.java
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.stratos.messaging.message.processor.application.status;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.messaging.event.application.status.AppStatusApplicationTerminatingEvent;
+import org.apache.stratos.messaging.message.processor.MessageProcessor;
+import org.apache.stratos.messaging.util.Util;
+
+public class AppStatusApplicationTerminatingMessageProcessor extends MessageProcessor {
+ private static final Log log =
+ LogFactory.getLog(AppStatusApplicationTerminatingMessageProcessor.class);
+
+
+ private MessageProcessor nextProcessor;
+
+ @Override
+ public void setNext(MessageProcessor nextProcessor) {
+ this.nextProcessor = nextProcessor;
+
+ }
+
+ @Override
+ public boolean process(String type, String message, Object object) {
+ if (AppStatusApplicationTerminatingEvent.class.getName().equals(type)) {
+ // Parse complete message and build event
+ AppStatusApplicationTerminatingEvent event =
+ (AppStatusApplicationTerminatingEvent) Util.jsonToObject(message, AppStatusApplicationTerminatingEvent.class);
+
+ if (log.isDebugEnabled()) {
+ log.debug("Received ApplicationTerminatingEvent in application status topic: " + event.toString());
+ }
+ // Notify event listeners
+ notifyEventListeners(event);
+ return true;
+ } else {
+ if (nextProcessor != null) {
+ return nextProcessor.process(type, message, object);
+ } else {
+ throw new RuntimeException(
+ String.format("Failed to process group activated message " +
+ "using available message processors: [type] %s [body] %s", type, message));
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/4e4ba5b3/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusClusterActivatedMessageProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusClusterActivatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusClusterActivatedMessageProcessor.java
new file mode 100644
index 0000000..3f3c6eb
--- /dev/null
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusClusterActivatedMessageProcessor.java
@@ -0,0 +1,57 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.stratos.messaging.message.processor.application.status;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.messaging.event.application.status.AppStatusClusterActivatedEvent;
+import org.apache.stratos.messaging.message.processor.MessageProcessor;
+import org.apache.stratos.messaging.util.Util;
+
+
+public class AppStatusClusterActivatedMessageProcessor extends MessageProcessor {
+ private static final Log log = LogFactory.getLog(AppStatusClusterActivatedMessageProcessor.class);
+ private MessageProcessor nextProcessor;
+
+ @Override
+ public void setNext(MessageProcessor nextProcessor) {
+ this.nextProcessor = nextProcessor;
+ }
+
+ @Override
+ public boolean process(String type, String message, Object object) {
+ if (AppStatusClusterActivatedEvent.class.getName().equals(type)) {
+ // Parse complete message and build event
+ AppStatusClusterActivatedEvent event = (AppStatusClusterActivatedEvent) Util.jsonToObject(message, AppStatusClusterActivatedEvent.class);
+
+ if(log.isDebugEnabled()) {
+ log.debug("Received ClusterActivatedEvent: " + event.toString());
+ }
+ // Notify event listeners
+ notifyEventListeners(event);
+ return true;
+ } else {
+ if (nextProcessor != null) {
+ return nextProcessor.process(type, message, object);
+ } else {
+ throw new RuntimeException(String.format("Failed to process cluster activated message using available message processors: [type] %s [body] %s", type, message));
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/4e4ba5b3/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusClusterInactivateMessageProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusClusterInactivateMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusClusterInactivateMessageProcessor.java
new file mode 100644
index 0000000..6e28972
--- /dev/null
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusClusterInactivateMessageProcessor.java
@@ -0,0 +1,58 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.stratos.messaging.message.processor.application.status;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.messaging.event.application.status.AppStatusClusterInactivateEvent;
+import org.apache.stratos.messaging.message.processor.MessageProcessor;
+import org.apache.stratos.messaging.util.Util;
+
+
+public class AppStatusClusterInactivateMessageProcessor extends MessageProcessor {
+ private static final Log log = LogFactory.getLog(AppStatusClusterInactivateMessageProcessor.class);
+ private MessageProcessor nextProcessor;
+
+ @Override
+ public void setNext(MessageProcessor nextProcessor) {
+ this.nextProcessor = nextProcessor;
+ }
+
+ @Override
+ public boolean process(String type, String message, Object object) {
+ if (AppStatusClusterInactivateEvent.class.getName().equals(type)) {
+ // Parse complete message and build event
+ AppStatusClusterInactivateEvent event = (AppStatusClusterInactivateEvent) Util.
+ jsonToObject(message, AppStatusClusterInactivateEvent.class);
+
+ if(log.isDebugEnabled()) {
+ log.debug("Received ClusterInActivateEvent: " + event.toString());
+ }
+ // Notify event listeners
+ notifyEventListeners(event);
+ return true;
+ } else {
+ if (nextProcessor != null) {
+ return nextProcessor.process(type, message, object);
+ } else {
+ throw new RuntimeException(String.format("Failed to process cluster activated message using available message processors: [type] %s [body] %s", type, message));
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/4e4ba5b3/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusGroupActivatedMessageProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusGroupActivatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusGroupActivatedMessageProcessor.java
new file mode 100644
index 0000000..473726c
--- /dev/null
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusGroupActivatedMessageProcessor.java
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.stratos.messaging.message.processor.application.status;
+
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.messaging.event.application.status.AppStatusGroupActivatedEvent;
+import org.apache.stratos.messaging.message.processor.MessageProcessor;
+import org.apache.stratos.messaging.util.Util;
+
+public class AppStatusGroupActivatedMessageProcessor extends MessageProcessor {
+ private static final Log log =
+ LogFactory.getLog(AppStatusGroupActivatedMessageProcessor.class);
+ private MessageProcessor nextProcessor;
+
+ @Override
+ public void setNext(MessageProcessor nextProcessor) {
+ this.nextProcessor = nextProcessor;
+ }
+
+ @Override
+ public boolean process(String type, String message, Object object) {
+ if (AppStatusGroupActivatedEvent.class.getName().equals(type)) {
+ // Parse complete message and build event
+ AppStatusGroupActivatedEvent event =
+ (AppStatusGroupActivatedEvent) Util.jsonToObject(message, AppStatusGroupActivatedEvent.class);
+
+ if (log.isDebugEnabled()) {
+ log.debug("Received GroupActivatedEvent: " + event.toString());
+ }
+ // Notify event listeners
+ notifyEventListeners(event);
+ return true;
+ } else {
+ if (nextProcessor != null) {
+ return nextProcessor.process(type, message, object);
+ } else {
+ throw new RuntimeException(
+ String.format("Failed to process group activated message " +
+ "using available message processors: [type] %s [body] %s", type, message));
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/4e4ba5b3/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusGroupInactivatedMessageProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusGroupInactivatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusGroupInactivatedMessageProcessor.java
new file mode 100644
index 0000000..714ee88
--- /dev/null
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusGroupInactivatedMessageProcessor.java
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.stratos.messaging.message.processor.application.status;
+
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.messaging.event.application.status.AppStatusGroupInactivateEvent;
+import org.apache.stratos.messaging.message.processor.MessageProcessor;
+import org.apache.stratos.messaging.util.Util;
+
+public class AppStatusGroupInactivatedMessageProcessor extends MessageProcessor {
+ private static final Log log =
+ LogFactory.getLog(AppStatusGroupInactivatedMessageProcessor.class);
+ private MessageProcessor nextProcessor;
+
+ @Override
+ public void setNext(MessageProcessor nextProcessor) {
+ this.nextProcessor = nextProcessor;
+ }
+
+ @Override
+ public boolean process(String type, String message, Object object) {
+ if (AppStatusGroupInactivateEvent.class.getName().equals(type)) {
+ // Parse complete message and build event
+ AppStatusGroupInactivateEvent event =
+ (AppStatusGroupInactivateEvent) Util.jsonToObject(message, AppStatusGroupInactivateEvent.class);
+
+ if (log.isDebugEnabled()) {
+ log.debug("Received GroupInActivateEvent: " + event.toString());
+ }
+ // Notify event listeners
+ notifyEventListeners(event);
+ return true;
+ } else {
+ if (nextProcessor != null) {
+ return nextProcessor.process(type, message, object);
+ } else {
+ throw new RuntimeException(
+ String.format("Failed to process group in activated message " +
+ "using available message processors: [type] %s [body] %s", type, message));
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/4e4ba5b3/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusGroupTerminatedMessageProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusGroupTerminatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusGroupTerminatedMessageProcessor.java
new file mode 100644
index 0000000..daa7206
--- /dev/null
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusGroupTerminatedMessageProcessor.java
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.stratos.messaging.message.processor.application.status;
+
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.messaging.event.application.status.AppStatusGroupTerminatedEvent;
+import org.apache.stratos.messaging.message.processor.MessageProcessor;
+import org.apache.stratos.messaging.util.Util;
+
+public class AppStatusGroupTerminatedMessageProcessor extends MessageProcessor {
+ private static final Log log =
+ LogFactory.getLog(AppStatusGroupTerminatedMessageProcessor.class);
+ private MessageProcessor nextProcessor;
+
+ @Override
+ public void setNext(MessageProcessor nextProcessor) {
+ this.nextProcessor = nextProcessor;
+ }
+
+ @Override
+ public boolean process(String type, String message, Object object) {
+ if (AppStatusGroupTerminatedEvent.class.getName().equals(type)) {
+ // Parse complete message and build event
+ AppStatusGroupTerminatedEvent event =
+ (AppStatusGroupTerminatedEvent) Util.jsonToObject(message, AppStatusGroupTerminatedEvent.class);
+
+ if (log.isDebugEnabled()) {
+ log.debug("Received GroupTerminatingEvent: " + event.toString());
+ }
+ // Notify event listeners
+ notifyEventListeners(event);
+ return true;
+ } else {
+ if (nextProcessor != null) {
+ return nextProcessor.process(type, message, object);
+ } else {
+ throw new RuntimeException(
+ String.format("Failed to process group in GroupTerminatingEvent message " +
+ "using available message processors: [type] %s [body] %s", type, message));
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/4e4ba5b3/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusGroupTerminatingMessageProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusGroupTerminatingMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusGroupTerminatingMessageProcessor.java
new file mode 100644
index 0000000..7445695
--- /dev/null
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusGroupTerminatingMessageProcessor.java
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.stratos.messaging.message.processor.application.status;
+
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.messaging.event.topology.GroupTerminatingEvent;
+import org.apache.stratos.messaging.message.processor.MessageProcessor;
+import org.apache.stratos.messaging.util.Util;
+
+public class AppStatusGroupTerminatingMessageProcessor extends MessageProcessor {
+ private static final Log log =
+ LogFactory.getLog(AppStatusGroupTerminatingMessageProcessor.class);
+ private MessageProcessor nextProcessor;
+
+ @Override
+ public void setNext(MessageProcessor nextProcessor) {
+ this.nextProcessor = nextProcessor;
+ }
+
+ @Override
+ public boolean process(String type, String message, Object object) {
+ if (GroupTerminatingEvent.class.getName().equals(type)) {
+ // Parse complete message and build event
+ GroupTerminatingEvent event =
+ (GroupTerminatingEvent) Util.jsonToObject(message, GroupTerminatingEvent.class);
+
+ if (log.isDebugEnabled()) {
+ log.debug("Received GroupTerminatingEvent: " + event.toString());
+ }
+ // Notify event listeners
+ notifyEventListeners(event);
+ return true;
+ } else {
+ if (nextProcessor != null) {
+ return nextProcessor.process(type, message, object);
+ } else {
+ throw new RuntimeException(
+ String.format("Failed to process group in GroupTerminatingEvent message " +
+ "using available message processors: [type] %s [body] %s", type, message));
+ }
+ }
+ }
+}
[46/50] [abbrv] git commit: fixing recursive call when terminating
cluster/group
Posted by im...@apache.org.
fixing recursive call when terminating cluster/group
Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/5e69c7fe
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/5e69c7fe
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/5e69c7fe
Branch: refs/heads/docker-grouping-merge
Commit: 5e69c7fe6d5eb00c64e7bc7c4159859632b7fd0a
Parents: 5196529
Author: reka <rt...@gmail.com>
Authored: Wed Oct 29 18:23:04 2014 +0530
Committer: reka <rt...@gmail.com>
Committed: Wed Oct 29 18:23:20 2014 +0530
----------------------------------------------------------------------
.../stratos/autoscaler/monitor/MonitorStatusEventBuilder.java | 4 ++--
.../apache/stratos/autoscaler/monitor/group/GroupMonitor.java | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/stratos/blob/5e69c7fe/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/MonitorStatusEventBuilder.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/MonitorStatusEventBuilder.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/MonitorStatusEventBuilder.java
index 30187ea..59bb4c0 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/MonitorStatusEventBuilder.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/MonitorStatusEventBuilder.java
@@ -53,8 +53,8 @@ public class MonitorStatusEventBuilder {
parent.onChildEvent(statusEvent);
}
- public static void notifyChildren (ParentComponentMonitor parent, MonitorStatusEvent statusEvent) {
- for (Monitor activeChildMonitor : parent.getAliasToActiveMonitorsMap().values()) {
+ public static void notifyChildren (ParentComponentMonitor componentMonitor, MonitorStatusEvent statusEvent) {
+ for (Monitor activeChildMonitor : componentMonitor.getAliasToActiveMonitorsMap().values()) {
activeChildMonitor.onParentEvent(statusEvent);
}
}
http://git-wip-us.apache.org/repos/asf/stratos/blob/5e69c7fe/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java
index b42e840..b1b7882 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java
@@ -162,6 +162,6 @@ public class GroupMonitor extends ParentComponentMonitor implements EventHandler
}
//}
//notify the children about the state change
- MonitorStatusEventBuilder.notifyChildren(this.parent, new GroupStatusEvent(status, getId()));
+ MonitorStatusEventBuilder.notifyChildren(this, new GroupStatusEvent(status, getId()));
}
}
[34/50] [abbrv] git commit: fixing inActive handling issue
Posted by im...@apache.org.
fixing inActive handling issue
Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/3b51d5c8
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/3b51d5c8
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/3b51d5c8
Branch: refs/heads/docker-grouping-merge
Commit: 3b51d5c8f184643b8aa9cc7c6d8855b1f09596b5
Parents: ed1af70
Author: reka <rt...@gmail.com>
Authored: Wed Oct 29 14:52:22 2014 +0530
Committer: reka <rt...@gmail.com>
Committed: Wed Oct 29 14:52:22 2014 +0530
----------------------------------------------------------------------
.../monitor/ParentComponentMonitor.java | 75 ++++++++++----------
.../monitor/application/ApplicationMonitor.java | 4 +-
.../autoscaler/monitor/group/GroupMonitor.java | 2 +-
3 files changed, 42 insertions(+), 39 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/stratos/blob/3b51d5c8/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ParentComponentMonitor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ParentComponentMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ParentComponentMonitor.java
index 6aa76b6..bd50f42 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ParentComponentMonitor.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ParentComponentMonitor.java
@@ -30,7 +30,6 @@ import org.apache.stratos.autoscaler.grouping.dependency.context.ApplicationCont
import org.apache.stratos.autoscaler.grouping.topic.StatusEventPublisher;
import org.apache.stratos.autoscaler.monitor.events.MonitorStatusEvent;
import org.apache.stratos.autoscaler.status.checker.StatusChecker;
-import org.apache.stratos.messaging.domain.topology.GroupStatus;
import org.apache.stratos.messaging.domain.topology.ParentComponent;
import java.util.HashMap;
@@ -115,50 +114,54 @@ public abstract class ParentComponentMonitor extends Monitor {
protected void onChildInActiveEvent(String idOfEvent) {
List<ApplicationContext> terminationList;
Monitor monitor;
- //Temporarily move the group/cluster to inactive list
- //this.aliasToInActiveMonitorsMap.put(idOfEvent, this.aliasToActiveMonitorsMap.remove(idOfEvent));
- if(this.hasDependent) {
+ if (this.hasDependent) {
//need to notify the parent
StatusChecker.getInstance().onChildStatusChange(idOfEvent, this.id, this.appId);
} else {
terminationList = this.dependencyTree.getTerminationDependencies(idOfEvent);
- if(this.hasInDependentChild()) {
- if(this.parent != null) {
+ //Checking whether all children are to be terminated.
+ if (terminationList.size() ==
+ (this.aliasToActiveMonitorsMap.size() + this.aliasToInActiveMonitorsMap.size())) {
+ if (this.parent != null) {
+ StatusEventPublisher.sendGroupTerminatingEvent(this.appId, this.id);
+ }
+ } else {
+ //TODO application InActive
+ if (this.parent != null) {
StatusEventPublisher.sendGroupInActivateEvent(this.appId, this.id);
- } /*else {
- StatusEventPublisher.sendApplicationInactivatedEvent(this.appId, terminationContext.getId());
-
- }*/
-
- }
-
- if (terminationList != null) {
- //Checking the termination dependents status
- for (ApplicationContext terminationContext : terminationList) {
- //Check whether dependent is in_active, then start to kill it
- monitor = this.aliasToActiveMonitorsMap.
- get(terminationContext.getId());
- //start to kill it
- if(monitor != null) {
- if (monitor.hasActiveMonitors()) {
- //it is a group
- StatusEventPublisher.sendGroupTerminatingEvent(this.appId, terminationContext.getId());
+ }
+ //Since it is reached the most independent unit and has few independent monitors,
+ // has to put the children down to terminating
+
+ if (terminationList != null) {
+ //Checking the termination dependents status
+ for (ApplicationContext terminationContext : terminationList) {
+ //Check whether dependent is in_active, then start to kill it
+ monitor = this.aliasToActiveMonitorsMap.
+ get(terminationContext.getId());
+ //start to kill it
+ if (monitor != null) {
+ if (monitor.hasActiveMonitors()) {
+ //it is a group
+ StatusEventPublisher.sendGroupTerminatingEvent(this.appId, terminationContext.getId());
+ } else {
+ StatusEventPublisher.sendClusterTerminatingEvent(this.appId,
+ ((AbstractClusterMonitor) monitor).getServiceId(), terminationContext.getId());
+ }
} else {
- StatusEventPublisher.sendClusterTerminatingEvent(this.appId,
- ((AbstractClusterMonitor) monitor).getServiceId(), terminationContext.getId());
-
+ log.warn("The relevant [monitor] " + terminationContext.getId() +
+ "is not in the active map....");
}
- } else {
- log.warn("The relevant [monitor] " + terminationContext.getId() +
- "is not in the active map....");
- }
+ }
+ } else {
+ log.warn("Wrong inActive event received from [Child] " + idOfEvent + " to the [parent]"
+ + " where child is identified as a independent");
}
- } else {
- log.warn("Wrong inActive event received from [Child] " + idOfEvent + " to the [parent]"
- + " where child is identified as a independent");
}
+
+
}
}
@@ -210,7 +213,7 @@ public abstract class ParentComponentMonitor extends Monitor {
}
}
- if((terminationList != null && allDependentTerminated || terminationList == null) &&
+ if ((terminationList != null && allDependentTerminated || terminationList == null) &&
(parentContexts != null && canStart || parentContexts == null)) {
//Find the non existent monitor by traversing dependency tree
@@ -249,7 +252,7 @@ public abstract class ParentComponentMonitor extends Monitor {
public void startDependencyOnTermination() throws TopologyInConsistentException {
//start the first dependency which went to terminated
List<ApplicationContext> applicationContexts = this.dependencyTree.
- getStarAbleDependenciesByTermination();
+ getStarAbleDependenciesByTermination();
startDependency(applicationContexts);
}
http://git-wip-us.apache.org/repos/asf/stratos/blob/3b51d5c8/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 f6a4d18..77def36 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
@@ -176,9 +176,9 @@ public class ApplicationMonitor extends ParentComponentMonitor {
onChildInActiveEvent(id);
//TODO update the status of the Application as in_active when child becomes in_active
- } else if (status1 == ClusterStatus.Terminating || status1 == GroupStatus.Terminating) {
+ /*} else if (status1 == ClusterStatus.Terminating || status1 == GroupStatus.Terminating) {
onChildTerminatingEvent(id);
- StatusChecker.getInstance().onChildStatusChange(id, this.id, this.appId);
+ StatusChecker.getInstance().onChildStatusChange(id, this.id, this.appId);*/
} else if (status1 == ClusterStatus.Terminated || status1 == GroupStatus.Terminated) {
//Check whether all dependent goes Terminated and then start them in parallel.
http://git-wip-us.apache.org/repos/asf/stratos/blob/3b51d5c8/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java
index 261f745..e6f8495 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java
@@ -88,7 +88,7 @@ public class GroupMonitor extends ParentComponentMonitor implements EventHandler
StatusChecker.getInstance().onChildStatusChange(id, this.id, this.appId);
} else if (status1 == ClusterStatus.Terminating || status1 == GroupStatus.Terminating) {
- onChildTerminatingEvent(id);
+ //onChildTerminatingEvent(id);
StatusChecker.getInstance().onChildStatusChange(id, this.id, this.appId);
} else if (status1 == ClusterStatus.Terminated || status1 == GroupStatus.Terminated) {
[06/50] [abbrv] git commit: removing ApplicationRemovedEvent,
ApplicationRemovedEventListener and ApplicationRemovedMessageProcessor
Posted by im...@apache.org.
removing ApplicationRemovedEvent, ApplicationRemovedEventListener and ApplicationRemovedMessageProcessor
Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/b56e3285
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/b56e3285
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/b56e3285
Branch: refs/heads/docker-grouping-merge
Commit: b56e3285239b2c070d7e78062ae8dd9e26131e50
Parents: 4e4ba5b
Author: Isuru Haththotuwa <is...@apache.org>
Authored: Mon Oct 27 13:08:58 2014 +0530
Committer: Isuru Haththotuwa <is...@apache.org>
Committed: Mon Oct 27 13:08:58 2014 +0530
----------------------------------------------------------------------
.../AutoscalerTopologyEventReceiver.java | 97 ++++++++++---
.../controller/topology/TopologyBuilder.java | 4 +-
.../topology/TopologyEventPublisher.java | 18 +--
.../StratosManagerTopologyEventReceiver.java | 13 +-
.../event/topology/ApplicationRemovedEvent.java | 62 --------
.../topology/ApplicationTerminatedEvent.java | 15 +-
.../ApplicationRemovedEventListener.java | 26 ----
...pStatusGroupTerminatingMessageProcessor.java | 8 +-
.../ApplicationRemovedMessageProcessor.java | 142 -------------------
.../ApplicationTerminatedMessageProcessor.java | 76 +++++++---
.../topology/TopologyMessageProcessorChain.java | 6 -
11 files changed, 166 insertions(+), 301 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/stratos/blob/b56e3285/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 654d5b2..89fe51f 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
@@ -419,28 +419,83 @@ public class AutoscalerTopologyEventReceiver implements Runnable {
}
});
- topologyEventReceiver.addEventListener(new ApplicationRemovedEventListener() {
+// topologyEventReceiver.addEventListener(new ApplicationRemovedEventListener() {
+// @Override
+// protected void onEvent(Event event) {
+//
+// log.info("[ApplicationRemovedEvent] Received: " + event.getClass());
+//
+// ApplicationRemovedEvent applicationRemovedEvent = (ApplicationRemovedEvent) event;
+//
+// //acquire read lock
+// TopologyManager.acquireReadLockForApplication(applicationRemovedEvent.getApplicationId());
+// Set<ClusterDataHolder> clusterDataHolders = applicationRemovedEvent.getClusterData();
+// if (clusterDataHolders != null) {
+// for (ClusterDataHolder clusterData : clusterDataHolders) {
+// TopologyManager.acquireReadLockForCluster(clusterData.getServiceType(),
+// clusterData.getClusterId());
+// }
+// }
+//
+// try {
+// //TODO remove monitors as well as any starting or pending threads
+// ApplicationMonitor monitor = AutoscalerContext.getInstance().
+// getAppMonitor(applicationRemovedEvent.getApplicationId());
+// if (monitor != null) {
+// //List<String> clusters = monitor.
+// // findClustersOfApplication(applicationRemovedEvent.getApplicationId());
+// for (ClusterDataHolder clusterData : clusterDataHolders) {
+// //stopping the cluster monitor and remove it from the AS
+// ((ClusterMonitor) AutoscalerContext.getInstance().getMonitor(clusterData.getClusterId())).
+// setDestroyed(true);
+// AutoscalerContext.getInstance().removeMonitor(clusterData.getClusterId());
+// }
+// //removing the application monitor
+// AutoscalerContext.getInstance().
+// removeAppMonitor(applicationRemovedEvent.getApplicationId());
+// } else {
+// log.warn("Application Monitor cannot be found for the removed [application] "
+// + applicationRemovedEvent.getApplicationId());
+// }
+//
+//
+// } finally {
+// //release read lock
+// if (clusterDataHolders != null) {
+// for (ClusterDataHolder clusterData : clusterDataHolders) {
+// TopologyManager.releaseReadLockForCluster(clusterData.getServiceType(),
+// clusterData.getClusterId());
+// }
+// }
+// TopologyManager.releaseReadLockForApplication(applicationRemovedEvent.getApplicationId());
+// }
+//
+// }
+// });
+
+ topologyEventReceiver.addEventListener(new ApplicationTerminatedEventListener() {
@Override
protected void onEvent(Event event) {
- log.info("[ApplicationRemovedEvent] Received: " + event.getClass());
+ log.info("[ApplicationTerminatedEvent] Received: " + event.getClass());
- ApplicationRemovedEvent applicationRemovedEvent = (ApplicationRemovedEvent) event;
+ ApplicationTerminatedEvent applicationRemovedEvent = (ApplicationTerminatedEvent) event;
+ // no need to access the locks since the Topology is not accessed
//acquire read lock
- TopologyManager.acquireReadLockForApplication(applicationRemovedEvent.getApplicationId());
+ //TopologyManager.acquireReadLockForApplication(applicationRemovedEvent.getAppId());
Set<ClusterDataHolder> clusterDataHolders = applicationRemovedEvent.getClusterData();
- if (clusterDataHolders != null) {
- for (ClusterDataHolder clusterData : clusterDataHolders) {
- TopologyManager.acquireReadLockForCluster(clusterData.getServiceType(),
- clusterData.getClusterId());
- }
- }
+// if (clusterDataHolders != null) {
+// for (ClusterDataHolder clusterData : clusterDataHolders) {
+// TopologyManager.acquireReadLockForCluster(clusterData.getServiceType(),
+// clusterData.getClusterId());
+// }
+// }
try {
//TODO remove monitors as well as any starting or pending threads
ApplicationMonitor monitor = AutoscalerContext.getInstance().
- getAppMonitor(applicationRemovedEvent.getApplicationId());
+ getAppMonitor(applicationRemovedEvent.getAppId());
if (monitor != null) {
//List<String> clusters = monitor.
// findClustersOfApplication(applicationRemovedEvent.getApplicationId());
@@ -452,22 +507,22 @@ public class AutoscalerTopologyEventReceiver implements Runnable {
}
//removing the application monitor
AutoscalerContext.getInstance().
- removeAppMonitor(applicationRemovedEvent.getApplicationId());
+ removeAppMonitor(applicationRemovedEvent.getAppId());
} else {
- log.warn("Application Monitor cannot be found for the removed [application] "
- + applicationRemovedEvent.getApplicationId());
+ log.warn("Application Monitor cannot be found for the terminated [application] "
+ + applicationRemovedEvent.getAppId());
}
} finally {
//release read lock
- if (clusterDataHolders != null) {
- for (ClusterDataHolder clusterData : clusterDataHolders) {
- TopologyManager.releaseReadLockForCluster(clusterData.getServiceType(),
- clusterData.getClusterId());
- }
- }
- TopologyManager.releaseReadLockForApplication(applicationRemovedEvent.getApplicationId());
+// if (clusterDataHolders != null) {
+// for (ClusterDataHolder clusterData : clusterDataHolders) {
+// TopologyManager.releaseReadLockForCluster(clusterData.getServiceType(),
+// clusterData.getClusterId());
+// }
+// }
+// TopologyManager.releaseReadLockForApplication(applicationRemovedEvent.getAppId());
}
}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b56e3285/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java
index 3e04311..f4606b8 100644
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java
@@ -1044,8 +1044,8 @@ public class TopologyBuilder {
log.info("Removed application [ " + event.getAppId() + " ] from Topology");
- TopologyEventPublisher.sendApplicationRemovedEvent(event.getAppId(),
- clusterData, tenantId, tenantDomain);
+ TopologyEventPublisher.sendApplicationTerminatedEvent(new ApplicationTerminatedEvent(event.getAppId(),
+ clusterData, tenantId, tenantDomain));
}
} finally {
http://git-wip-us.apache.org/repos/asf/stratos/blob/b56e3285/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyEventPublisher.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyEventPublisher.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyEventPublisher.java
index cd13111..a3feb4d 100644
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyEventPublisher.java
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyEventPublisher.java
@@ -103,15 +103,15 @@ public class TopologyEventPublisher {
publishEvent(new ApplicationUndeployedEvent(applicationId, clusterData));
}
- public static void sendApplicationRemovedEvent(String applicationId, Set<ClusterDataHolder> clusterData,
- int tenantId, String tenantDomain) {
-
- if(log.isInfoEnabled() || log.isDebugEnabled()) {
- log.info("Publishing Application removed event: " + applicationId + " tenantId: " + tenantId);
- }
-
- publishEvent(new ApplicationRemovedEvent(applicationId, clusterData, tenantId, tenantDomain));
- }
+// public static void sendApplicationRemovedEvent(String applicationId, Set<ClusterDataHolder> clusterData,
+// int tenantId, String tenantDomain) {
+//
+// if(log.isInfoEnabled() || log.isDebugEnabled()) {
+// log.info("Publishing Application removed event: " + applicationId + " tenantId: " + tenantId);
+// }
+//
+// publishEvent(new ApplicationRemovedEvent(applicationId, clusterData, tenantId, tenantDomain));
+// }
public static void sendClusterRemovedEvent(ClusterContext ctxt, String deploymentPolicy) {
http://git-wip-us.apache.org/repos/asf/stratos/blob/b56e3285/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/topology/receiver/StratosManagerTopologyEventReceiver.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/topology/receiver/StratosManagerTopologyEventReceiver.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/topology/receiver/StratosManagerTopologyEventReceiver.java
index 699af72..6e8552b 100644
--- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/topology/receiver/StratosManagerTopologyEventReceiver.java
+++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/topology/receiver/StratosManagerTopologyEventReceiver.java
@@ -355,21 +355,22 @@ public class StratosManagerTopologyEventReceiver implements Runnable {
});
//add listener
- topologyEventReceiver.addEventListener(new ApplicationRemovedEventListener() {
+ topologyEventReceiver.addEventListener(new ApplicationTerminatedEventListener() {
@Override
protected void onEvent(Event event) {
- ApplicationRemovedEvent appRemovedEvent = (ApplicationRemovedEvent) event;
+ ApplicationTerminatedEvent appRemovedEvent = (ApplicationTerminatedEvent) event;
- log.info("[ApplicationRemovedEventListener] Received: " + event.getClass());
+ log.info("[ApplicationTerminatedEvent] Received: " + event.getClass());
try {
+ // no need to lock since Topology is not accessed
//TopologyManager.acquireReadLock();
- TopologyManager.acquireReadLockForApplication(appRemovedEvent.getApplicationId());
+ //TopologyManager.acquireReadLockForApplication(appRemovedEvent.getAppId());
// create and persist Application subscritpion
CartridgeSubscriptionManager cartridgeSubscriptionManager = new CartridgeSubscriptionManager();
- String appId = appRemovedEvent.getApplicationId();
+ String appId = appRemovedEvent.getAppId();
int tenantId = appRemovedEvent.getTenantId();
String domain = appRemovedEvent.getTenantDomain();
@@ -393,7 +394,7 @@ public class StratosManagerTopologyEventReceiver implements Runnable {
}
} finally {
//TopologyManager.releaseReadLock();
- TopologyManager.releaseReadLockForApplication(appRemovedEvent.getApplicationId());
+ //TopologyManager.releaseReadLockForApplication(appRemovedEvent.getAppId());
}
}
});
http://git-wip-us.apache.org/repos/asf/stratos/blob/b56e3285/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ApplicationRemovedEvent.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ApplicationRemovedEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ApplicationRemovedEvent.java
deleted file mode 100644
index 3d5b9a4..0000000
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ApplicationRemovedEvent.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.stratos.messaging.event.topology;
-
-
-import org.apache.stratos.messaging.domain.topology.ClusterDataHolder;
-
-import java.util.Set;
-
-public class ApplicationRemovedEvent extends TopologyEvent {
-
- /**
- *
- */
- private static final long serialVersionUID = -5499420725533165623L;
- private final String applicationId;
- private Set<ClusterDataHolder> clusterData;
-
- private String tenantDomain;
- private int tenantId;
-
- public ApplicationRemovedEvent(String applicationId, Set<ClusterDataHolder> clusterData,
- int tenantId, String tenantDomain) {
- this.applicationId = applicationId;
- this.clusterData = clusterData;
- this.tenantId = tenantId;
- this.tenantDomain = tenantDomain;
- }
-
- public String getApplicationId() {
- return applicationId;
- }
-
- public int getTenantId() {
- return tenantId;
- }
-
- public String getTenantDomain() {
- return tenantDomain;
- }
-
- public Set<ClusterDataHolder> getClusterData() {
- return clusterData;
- }
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b56e3285/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ApplicationTerminatedEvent.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ApplicationTerminatedEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ApplicationTerminatedEvent.java
index 6607a02..fa0cd26 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ApplicationTerminatedEvent.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ApplicationTerminatedEvent.java
@@ -28,10 +28,15 @@ import java.util.Set;
public class ApplicationTerminatedEvent extends TopologyEvent {
private final String appId;
private final Set<ClusterDataHolder> clusterData;
+ private String tenantDomain;
+ private int tenantId;
- public ApplicationTerminatedEvent(String appId, Set<ClusterDataHolder> clusterData) {
+ public ApplicationTerminatedEvent(String appId, Set<ClusterDataHolder> clusterData,
+ int tenantId, String tenantDomain) {
this.appId = appId;
this.clusterData = clusterData;
+ this.tenantId = tenantId;
+ this.tenantDomain = tenantDomain;
}
public String getAppId() {
@@ -41,4 +46,12 @@ public class ApplicationTerminatedEvent extends TopologyEvent {
public Set<ClusterDataHolder> getClusterData() {
return clusterData;
}
+
+ public String getTenantDomain() {
+ return tenantDomain;
+ }
+
+ public int getTenantId() {
+ return tenantId;
+ }
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/stratos/blob/b56e3285/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/ApplicationRemovedEventListener.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/ApplicationRemovedEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/ApplicationRemovedEventListener.java
deleted file mode 100644
index c3a1178..0000000
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/ApplicationRemovedEventListener.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.stratos.messaging.listener.topology;
-
-import org.apache.stratos.messaging.listener.EventListener;
-
-public abstract class ApplicationRemovedEventListener extends EventListener {
-
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b56e3285/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusGroupTerminatingMessageProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusGroupTerminatingMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusGroupTerminatingMessageProcessor.java
index 7445695..75012e0 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusGroupTerminatingMessageProcessor.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusGroupTerminatingMessageProcessor.java
@@ -21,7 +21,7 @@ package org.apache.stratos.messaging.message.processor.application.status;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.messaging.event.topology.GroupTerminatingEvent;
+import org.apache.stratos.messaging.event.application.status.AppStatusGroupTerminatingEvent;
import org.apache.stratos.messaging.message.processor.MessageProcessor;
import org.apache.stratos.messaging.util.Util;
@@ -37,10 +37,10 @@ public class AppStatusGroupTerminatingMessageProcessor extends MessageProcessor
@Override
public boolean process(String type, String message, Object object) {
- if (GroupTerminatingEvent.class.getName().equals(type)) {
+ if (AppStatusGroupTerminatingEvent.class.getName().equals(type)) {
// Parse complete message and build event
- GroupTerminatingEvent event =
- (GroupTerminatingEvent) Util.jsonToObject(message, GroupTerminatingEvent.class);
+ AppStatusGroupTerminatingEvent event =
+ (AppStatusGroupTerminatingEvent) Util.jsonToObject(message, AppStatusGroupTerminatingEvent.class);
if (log.isDebugEnabled()) {
log.debug("Received GroupTerminatingEvent: " + event.toString());
http://git-wip-us.apache.org/repos/asf/stratos/blob/b56e3285/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationRemovedMessageProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationRemovedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationRemovedMessageProcessor.java
deleted file mode 100644
index 5e02565..0000000
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationRemovedMessageProcessor.java
+++ /dev/null
@@ -1,142 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.stratos.messaging.message.processor.topology;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.messaging.domain.topology.ClusterDataHolder;
-import org.apache.stratos.messaging.domain.topology.Service;
-import org.apache.stratos.messaging.domain.topology.Topology;
-import org.apache.stratos.messaging.event.topology.ApplicationRemovedEvent;
-import org.apache.stratos.messaging.message.processor.MessageProcessor;
-import org.apache.stratos.messaging.message.processor.topology.updater.TopologyUpdater;
-import org.apache.stratos.messaging.util.Util;
-
-import java.util.Set;
-
-public class ApplicationRemovedMessageProcessor extends MessageProcessor {
-
- private static final Log log = LogFactory.getLog(ApplicationCreatedMessageProcessor.class);
-
- private MessageProcessor nextProcessor;
-
- @Override
- public void setNext(MessageProcessor nextProcessor) {
- this.nextProcessor = nextProcessor;
- }
-
- @Override
- public boolean process(String type, String message, Object object) {
-
- if (log.isDebugEnabled()) {
- log.debug("ApplicationRemovedMessageProcessor processing " + object);
- }
-
- Topology topology = (Topology) object;
-
- if (ApplicationRemovedEvent.class.getName().equals(type)) {
- if (!topology.isInitialized()) {
- if (log.isDebugEnabled()) {
- log.debug("ApplicationRemovedMessageProcessor topology not initialized ... " + object);
- }
- return false;
- }
-
- ApplicationRemovedEvent event = (ApplicationRemovedEvent) Util.jsonToObject(message, ApplicationRemovedEvent.class);
- if (event == null) {
- log.error("Unable to convert the JSON message to ApplicationCreatedEvent");
- return false;
- }
-
- TopologyUpdater.acquireWriteLockForApplications();
- Set<ClusterDataHolder> clusterDataHolders = event.getClusterData();
- if (clusterDataHolders != null) {
- for (ClusterDataHolder clusterData : clusterDataHolders) {
- TopologyUpdater.acquireWriteLockForService(clusterData.getServiceType());
- }
- }
-
- try {
- return doProcess(event, topology);
-
- } finally {
- if (clusterDataHolders != null) {
- for (ClusterDataHolder clusterData : clusterDataHolders) {
- TopologyUpdater.releaseWriteLockForService(clusterData.getServiceType());
- }
- }
- TopologyUpdater.releaseWriteLockForApplications();
- }
-
- } else {
- if (nextProcessor != null) {
- // ask the next processor to take care of the message.
- return nextProcessor.process(type, message, topology);
- } else {
- throw new RuntimeException(String.format("Failed to process message using available message processors: [type] %s [body] %s", type, message));
- }
- }
- }
-
- private boolean doProcess (ApplicationRemovedEvent event, Topology topology) {
-
- // check if required properties are available
- if (event.getApplicationId() == null) {
- String errorMsg = "Application Id of application removed event is invalid";
- log.error(errorMsg);
- throw new RuntimeException(errorMsg);
- }
-
- if (event.getTenantDomain()== null) {
- String errorMsg = "Application tenant domain of application removed event is invalid";
- log.error(errorMsg);
- throw new RuntimeException(errorMsg);
- }
-
- // check if an Application with same name exists in topology
- String appId = event.getApplicationId();
- if (topology.applicationExists(appId)) {
- log.warn("Application with id [ " + appId + " ] still exists in Topology, removing it");
- topology.removeApplication(appId);
- }
-
- if (event.getClusterData() != null) {
- // remove the Clusters from the Topology
- for (ClusterDataHolder clusterData : event.getClusterData()) {
- Service service = topology.getService(clusterData.getServiceType());
- if (service != null) {
- service.removeCluster(clusterData.getClusterId());
- if (log.isDebugEnabled()) {
- log.debug("Removed the Cluster " + clusterData.getClusterId() + " from Topology");
- }
- } else {
- log.warn("Service " + clusterData.getServiceType() + " not found in Topology!");
- }
- }
- }
-
- if (log.isDebugEnabled()) {
- log.debug("ApplicationRemovedMessageProcessor notifying listener ");
- }
-
- notifyEventListeners(event);
- return true;
- }
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b56e3285/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationTerminatedMessageProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationTerminatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationTerminatedMessageProcessor.java
index 2d22c6c..49a8d22 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationTerminatedMessageProcessor.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationTerminatedMessageProcessor.java
@@ -20,14 +20,15 @@ package org.apache.stratos.messaging.message.processor.topology;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.messaging.domain.topology.Application;
-import org.apache.stratos.messaging.domain.topology.ApplicationStatus;
-import org.apache.stratos.messaging.domain.topology.Topology;
+import org.apache.stratos.messaging.domain.topology.*;
import org.apache.stratos.messaging.event.topology.ApplicationInactivatedEvent;
+import org.apache.stratos.messaging.event.topology.ApplicationTerminatedEvent;
import org.apache.stratos.messaging.message.processor.MessageProcessor;
import org.apache.stratos.messaging.message.processor.topology.updater.TopologyUpdater;
import org.apache.stratos.messaging.util.Util;
+import java.util.Set;
+
/**
* This processor responsible to process the application Inactivation even and update the Topology.
*/
@@ -48,22 +49,33 @@ public class ApplicationTerminatedMessageProcessor extends MessageProcessor {
public boolean process(String type, String message, Object object) {
Topology topology = (Topology) object;
- if (ApplicationInactivatedEvent.class.getName().equals(type)) {
+ if (ApplicationTerminatedEvent.class.getName().equals(type)) {
// Return if topology has not been initialized
if (!topology.isInitialized())
return false;
// Parse complete message and build event
- ApplicationInactivatedEvent event = (ApplicationInactivatedEvent) Util.
- jsonToObject(message, ApplicationInactivatedEvent.class);
+ ApplicationTerminatedEvent event = (ApplicationTerminatedEvent) Util.
+ jsonToObject(message, ApplicationTerminatedEvent.class);
TopologyUpdater.acquireWriteLockForApplication(event.getAppId());
+ Set<ClusterDataHolder> clusterDataHolders = event.getClusterData();
+ if (clusterDataHolders != null) {
+ for (ClusterDataHolder clusterData : clusterDataHolders) {
+ TopologyUpdater.acquireWriteLockForService(clusterData.getServiceType());
+ }
+ }
try {
return doProcess(event, topology);
} finally {
TopologyUpdater.releaseWriteLockForApplication(event.getAppId());
+ if (clusterDataHolders != null) {
+ for (ClusterDataHolder clusterData : clusterDataHolders) {
+ TopologyUpdater.releaseWriteLockForService(clusterData.getServiceType());
+ }
+ }
}
} else {
@@ -76,27 +88,47 @@ public class ApplicationTerminatedMessageProcessor extends MessageProcessor {
}
}
- private boolean doProcess (ApplicationInactivatedEvent event, Topology topology) {
+ private boolean doProcess (ApplicationTerminatedEvent event, Topology topology) {
- // Validate event against the existing topology
- Application application = topology.getApplication(event.getAppId());
- if (application == null) {
- if (log.isWarnEnabled()) {
- log.warn(String.format("Application does not exist: [service] %s",
- event.getAppId()));
- }
- return false;
- } else {
- // Apply changes to the topology
- if (!application.isStateTransitionValid(ApplicationStatus.Terminated)) {
- log.error("Invalid State transfer from [ " + application.getStatus() +
- " ] to [ " + ApplicationStatus.Terminated + " ]");
+ // check if required properties are available
+ if (event.getAppId() == null) {
+ String errorMsg = "Application Id of application removed event is invalid";
+ log.error(errorMsg);
+ throw new RuntimeException(errorMsg);
+ }
+
+ if (event.getTenantDomain()== null) {
+ String errorMsg = "Application tenant domain of application removed event is invalid";
+ log.error(errorMsg);
+ throw new RuntimeException(errorMsg);
+ }
+
+ // check if an Application with same name exists in topology
+ String appId = event.getAppId();
+ if (topology.applicationExists(appId)) {
+ log.warn("Application with id [ " + appId + " ] still exists in Topology, removing it");
+ topology.removeApplication(appId);
+ }
+
+ if (event.getClusterData() != null) {
+ // remove the Clusters from the Topology
+ for (ClusterDataHolder clusterData : event.getClusterData()) {
+ Service service = topology.getService(clusterData.getServiceType());
+ if (service != null) {
+ service.removeCluster(clusterData.getClusterId());
+ if (log.isDebugEnabled()) {
+ log.debug("Removed the Cluster " + clusterData.getClusterId() + " from Topology");
+ }
+ } else {
+ log.warn("Service " + clusterData.getServiceType() + " not found in Topology!");
+ }
}
- application.setStatus(ApplicationStatus.Terminated);
+ }
+ if (log.isDebugEnabled()) {
+ log.debug("ApplicationRemovedMessageProcessor notifying listener ");
}
- // Notify event listeners
notifyEventListeners(event);
return true;
http://git-wip-us.apache.org/repos/asf/stratos/blob/b56e3285/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/TopologyMessageProcessorChain.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/TopologyMessageProcessorChain.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/TopologyMessageProcessorChain.java
index 1b7ba13..4f6d3a9 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/TopologyMessageProcessorChain.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/TopologyMessageProcessorChain.java
@@ -50,7 +50,6 @@ public class TopologyMessageProcessorChain extends MessageProcessorChain {
private GroupInActivateProcessor groupInActivateProcessor;
private ApplicationCreatedMessageProcessor applicationCreatedMessageProcessor;
private ApplicationUndeployedMessageProcessor applicationUndeployedMessageProcessor;
- private ApplicationRemovedMessageProcessor applicationRemovedMessageProcessor;
private ApplicationActivatedMessageProcessor applicationActivatedMessageProcessor;
private ApplicationInactivatedMessageProcessor applicationInactivatedMessageProcessor;
private ApplicationTerminatedMessageProcessor applicationTerminatedMessageProcessor;
@@ -128,9 +127,6 @@ public class TopologyMessageProcessorChain extends MessageProcessorChain {
applicationUndeployedMessageProcessor = new ApplicationUndeployedMessageProcessor();
add(applicationUndeployedMessageProcessor);
- applicationRemovedMessageProcessor = new ApplicationRemovedMessageProcessor();
- add(applicationRemovedMessageProcessor);
-
applicationActivatedMessageProcessor = new ApplicationActivatedMessageProcessor();
add(applicationActivatedMessageProcessor);
@@ -193,8 +189,6 @@ public class TopologyMessageProcessorChain extends MessageProcessorChain {
applicationCreatedMessageProcessor.addEventListener(eventListener);
} else if (eventListener instanceof ApplicationUndeployedEventListener) {
applicationUndeployedMessageProcessor.addEventListener(eventListener);
- } else if (eventListener instanceof ApplicationRemovedEventListener) {
- applicationRemovedMessageProcessor.addEventListener(eventListener);
} else if (eventListener instanceof ApplicationActivatedEventListener) {
applicationActivatedMessageProcessor.addEventListener(eventListener);
} else if (eventListener instanceof ApplicationInActivateEventListener){
[41/50] [abbrv] git commit: implementing onParentEvent method in
ClusterMonitor
Posted by im...@apache.org.
implementing onParentEvent method in ClusterMonitor
Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/e2994c4f
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/e2994c4f
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/e2994c4f
Branch: refs/heads/docker-grouping-merge
Commit: e2994c4ff22053162922fb9cba0415b55fb5b04d
Parents: caa6f1b
Author: Isuru Haththotuwa <is...@apache.org>
Authored: Wed Oct 29 16:23:22 2014 +0530
Committer: Isuru Haththotuwa <is...@apache.org>
Committed: Wed Oct 29 16:23:22 2014 +0530
----------------------------------------------------------------------
.../stratos/autoscaler/monitor/cluster/ClusterMonitor.java | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/stratos/blob/e2994c4f/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 b9f6cbf..6d7e8ca 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
@@ -25,6 +25,7 @@ import org.apache.stratos.autoscaler.PartitionContext;
import org.apache.stratos.autoscaler.client.cloud.controller.CloudControllerClient;
import org.apache.stratos.autoscaler.deployment.policy.DeploymentPolicy;
import org.apache.stratos.autoscaler.exception.TerminationException;
+import org.apache.stratos.autoscaler.grouping.topic.StatusEventPublisher;
import org.apache.stratos.autoscaler.monitor.AbstractClusterMonitor;
import org.apache.stratos.autoscaler.monitor.events.MonitorStatusEvent;
import org.apache.stratos.autoscaler.policy.model.AutoscalePolicy;
@@ -32,7 +33,9 @@ import org.apache.stratos.autoscaler.rule.AutoscalerRuleEvaluator;
import org.apache.stratos.cloud.controller.stub.pojo.MemberContext;
import org.apache.stratos.cloud.controller.stub.pojo.Properties;
import org.apache.stratos.cloud.controller.stub.pojo.Property;
+import org.apache.stratos.messaging.domain.topology.ApplicationStatus;
import org.apache.stratos.messaging.domain.topology.ClusterStatus;
+import org.apache.stratos.messaging.domain.topology.GroupStatus;
import java.util.ArrayList;
import java.util.List;
@@ -281,6 +284,10 @@ public class ClusterMonitor extends AbstractClusterMonitor {
@Override
public void onParentEvent(MonitorStatusEvent statusEvent) {
- // doesn't have to do anything since this is not a Parent Monitor
+ // send the ClusterTerminating event
+ if (statusEvent.getStatus() == GroupStatus.Terminating || statusEvent.getStatus() ==
+ ApplicationStatus.Terminating) {
+ StatusEventPublisher.sendClusterTerminatingEvent(appId, serviceId, clusterId);
+ }
}
}
[44/50] [abbrv] git commit: stopping notifying parent in Cluster
Monitor and Group Monitor if its in Terminating state
Posted by im...@apache.org.
stopping notifying parent in Cluster Monitor and Group Monitor if its in Terminating state
Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/08d68656
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/08d68656
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/08d68656
Branch: refs/heads/docker-grouping-merge
Commit: 08d68656f4b81704996761dc4615973f901bfcbc
Parents: b51b0b7
Author: Isuru Haththotuwa <is...@apache.org>
Authored: Wed Oct 29 17:53:05 2014 +0530
Committer: Isuru Haththotuwa <is...@apache.org>
Committed: Wed Oct 29 17:53:15 2014 +0530
----------------------------------------------------------------------
.../stratos/autoscaler/monitor/AbstractClusterMonitor.java | 6 ++++++
.../apache/stratos/autoscaler/monitor/group/GroupMonitor.java | 6 ++++++
2 files changed, 12 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/stratos/blob/08d68656/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/AbstractClusterMonitor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/AbstractClusterMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/AbstractClusterMonitor.java
index 1eda837..da4cba8 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/AbstractClusterMonitor.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/AbstractClusterMonitor.java
@@ -240,6 +240,12 @@ abstract public class AbstractClusterMonitor extends Monitor implements Runnable
if (status == ClusterStatus.Inactive && !this.hasDependent) {
log.info("[Cluster] " + clusterId + "is not notifying the parent, " +
"since it is identified as the independent unit");
+
+ } else if (status == ClusterStatus.Terminating) {
+ // notify parent
+ log.info("[Cluster] " + clusterId + " is not notifying the parent, " +
+ "since it is in Terminating State");
+
} else {
MonitorStatusEventBuilder.handleClusterStatusEvent(this.parent, this.status, this.clusterId);
}
http://git-wip-us.apache.org/repos/asf/stratos/blob/08d68656/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java
index 55f3b4e..0f213a9 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java
@@ -152,7 +152,13 @@ public class GroupMonitor extends ParentComponentMonitor implements EventHandler
if (status == GroupStatus.Inactive && !this.hasDependent) {
log.info("[Group] " + this.id + "is not notifying the parent, " +
"since it is identified as the independent unit");
+
+ } else if (status == GroupStatus.Terminating) {
+ log.info("[Group] " + this.id + " is not notifying the parent, " +
+ "since it is in Terminating State");
+
} else {
+ // notify parent
MonitorStatusEventBuilder.handleGroupStatusEvent(this.parent, this.status, this.id);
}
//}
[02/50] [abbrv] git commit: removing unwanted event
ApplicationUndeployed from the flow
Posted by im...@apache.org.
removing unwanted event ApplicationUndeployed from the flow
Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/87d77a2d
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/87d77a2d
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/87d77a2d
Branch: refs/heads/docker-grouping-merge
Commit: 87d77a2dfa8d9ac9ca0f53f119fcabdedffb4159
Parents: 6f7baa8
Author: Isuru Haththotuwa <is...@apache.org>
Authored: Fri Oct 24 17:42:37 2014 +0530
Committer: Isuru Haththotuwa <is...@apache.org>
Committed: Sun Oct 26 21:54:59 2014 +0530
----------------------------------------------------------------------
.../AutoscalerTopologyEventReceiver.java | 85 ++++++++++++++++---
.../controller/topology/TopologyBuilder.java | 88 ++++++++++++++++----
.../topology/ApplicationTerminatingEvent.java | 13 ++-
3 files changed, 159 insertions(+), 27 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/stratos/blob/87d77a2d/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 63f9079..2f7cca4 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
@@ -38,6 +38,11 @@ import org.apache.stratos.autoscaler.status.checker.StatusChecker;
import org.apache.stratos.messaging.domain.topology.*;
import org.apache.stratos.messaging.event.Event;
import org.apache.stratos.messaging.event.topology.*;
+import org.apache.stratos.messaging.event.topology.ApplicationActivatedEvent;
+import org.apache.stratos.messaging.event.topology.ApplicationCreatedEvent;
+import org.apache.stratos.messaging.event.topology.ClusterActivatedEvent;
+import org.apache.stratos.messaging.event.topology.ClusterInActivateEvent;
+import org.apache.stratos.messaging.event.topology.GroupActivatedEvent;
import org.apache.stratos.messaging.listener.topology.*;
import org.apache.stratos.messaging.message.receiver.topology.TopologyEventReceiver;
import org.apache.stratos.messaging.message.receiver.topology.TopologyManager;
@@ -323,17 +328,78 @@ public class AutoscalerTopologyEventReceiver implements Runnable {
}
});
- topologyEventReceiver.addEventListener(new ApplicationUndeployedEventListener() {
+// topologyEventReceiver.addEventListener(new ApplicationUndeployedEventListener() {
+// @Override
+// protected void onEvent(Event event) {
+//
+// log.info("[ApplicationUndeployedEvent] Received: " + event.getClass());
+//
+// 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());
+//
+// for (String clusterId : clusters) {
+// //stopping the cluster monitor and remove it from the AS
+// ClusterMonitor clusterMonitor =
+// ((ClusterMonitor) AutoscalerContext.getInstance().getMonitor(clusterId));
+// if (clusterMonitor != null) {
+// clusterMonitor.setDestroyed(true);
+// clusterMonitor.terminateAllMembers();
+// clusterMonitor.setStatus(ClusterStatus.Terminating);
+// } else {
+// log.warn("No Cluster Monitor found for cluster id " + clusterId);
+// }
+// }
+//
+// } else {
+// log.warn("Application Monitor cannot be found for the undeployed [application] "
+// + applicationUndeployedEvent.getApplicationId());
+// }
+//
+// } finally {
+// if (clusterDataHolders != null) {
+// for (ClusterDataHolder clusterData : clusterDataHolders) {
+// TopologyManager.releaseReadLockForCluster(clusterData.getServiceType(),
+// clusterData.getClusterId());
+// }
+// }
+// TopologyManager.
+// releaseReadLockForApplication(applicationUndeployedEvent.getApplicationId());
+// }
+// }
+// });
+
+
+ topologyEventReceiver.addEventListener(new ApplicationTerminatingEventListener() {
@Override
protected void onEvent(Event event) {
- log.info("[ApplicationUndeployedEvent] Received: " + event.getClass());
+ log.info("[ApplicationTerminatingEvent] Received: " + event.getClass());
- ApplicationUndeployedEvent applicationUndeployedEvent = (ApplicationUndeployedEvent) event;
+ ApplicationTerminatingEvent appTerminatingEvent = (ApplicationTerminatingEvent) event;
// acquire reead locks for application and relevant clusters
- TopologyManager.acquireReadLockForApplication(applicationUndeployedEvent.getApplicationId());
- Set<ClusterDataHolder> clusterDataHolders = applicationUndeployedEvent.getClusterData();
+ TopologyManager.acquireReadLockForApplication(appTerminatingEvent.getAppId());
+ Set<ClusterDataHolder> clusterDataHolders = appTerminatingEvent.getClusterData();
if (clusterDataHolders != null) {
for (ClusterDataHolder clusterData : clusterDataHolders) {
TopologyManager.acquireReadLockForCluster(clusterData.getServiceType(),
@@ -343,14 +409,14 @@ public class AutoscalerTopologyEventReceiver implements Runnable {
try {
ApplicationMonitor appMonitor = AutoscalerContext.getInstance().
- getAppMonitor(applicationUndeployedEvent.getApplicationId());
+ getAppMonitor(appTerminatingEvent.getAppId());
if (appMonitor != null) {
// update the status as Terminating
appMonitor.setStatus(ApplicationStatus.Terminating);
List<String> clusters = appMonitor.
- findClustersOfApplication(applicationUndeployedEvent.getApplicationId());
+ findClustersOfApplication(appTerminatingEvent.getAppId());
for (String clusterId : clusters) {
//stopping the cluster monitor and remove it from the AS
@@ -367,7 +433,7 @@ public class AutoscalerTopologyEventReceiver implements Runnable {
} else {
log.warn("Application Monitor cannot be found for the undeployed [application] "
- + applicationUndeployedEvent.getApplicationId());
+ + appTerminatingEvent.getAppId());
}
} finally {
@@ -378,12 +444,11 @@ public class AutoscalerTopologyEventReceiver implements Runnable {
}
}
TopologyManager.
- releaseReadLockForApplication(applicationUndeployedEvent.getApplicationId());
+ releaseReadLockForApplication(appTerminatingEvent.getAppId());
}
}
});
-
topologyEventReceiver.addEventListener(new ApplicationRemovedEventListener() {
@Override
protected void onEvent(Event event) {
http://git-wip-us.apache.org/repos/asf/stratos/blob/87d77a2d/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java
index 80315ea..d245a6f 100644
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java
@@ -933,29 +933,85 @@ public class TopologyBuilder {
}
public static void handleApplicationTerminatingEvent(ApplicationTerminatingEvent event) {
- Topology topology = TopologyManager.getTopology();
- Application application = topology.getApplication(event.getAppId());
- //update the status of the Group
- if (application == null) {
- log.warn(String.format("Application %s does not exist",
- event.getAppId()));
- return;
- }
- org.apache.stratos.messaging.event.topology.ApplicationTerminatingEvent applicationTerminatingEvent =
- new org.apache.stratos.messaging.event.topology.ApplicationTerminatingEvent(
- event.getAppId());
+ Set<ClusterDataHolder> clusterData;
+ String applicationId = event.getAppId();
+
+ // update the Application and Cluster Statuses as 'Terminating'
+ TopologyManager.acquireWriteLock();
+
try {
- TopologyManager.acquireWriteLock();
+
+ Topology topology = TopologyManager.getTopology();
+
+ if (!topology.applicationExists(applicationId)) {
+ log.warn("Application with id [ " + applicationId + " ] doesn't exist in Topology");
+ return;
+ }
+
+ Application application = topology.getApplication(applicationId);
+ // check and update application status to 'Terminating'
+ if (!application.isStateTransitionValid(ApplicationStatus.Terminating)) {
+ log.error("Invalid state transfer from " + application.getStatus() + " to " + ApplicationStatus.Terminating);
+ }
+ // for now anyway update the status forcefully
application.setStatus(ApplicationStatus.Terminating);
- log.info("Application terminating adding status started for Topology");
+ log.info("Application " + applicationId + "'s status updated to " + ApplicationStatus.Terminating);
+
+ // update all the Clusters' statuses to 'Terminating'
+ clusterData = application.getClusterDataRecursively();
+ for (ClusterDataHolder clusterDataHolder : clusterData) {
+ Service service = topology.getService(clusterDataHolder.getServiceType());
+ if (service != null) {
+ Cluster aCluster = service.getCluster(clusterDataHolder.getClusterId());
+ if (aCluster != null) {
+ // validate state transition
+ if (!aCluster.isStateTransitionValid(ClusterStatus.Terminating)) {
+ log.error("Invalid state transfer from " + aCluster.getStatus() + " to "
+ + ClusterStatus.Terminating);
+ }
+ // for now anyway update the status forcefully
+ aCluster.setStatus(ClusterStatus.Terminating);
+
+ } else {
+ log.warn("Unable to find Cluster with cluster id " + clusterDataHolder.getClusterId() +
+ " in Topology");
+ }
+
+ } else {
+ log.warn("Unable to update cluster with cluster id: " + clusterDataHolder.getClusterId() + " from Topology, " +
+ " associated Service [ " + clusterDataHolder.getServiceType() + " ] not found");
+ }
+ }
+
+ // update all Group's statuses to 'Terminating'
+ if (application.getGroups() != null) {
+ updateGroupStatusesRecursively(GroupStatus.Terminating, application.getGroups());
+ }
- TopologyManager.updateTopology(topology);
} finally {
TopologyManager.releaseWriteLock();
}
- //publishing data
- TopologyEventPublisher.sendApplicationTerminatingEvent(applicationTerminatingEvent);
+
+ TopologyEventPublisher.sendApplicationTerminatingEvent(
+ new org.apache.stratos.messaging.event.topology.ApplicationTerminatingEvent(
+ applicationId, clusterData));
+ }
+
+ private static void updateGroupStatusesRecursively (GroupStatus groupStatus, Collection<Group> groups) {
+
+ for (Group group : groups) {
+ if (!group.isStateTransitionValid(groupStatus)) {
+ log.error("Invalid state transfer from " + group.getStatus() + " to " + groupStatus);
+ }
+ // force update for now
+ group.setStatus(groupStatus);
+
+ // go recursively and update
+ if (group.getGroups() != null) {
+ updateGroupStatusesRecursively(groupStatus, group.getGroups());
+ }
+ }
}
public static void handleApplicationTerminatedEvent(ApplicationTerminatedEvent event) {
http://git-wip-us.apache.org/repos/asf/stratos/blob/87d77a2d/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ApplicationTerminatingEvent.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ApplicationTerminatingEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ApplicationTerminatingEvent.java
index e1fbc02..c718f08 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ApplicationTerminatingEvent.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ApplicationTerminatingEvent.java
@@ -18,17 +18,28 @@
*/
package org.apache.stratos.messaging.event.topology;
+import org.apache.stratos.messaging.domain.topology.ClusterDataHolder;
+
+import java.util.Set;
+
/**
* This event will be sent to Topology upon terminating of application
*/
public class ApplicationTerminatingEvent extends TopologyEvent {
+
private final String appId;
+ private Set<ClusterDataHolder> clusterData;
- public ApplicationTerminatingEvent(String appId) {
+ public ApplicationTerminatingEvent(String appId, Set<ClusterDataHolder> clusterData) {
this.appId = appId;
+ this.clusterData = clusterData;
}
public String getAppId() {
return appId;
}
+
+ public Set<ClusterDataHolder> getClusterData() {
+ return clusterData;
+ }
}
\ No newline at end of file