You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stratos.apache.org by is...@apache.org on 2014/10/31 11:37:24 UTC
[1/4] git commit: moving application stuff to Autoscaler
Repository: stratos
Updated Branches:
refs/heads/4.0.0-grouping 836b71fd7 -> 226b8709e
moving application stuff to Autoscaler
Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/226b8709
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/226b8709
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/226b8709
Branch: refs/heads/4.0.0-grouping
Commit: 226b8709e09e91c3f2f86eb679d7f1adbb0ce108
Parents: c42d7c1
Author: Isuru Haththotuwa <is...@apache.org>
Authored: Fri Oct 31 16:05:28 2014 +0530
Committer: Isuru Haththotuwa <is...@apache.org>
Committed: Fri Oct 31 16:07:05 2014 +0530
----------------------------------------------------------------------
.../controller/topology/TopologyBuilder.java | 103 -------------------
.../topology/TopologyEventPublisher.java | 12 +--
.../StratosManagerTopologyEventReceiver.java | 13 +--
.../rest/endpoint/services/ServiceUtils.java | 7 +-
4 files changed, 17 insertions(+), 118 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/stratos/blob/226b8709/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 7ee342e..5c25297 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
@@ -655,109 +655,6 @@ public class TopologyBuilder {
}
}
- public static void handleGroupInActiveEvent(AppStatusGroupInactivateEvent 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;
- }
-
- Group group = application.getGroupRecursively(event.getGroupId());
- if (group == null) {
- log.warn(String.format("Group %s does not exist",
- event.getGroupId()));
- return;
- }
-
- org.apache.stratos.messaging.event.topology.GroupInactivateEvent groupInActivateEvent =
- new org.apache.stratos.messaging.event.topology.GroupInactivateEvent(
- event.getAppId(),
- event.getGroupId());
- try {
- TopologyManager.acquireWriteLock();
- group.setStatus(GroupStatus.Inactive);
- log.info("Group in-active adding status started for" + group.getUniqueIdentifier());
-
- TopologyManager.updateTopology(topology);
- } finally {
- TopologyManager.releaseWriteLock();
- }
- //publishing data
- TopologyEventPublisher.sendGroupInActiveEvent(groupInActivateEvent);
- }
-
-
- public static void handleGroupTerminatedEvent(GroupTerminatedEvent 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;
- }
-
- Group group = application.getGroupRecursively(event.getGroupId());
- if (group == null) {
- log.warn(String.format("Group %s does not exist",
- event.getGroupId()));
- return;
- }
-
- org.apache.stratos.messaging.event.topology.GroupTerminatedEvent groupTerminatedTopologyEvent =
- new org.apache.stratos.messaging.event.topology.GroupTerminatedEvent(
- event.getAppId(),
- event.getGroupId());
- try {
- TopologyManager.acquireWriteLock();
- group.setStatus(GroupStatus.Terminated);
- log.info("Group Terminated adding status started for" + group.getUniqueIdentifier());
-
- TopologyManager.updateTopology(topology);
- } finally {
- TopologyManager.releaseWriteLock();
- }
- //publishing data
- TopologyEventPublisher.sendGroupTerminatedEvent(groupTerminatedTopologyEvent);
- }
-
- public static void handleGroupTerminatingEvent(GroupTerminatingEvent 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;
- }
-
- Group group = application.getGroupRecursively(event.getGroupId());
- if (group == null) {
- log.warn(String.format("Group %s does not exist",
- event.getGroupId()));
- return;
- }
-
- org.apache.stratos.messaging.event.topology.GroupTerminatingEvent groupTerminatingTopologyEvent =
- new org.apache.stratos.messaging.event.topology.GroupTerminatingEvent(
- event.getAppId(),
- event.getGroupId());
- try {
- TopologyManager.acquireWriteLock();
- group.setStatus(GroupStatus.Terminating);
- log.info("Group Terminating adding status started for " + group.getUniqueIdentifier());
-
- TopologyManager.updateTopology(topology);
- } finally {
- TopologyManager.releaseWriteLock();
- }
- //publishing data
- TopologyEventPublisher.sendGroupTerminatingEvent(groupTerminatingTopologyEvent);
- }
-
public static void handleClusterTerminatedEvent(ClusterStatusClusterTerminatedEvent event) {
TopologyManager.acquireWriteLock();
http://git-wip-us.apache.org/repos/asf/stratos/blob/226b8709/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 2e0883b..eb1fb7f 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
@@ -78,12 +78,12 @@ public class TopologyEventPublisher {
}
public static void sendClusterCreatedEvent(String appId, String serviceName, String clusterId) {
- ClusterCreatedEvent clusterCreatedEvent = new ClusterCreatedEvent(new Cluster());
-
- if(log.isInfoEnabled()) {
- log.info("Publishing cluster created event: " +clusterId);
- }
- publishEvent(clusterCreatedEvent);
+// ClusterCreatedEvent clusterCreatedEvent = new ClusterCreatedEvent(new Cluster());
+//
+// if(log.isInfoEnabled()) {
+// log.info("Publishing cluster created event: " +clusterId);
+// }
+// publishEvent(clusterCreatedEvent);
}
public static void sendApplicationCreatedEvent (ApplicationCreatedEvent applicationCreatedEvent) {
http://git-wip-us.apache.org/repos/asf/stratos/blob/226b8709/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 a085664..d4446c4 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
@@ -92,21 +92,22 @@ public class StratosManagerTopologyEventReceiver implements Runnable {
ClusterCreatedEvent clustercreatedEvent = (ClusterCreatedEvent) event;
- String serviceType = clustercreatedEvent.getServiceName();
+ String serviceType = clustercreatedEvent.getCluster().getServiceName();
//acquire read lock
//TopologyManager.acquireReadLock();
- TopologyManager.acquireReadLockForCluster(clustercreatedEvent.getServiceName(),
- clustercreatedEvent.getClusterId());
+ TopologyManager.acquireReadLockForCluster(clustercreatedEvent.getCluster().getServiceName(),
+ clustercreatedEvent.getCluster().getClusterId());
try {
- Cluster cluster = TopologyManager.getTopology().getService(serviceType).getCluster(clustercreatedEvent.getClusterId());
+ Cluster cluster = TopologyManager.getTopology().getService(serviceType).
+ getCluster(clustercreatedEvent.getCluster().getClusterId());
TopologyClusterInformationModel.getInstance().addCluster(cluster);
} finally {
//release read lock
//TopologyManager.releaseReadLock();
- TopologyManager.releaseReadLockForCluster(clustercreatedEvent.getServiceName(),
- clustercreatedEvent.getClusterId());
+ TopologyManager.releaseReadLockForCluster(clustercreatedEvent.getCluster().getServiceName(),
+ clustercreatedEvent.getCluster().getClusterId());
}
}
http://git-wip-us.apache.org/repos/asf/stratos/blob/226b8709/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java
----------------------------------------------------------------------
diff --git 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
index 9037f33..2b99f14 100644
--- 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
@@ -54,6 +54,7 @@ import org.apache.stratos.messaging.domain.applications.Application;
import org.apache.stratos.messaging.domain.applications.ClusterDataHolder;
import org.apache.stratos.messaging.domain.applications.Group;
import org.apache.stratos.messaging.domain.topology.*;
+import org.apache.stratos.messaging.message.receiver.applications.ApplicationManager;
import org.apache.stratos.messaging.message.receiver.topology.TopologyManager;
import org.apache.stratos.messaging.util.Constants;
import org.apache.stratos.rest.endpoint.bean.ApplicationBean;
@@ -1449,8 +1450,8 @@ public class ServiceUtils {
public static ApplicationBean getApplicationInfo(String applicationId, ConfigurationContext configContext) {
ApplicationBean applicationBean = null;
try{
- TopologyManager.acquireReadLockForApplication(applicationId);
- Application application = TopologyManager.getTopology().getApplication(applicationId);
+ ApplicationManager.acquireReadLockForApplication(applicationId);
+ Application application = ApplicationManager.getApplications().getApplication(applicationId);
if(application == null){
return null;
}
@@ -1480,7 +1481,7 @@ public class ServiceUtils {
applicationBean.addGroup(groupBean);
}
}finally {
- TopologyManager.releaseReadLockForApplication(applicationId);
+ ApplicationManager.releaseReadLockForApplication(applicationId);
}
[4/4] git commit: removing Application from Topology - I
Posted by is...@apache.org.
removing Application from Topology - I
Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/d4f90be2
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/d4f90be2
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/d4f90be2
Branch: refs/heads/4.0.0-grouping
Commit: d4f90be212976c529b6970c673b4eddf6461e0a4
Parents: 836b71f
Author: Isuru Haththotuwa <is...@apache.org>
Authored: Fri Oct 31 14:55:36 2014 +0530
Committer: Isuru Haththotuwa <is...@apache.org>
Committed: Fri Oct 31 16:07:05 2014 +0530
----------------------------------------------------------------------
.../domain/applications/Applications.java | 13 ++-
.../messaging/domain/topology/Topology.java | 111 -------------------
2 files changed, 11 insertions(+), 113 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/stratos/blob/d4f90be2/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/Applications.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/Applications.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/Applications.java
index 9e8cf3e..e5a7921 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/Applications.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/Applications.java
@@ -21,6 +21,8 @@ package org.apache.stratos.messaging.domain.applications;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.messaging.domain.applications.locking.ApplicationLock;
+import org.apache.stratos.messaging.domain.applications.locking.ApplicationLockHierarchy;
import java.io.Serializable;
import java.util.HashMap;
@@ -38,8 +40,10 @@ public class Applications implements Serializable {
this.applicationMap = new HashMap<String, Application>();
}
- public void addApplication (Application application) {
- this.getApplications().put(application.getUniqueIdentifier(), application);
+ public synchronized void addApplication (Application application) {
+ this.applicationMap.put(application.getUniqueIdentifier(), application);
+ ApplicationLockHierarchy.getInstance().addApplicationLock(application.getUniqueIdentifier(),
+ new ApplicationLock());
}
public Application getApplication (String appId) {
@@ -61,4 +65,9 @@ public class Applications implements Serializable {
public Map<String, Application> getApplications() {
return applicationMap;
}
+
+ public synchronized void removeApplication (String appId) {
+ this.applicationMap.remove(appId);
+ ApplicationLockHierarchy.getInstance().removeLock(appId);
+ }
}
http://git-wip-us.apache.org/repos/asf/stratos/blob/d4f90be2/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 0f128fa..a5780bb 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
@@ -37,42 +37,12 @@ public class Topology implements Serializable {
private static final long serialVersionUID = -2453583548027402122L;
// Key: Service.serviceName
private Map<String, Service> serviceMap;
- //Grouping
- private Map<String, CompositeApplication> compositeApplicationMap;
- // grouping_poc private Map<String, ConfigCompositeApplication> configCompositeApplicationMap;
- // Key: Application.id
- private Map<String, Application> applicationMap;
private boolean initialized;
private static Log log = LogFactory.getLog(Topology.class);
public Topology() {
this.serviceMap = new HashMap<String, Service>();
- this.compositeApplicationMap = new HashMap<String, CompositeApplication>();
- // grouping_poc this.configCompositeApplicationMap = new HashMap<String, ConfigCompositeApplication>();
- this.applicationMap = new HashMap<String, Application>();
- }
-
- public void addApplication (Application application) {
- this.applicationMap.put(application.getUniqueIdentifier(), application);
- TopologyLockHierarchy.getInstance().addApplicationLock(application.getUniqueIdentifier(), new TopologyLock());
- }
-
- public Application getApplication (String applicationId) {
- return applicationMap.get(applicationId);
- }
-
- public void removeApplication (String applicationId) {
- applicationMap.remove(applicationId);
- TopologyLockHierarchy.getInstance().removeTopologyLockForApplication(applicationId);
- }
-
- public Collection<Application> getApplications () {
- return applicationMap.values();
- }
-
- public boolean applicationExists (String applicationId) {
- return this.applicationMap.containsKey(applicationId);
}
public Collection<Service> getServices() {
@@ -111,87 +81,6 @@ public class Topology implements Serializable {
public void clear() {
this.serviceMap.clear();
}
-
- // Grouping
- public Collection<CompositeApplication> getCompositeApplication() {
- return this.compositeApplicationMap.values();
- }
-
- public void addCompositeApplication(String alias, CompositeApplication app) {
- this.compositeApplicationMap.put(alias, app);
- }
-
- public void removeCompositeApplication(String alias) {
- this.compositeApplicationMap.remove(alias);
- }
-
- /* grouping_poc
- public Collection<ConfigCompositeApplication> getConfigCompositeApplication() {
-
- if (this.configCompositeApplicationMap == null) {
- log.info("adding new config comp in topology while retrieving it, ConfigCompositeApplication is null");
- this.configCompositeApplicationMap = new HashMap<String, ConfigCompositeApplication>();
- }
- return this.configCompositeApplicationMap.values();
- }
-
- public void addConfigCompositeApplication(String alias, ConfigCompositeApplication configApp) {
- log.info("adding config comp in topology" + alias + " / " + configApp);
- if (this.configCompositeApplicationMap != null) {
- log.info("adding config comp in topology, ConfigCompositeApplication is not null");
- this.configCompositeApplicationMap.put(alias, configApp);
- log.info("successful config comp in topology, ConfigCompositeApplication is not null");
- } else {
- log.info("adding config comp in topology, ConfigCompositeApplication is null, adding one");
- this.configCompositeApplicationMap = new HashMap<String, ConfigCompositeApplication>();
- this.configCompositeApplicationMap.put(alias, configApp);
- }
- }
-
- public void removeConfigCompositeApplication(String alias) {
- this.configCompositeApplicationMap.remove(alias);
- }
-
- public void removeAllCompositeApplication() {
- java.util.Set<String> keys = this.compositeApplicationMap.keySet();
- for (String key : keys) {
- compositeApplicationMap.remove(key);
- }
- }
-
- public void removeAllConfigCompositeApplication() {
- java.util.Set<String> keys = this.configCompositeApplicationMap.keySet();
- for (String key : keys) {
- configCompositeApplicationMap.remove(key);
- }
- }
-
- public CompositeApplication getCompositeApplication(String appAlias) {
- return this.compositeApplicationMap.get(appAlias);
- }
-
- public boolean compositeApplicationExists(String appAlias) {
- return this.compositeApplicationMap.containsKey(appAlias);
- }
-
- public ConfigCompositeApplication getConfigCompositeApplication(String appAlias) {
- return this.configCompositeApplicationMap.get(appAlias);
- }
-
- public boolean configCompositeApplicationExists(String appAlias) {
- return this.configCompositeApplicationMap.containsKey(appAlias);
- }
-
-
- public Map<String, ConfigCompositeApplication> getConfigCompositeApplicationMap() {
- return configCompositeApplicationMap;
- }
-
- public void setConfigCompositeApplicationMap(Map<String, ConfigCompositeApplication> configCompositeApplicationMap) {
- this.configCompositeApplicationMap = configCompositeApplicationMap;
- }
-
- */
public void setInitialized(boolean initialized) {
this.initialized = initialized;
[3/4] git commit: moving applications stuff to autoscaler - II
Posted by is...@apache.org.
moving applications stuff to autoscaler - II
Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/c42d7c1d
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/c42d7c1d
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/c42d7c1d
Branch: refs/heads/4.0.0-grouping
Commit: c42d7c1dc232256e4bbb7a10bda7e8f110ddb795
Parents: d4f90be
Author: Isuru Haththotuwa <is...@apache.org>
Authored: Fri Oct 31 15:55:27 2014 +0530
Committer: Isuru Haththotuwa <is...@apache.org>
Committed: Fri Oct 31 16:07:05 2014 +0530
----------------------------------------------------------------------
.../topic/ApplicationsEventPublisher.java | 56 ++++-----
.../AutoscalerTopologyEventReceiver.java | 7 +-
.../monitor/ApplicationMonitorFactory.java | 13 +-
.../status/checker/StatusChecker.java | 21 ++--
.../topology/TopologyEventPublisher.java | 2 +-
.../domain/applications/Applications.java | 2 +-
.../locking/ApplicationLockHierarchy.java | 4 +-
.../topology/locking/TopologyLockHierarchy.java | 42 -------
.../ApplicationActivatedMessageProcessor.java | 24 ++--
.../ApplicationCreatedMessageProcessor.java | 18 ++-
.../ApplicationInactivatedMessageProcessor.java | 24 ++--
.../ApplicationTerminatedMessageProcessor.java | 43 +++----
.../ApplicationTerminatingMessageProcessor.java | 24 ++--
.../ApplicationUndeployedMessageProcessor.java | 61 +++++-----
.../CompleteApplicationsMessageProcessor.java | 17 +--
.../applications/GroupActivatedProcessor.java | 20 ++--
.../applications/GroupCreatedProcessor.java | 24 ++--
.../applications/GroupInActivateProcessor.java | 22 ++--
.../applications/GroupTerminatedProcessor.java | 24 ++--
.../applications/GroupTerminatingProcessor.java | 24 ++--
.../updater/ApplicationsUpdater.java | 23 ++--
.../CompleteTopologyMessageProcessor.java | 15 ---
.../topology/updater/TopologyUpdater.java | 68 +----------
.../applications/ApplicationManager.java | 119 +++++++++++++++++++
.../receiver/topology/TopologyManager.java | 67 +----------
25 files changed, 351 insertions(+), 413 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/stratos/blob/c42d7c1d/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/topic/ApplicationsEventPublisher.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/topic/ApplicationsEventPublisher.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/topic/ApplicationsEventPublisher.java
index f8d989f..bdbffc0 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/topic/ApplicationsEventPublisher.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/topic/ApplicationsEventPublisher.java
@@ -7,7 +7,7 @@ import org.apache.stratos.messaging.broker.publish.EventPublisherPool;
import org.apache.stratos.messaging.domain.applications.*;
import org.apache.stratos.messaging.event.Event;
import org.apache.stratos.messaging.event.applications.*;
-import org.apache.stratos.messaging.message.receiver.topology.TopologyManager;
+import org.apache.stratos.messaging.message.receiver.applications.ApplicationManager;
import org.apache.stratos.messaging.util.Constants;
import java.util.Set;
@@ -21,8 +21,8 @@ public class ApplicationsEventPublisher {
public static void sendGroupCreatedEvent(String appId, String groupId) {
try {
- TopologyManager.acquireReadLockForApplication(appId);
- Application application = TopologyManager.getTopology().getApplication(appId);
+ ApplicationManager.acquireReadLockForApplication(appId);
+ Application application = ApplicationManager.getApplications().getApplication(appId);
if (application != null) {
Group group = application.getGroupRecursively(groupId);
if (group.isStateTransitionValid(GroupStatus.Created)) {
@@ -39,14 +39,14 @@ public class ApplicationsEventPublisher {
}
}
} finally {
- TopologyManager.releaseReadLockForApplication(appId);
+ ApplicationManager.releaseReadLockForApplication(appId);
}
}
public static void sendGroupActivatedEvent(String appId, String groupId) {
try {
- TopologyManager.acquireReadLockForApplication(appId);
- Application application = TopologyManager.getTopology().getApplication(appId);
+ ApplicationManager.acquireReadLockForApplication(appId);
+ Application application = ApplicationManager.getApplications().getApplication(appId);
if (application != null) {
Group group = application.getGroupRecursively(groupId);
if (group.isStateTransitionValid(GroupStatus.Active)) {
@@ -63,14 +63,14 @@ public class ApplicationsEventPublisher {
}
}
} finally {
- TopologyManager.releaseReadLockForApplication(appId);
+ ApplicationManager.releaseReadLockForApplication(appId);
}
}
public static void sendGroupInActivateEvent(String appId, String groupId) {
try {
- TopologyManager.acquireReadLockForApplication(appId);
- Application application = TopologyManager.getTopology().getApplication(appId);
+ ApplicationManager.acquireReadLockForApplication(appId);
+ Application application = ApplicationManager.getApplications().getApplication(appId);
if (application != null) {
Group group = application.getGroupRecursively(groupId);
if (group.isStateTransitionValid(GroupStatus.Inactive)) {
@@ -87,14 +87,14 @@ public class ApplicationsEventPublisher {
}
}
} finally {
- TopologyManager.releaseReadLockForApplication(appId);
+ ApplicationManager.releaseReadLockForApplication(appId);
}
}
public static void sendGroupTerminatingEvent(String appId, String groupId) {
try {
- TopologyManager.acquireReadLockForApplication(appId);
- Application application = TopologyManager.getTopology().getApplication(appId);
+ ApplicationManager.acquireReadLockForApplication(appId);
+ Application application = ApplicationManager.getApplications().getApplication(appId);
if (application != null) {
Group group = application.getGroupRecursively(groupId);
if (group.isStateTransitionValid(GroupStatus.Terminating)) {
@@ -110,7 +110,7 @@ public class ApplicationsEventPublisher {
}
}
} finally {
- TopologyManager.releaseReadLockForApplication(appId);
+ ApplicationManager.releaseReadLockForApplication(appId);
}
}
@@ -122,8 +122,8 @@ public class ApplicationsEventPublisher {
}
try {
- TopologyManager.acquireReadLockForApplication(appId);
- Application application = TopologyManager.getTopology().getApplication(appId);
+ ApplicationManager.acquireReadLockForApplication(appId);
+ Application application = ApplicationManager.getApplications().getApplication(appId);
if (application != null) {
Group group = application.getGroupRecursively(groupId);
if (group.isStateTransitionValid(GroupStatus.Terminated)) {
@@ -135,7 +135,7 @@ public class ApplicationsEventPublisher {
}
}
} finally {
- TopologyManager.releaseReadLockForApplication(appId);
+ ApplicationManager.releaseReadLockForApplication(appId);
}
@@ -143,8 +143,8 @@ public class ApplicationsEventPublisher {
public static void sendApplicationActivatedEvent(String appId) {
try {
- TopologyManager.acquireReadLockForApplication(appId);
- Application application = TopologyManager.getTopology().getApplication(appId);
+ ApplicationManager.acquireReadLockForApplication(appId);
+ Application application = ApplicationManager.getApplications().getApplication(appId);
if (application != null) {
if (application.isStateTransitionValid(ApplicationStatus.Active)) {
if (log.isInfoEnabled()) {
@@ -159,7 +159,7 @@ public class ApplicationsEventPublisher {
}
}
} finally {
- TopologyManager.releaseReadLockForApplication(appId);
+ ApplicationManager.releaseReadLockForApplication(appId);
}
}
@@ -169,8 +169,8 @@ public class ApplicationsEventPublisher {
}
try {
- TopologyManager.acquireReadLockForApplication(appId);
- Application application = TopologyManager.getTopology().getApplication(appId);
+ ApplicationManager.acquireReadLockForApplication(appId);
+ Application application = ApplicationManager.getApplications().getApplication(appId);
if (application != null) {
if (application.isStateTransitionValid(ApplicationStatus.Inactive)) {
ApplicationInactivatedEvent applicationInActivatedEvent =
@@ -181,14 +181,14 @@ public class ApplicationsEventPublisher {
}
}
} finally {
- TopologyManager.releaseReadLockForApplication(appId);
+ ApplicationManager.releaseReadLockForApplication(appId);
}
}
public static void sendApplicationTerminatingEvent(String appId) {
try {
- TopologyManager.acquireReadLockForApplication(appId);
- Application application = TopologyManager.getTopology().getApplication(appId);
+ ApplicationManager.acquireReadLockForApplication(appId);
+ Application application = ApplicationManager.getApplications().getApplication(appId);
if (application != null) {
if (application.isStateTransitionValid(ApplicationStatus.Terminating)) {
if (log.isInfoEnabled()) {
@@ -202,14 +202,14 @@ public class ApplicationsEventPublisher {
}
}
} finally {
- TopologyManager.releaseReadLockForApplication(appId);
+ ApplicationManager.releaseReadLockForApplication(appId);
}
}
public static void sendApplicationTerminatedEvent(String appId, Set<ClusterDataHolder> clusterData) {
try {
- TopologyManager.acquireReadLockForApplication(appId);
- Application application = TopologyManager.getTopology().getApplication(appId);
+ ApplicationManager.acquireReadLockForApplication(appId);
+ Application application = ApplicationManager.getApplications().getApplication(appId);
if (application != null) {
if (application.isStateTransitionValid(ApplicationStatus.Terminated)) {
if (log.isInfoEnabled()) {
@@ -223,7 +223,7 @@ public class ApplicationsEventPublisher {
}
}
} finally {
- TopologyManager.releaseReadLockForApplication(appId);
+ ApplicationManager.releaseReadLockForApplication(appId);
}
}
http://git-wip-us.apache.org/repos/asf/stratos/blob/c42d7c1d/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 18929ed..dcf3a82 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
@@ -45,6 +45,7 @@ import org.apache.stratos.messaging.event.Event;
import org.apache.stratos.messaging.event.topology.*;
import org.apache.stratos.messaging.listener.applications.ApplicationUndeployedEventListener;
import org.apache.stratos.messaging.listener.topology.*;
+import org.apache.stratos.messaging.message.receiver.applications.ApplicationManager;
import org.apache.stratos.messaging.message.receiver.topology.TopologyEventReceiver;
import org.apache.stratos.messaging.message.receiver.topology.TopologyManager;
@@ -103,7 +104,7 @@ public class AutoscalerTopologyEventReceiver implements Runnable {
TopologyManager.acquireReadLock();
try {
- for (Application application : TopologyManager.getTopology().getApplications()) {
+ for (Application application : ApplicationManager.getApplications().getApplications().values()) {
startApplicationMonitor(application.getUniqueIdentifier());
}
@@ -172,8 +173,8 @@ public class AutoscalerTopologyEventReceiver implements Runnable {
log.info("[ClusterCreatedEvent] Received: " + event.getClass());
- ClusterResetEvent clusterCreatedEvent = (ClusterResetEvent) event;
- String clusterId = clusterCreatedEvent.getClusterId();
+ ClusterCreatedEvent clusterCreatedEvent = (ClusterCreatedEvent) event;
+ String clusterId = clusterCreatedEvent.getCluster().getClusterId();
AbstractClusterMonitor clusterMonitor =
(AbstractClusterMonitor) AutoscalerContext.getInstance().getMonitor(clusterId);
http://git-wip-us.apache.org/repos/asf/stratos/blob/c42d7c1d/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 1e64d78..f693310 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
@@ -47,6 +47,7 @@ import org.apache.stratos.cloud.controller.stub.pojo.Property;
import org.apache.stratos.messaging.domain.applications.Application;
import org.apache.stratos.messaging.domain.applications.Group;
import org.apache.stratos.messaging.domain.topology.*;
+import org.apache.stratos.messaging.message.receiver.applications.ApplicationManager;
import org.apache.stratos.messaging.message.receiver.topology.TopologyManager;
import org.apache.stratos.messaging.util.Constants;
@@ -102,10 +103,10 @@ public class ApplicationMonitorFactory {
throws DependencyBuilderException,
TopologyInConsistentException {
GroupMonitor groupMonitor;
- TopologyManager.acquireReadLockForApplication(appId);
+ ApplicationManager.acquireReadLockForApplication(appId);
try {
- Group group = TopologyManager.getTopology().getApplication(appId).getGroupRecursively(context.getId());
+ Group group = ApplicationManager.getApplications().getApplication(appId).getGroupRecursively(context.getId());
groupMonitor = new GroupMonitor(group, appId);
groupMonitor.setAppId(appId);
if(parentMonitor != null) {
@@ -126,7 +127,7 @@ public class ApplicationMonitorFactory {
}
} finally {
- TopologyManager.releaseReadLockForApplication(appId);
+ ApplicationManager.releaseReadLockForApplication(appId);
}
return groupMonitor;
@@ -146,9 +147,9 @@ public class ApplicationMonitorFactory {
throws DependencyBuilderException,
TopologyInConsistentException {
ApplicationMonitor applicationMonitor;
- TopologyManager.acquireReadLockForApplication(appId);
+ ApplicationManager.acquireReadLockForApplication(appId);
try {
- Application application = TopologyManager.getTopology().getApplication(appId);
+ Application application = ApplicationManager.getApplications().getApplication(appId);
if (application != null) {
applicationMonitor = new ApplicationMonitor(application);
applicationMonitor.setHasDependent(false);
@@ -158,7 +159,7 @@ public class ApplicationMonitorFactory {
throw new TopologyInConsistentException(msg);
}
} finally {
- TopologyManager.releaseReadLockForApplication(appId);
+ ApplicationManager.releaseReadLockForApplication(appId);
}
return applicationMonitor;
http://git-wip-us.apache.org/repos/asf/stratos/blob/c42d7c1d/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 eafa269..5468f6d 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
@@ -30,6 +30,7 @@ import org.apache.stratos.autoscaler.monitor.AbstractClusterMonitor;
import org.apache.stratos.autoscaler.monitor.cluster.ClusterMonitor;
import org.apache.stratos.messaging.domain.applications.*;
import org.apache.stratos.messaging.domain.topology.*;
+import org.apache.stratos.messaging.message.receiver.applications.ApplicationManager;
import org.apache.stratos.messaging.message.receiver.topology.TopologyManager;
import java.util.Map;
@@ -98,8 +99,8 @@ public class StatusChecker {
if (cluster != null) {
try {
- TopologyManager.acquireReadLockForApplication(appId);
- Application application = TopologyManager.getTopology().getApplication(appId);
+ ApplicationManager.acquireReadLockForApplication(appId);
+ Application application = ApplicationManager.getApplications().getApplication(appId);
if (!clusterMonitorHasMembers && cluster.getStatus() == ClusterStatus.Terminating) {
if (application.getStatus() == ApplicationStatus.Terminating) {
@@ -123,7 +124,7 @@ public class StatusChecker {
}*/
}
} finally {
- TopologyManager.releaseReadLockForApplication(appId);
+ ApplicationManager.releaseReadLockForApplication(appId);
}
}
}
@@ -233,22 +234,22 @@ public class StatusChecker {
Runnable group = new Runnable() {
public void run() {
try {
- TopologyManager.acquireReadLockForApplication(appId);
+ ApplicationManager.acquireReadLockForApplication(appId);
ParentComponent component;
if (groupId.equals(appId)) {
//it is an application
- component = TopologyManager.getTopology().
+ component = ApplicationManager.getApplications().
getApplication(appId);
} else {
//it is a group
- component = TopologyManager.getTopology().
+ component = ApplicationManager.getApplications().
getApplication(appId).getGroupRecursively(groupId);
}
Map<String, ClusterDataHolder> clusterIds = component.getClusterDataMap();
Map<String, Group> groups = component.getAliasToGroupMap();
updateChildStatus(appId, idOfChild, groups, clusterIds, component);
} finally {
- TopologyManager.releaseReadLockForApplication(appId);
+ ApplicationManager.releaseReadLockForApplication(appId);
}
@@ -286,8 +287,8 @@ public class StatusChecker {
clusterStatus = getClusterStatus(clusterData);
groupStatus = getGroupStatus(groups);
try {
- TopologyManager.acquireReadLockForApplication(appId);
- Application application = TopologyManager.getTopology().getApplication(appId);
+ ApplicationManager.acquireReadLockForApplication(appId);
+ Application application = ApplicationManager.getApplications().getApplication(appId);
if (groups.isEmpty() && getAllClusterInSameState(clusterData,ClusterStatus.Active) ||
clusterData.isEmpty() && getAllGroupInSameState(groups, GroupStatus.Active) ||
@@ -352,7 +353,7 @@ public class StatusChecker {
log.warn("Clusters/groups not found in this [component] " + appId);
}
} finally {
- TopologyManager.releaseReadLockForApplication(appId);
+ ApplicationManager.releaseReadLockForApplication(appId);
}
http://git-wip-us.apache.org/repos/asf/stratos/blob/c42d7c1d/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 f96ba8e..2e0883b 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
@@ -78,7 +78,7 @@ public class TopologyEventPublisher {
}
public static void sendClusterCreatedEvent(String appId, String serviceName, String clusterId) {
- ClusterCreatedEvent clusterCreatedEvent = new ClusterCreatedEvent(appId,serviceName, clusterId);
+ ClusterCreatedEvent clusterCreatedEvent = new ClusterCreatedEvent(new Cluster());
if(log.isInfoEnabled()) {
log.info("Publishing cluster created event: " +clusterId);
http://git-wip-us.apache.org/repos/asf/stratos/blob/c42d7c1d/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/Applications.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/Applications.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/Applications.java
index e5a7921..e1feb82 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/Applications.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/Applications.java
@@ -68,6 +68,6 @@ public class Applications implements Serializable {
public synchronized void removeApplication (String appId) {
this.applicationMap.remove(appId);
- ApplicationLockHierarchy.getInstance().removeLock(appId);
+ ApplicationLockHierarchy.getInstance().removeLockForApplication(appId);
}
}
http://git-wip-us.apache.org/repos/asf/stratos/blob/c42d7c1d/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/locking/ApplicationLockHierarchy.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/locking/ApplicationLockHierarchy.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/locking/ApplicationLockHierarchy.java
index cc31892..2b457d7 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/locking/ApplicationLockHierarchy.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/locking/ApplicationLockHierarchy.java
@@ -71,11 +71,11 @@ public class ApplicationLockHierarchy {
}
}
- public ApplicationLock getLock (String appId) {
+ public ApplicationLock getLockForApplication(String appId) {
return appIdToApplicationLockMap.get(appId);
}
- public void removeLock (String appId) {
+ public void removeLockForApplication (String appId) {
if (appIdToApplicationLockMap.remove(appId) != null) {
log.info("Removed lock for Application " + appId);
} else {
http://git-wip-us.apache.org/repos/asf/stratos/blob/c42d7c1d/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 bb6b8fa..e89df3a 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
@@ -35,15 +35,9 @@ public class TopologyLockHierarchy {
// lock for Services
private final TopologyLock serviceLock;
- // lock for Applications
- private final TopologyLock applicatioLock;
-
// key = Service.name
private final Map<String, TopologyLock> serviceNameToTopologyLockMap;
- // key = Application.id
- private final Map<String, TopologyLock> applicationIdToTopologyLockMap;
-
// key = Cluster.id
private final Map<String, TopologyLock> clusterIdToTopologyLockMap;
@@ -53,9 +47,7 @@ public class TopologyLockHierarchy {
this.completeTopologyLock = new TopologyLock();
this.serviceLock = new TopologyLock();
- this.applicatioLock = new TopologyLock();
this.serviceNameToTopologyLockMap = new ConcurrentHashMap<String, TopologyLock>();
- this.applicationIdToTopologyLockMap = new ConcurrentHashMap<String, TopologyLock>();
this.clusterIdToTopologyLockMap = new ConcurrentHashMap<String, TopologyLock>();
}
@@ -72,26 +64,6 @@ public class TopologyLockHierarchy {
return topologyLockHierarchy;
}
- public void addApplicationLock (String appId, final TopologyLock topologyLock) {
-
- if (!applicationIdToTopologyLockMap.containsKey(appId)) {
- synchronized (applicationIdToTopologyLockMap) {
- if (!applicationIdToTopologyLockMap.containsKey(appId)) {
- applicationIdToTopologyLockMap.put(appId, topologyLock);
- log.info("Added lock for Application " + appId);
- }
- }
- } else {
- if (log.isDebugEnabled()) {
- log.debug("Topology Lock for Application " + appId + " already exists");
- }
- }
- }
-
- public TopologyLock getTopologyLockForApplication (String appId) {
- return applicationIdToTopologyLockMap.get(appId);
- }
-
public void addServiceLock (String serviceName, final TopologyLock topologyLock) {
if (!serviceNameToTopologyLockMap.containsKey(serviceName)) {
@@ -132,16 +104,6 @@ public class TopologyLockHierarchy {
return clusterIdToTopologyLockMap.get(clusterId);
}
- public void removeTopologyLockForApplication (String appId) {
- if (applicationIdToTopologyLockMap.remove(appId) != null) {
- log.info("Removed lock for Application " + appId);
- } else {
- if (log.isDebugEnabled()) {
- log.debug("Lock already removed for Application " + appId);
- }
- }
- }
-
public void removeTopologyLockForService (String serviceName) {
if (serviceNameToTopologyLockMap.remove(serviceName) != null) {
log.info("Removed lock for Service " + serviceName);
@@ -166,10 +128,6 @@ public class TopologyLockHierarchy {
return serviceLock;
}
- public TopologyLock getApplicatioLock() {
- return applicatioLock;
- }
-
public TopologyLock getCompleteTopologyLock() {
return completeTopologyLock;
}
http://git-wip-us.apache.org/repos/asf/stratos/blob/c42d7c1d/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationActivatedMessageProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationActivatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationActivatedMessageProcessor.java
index 6c82925..da75265 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationActivatedMessageProcessor.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationActivatedMessageProcessor.java
@@ -22,9 +22,11 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.stratos.messaging.domain.applications.Application;
import org.apache.stratos.messaging.domain.applications.ApplicationStatus;
+import org.apache.stratos.messaging.domain.applications.Applications;
import org.apache.stratos.messaging.domain.topology.Topology;
import org.apache.stratos.messaging.event.topology.ApplicationActivatedEvent;
import org.apache.stratos.messaging.message.processor.MessageProcessor;
+import org.apache.stratos.messaging.message.processor.applications.updater.ApplicationsUpdater;
import org.apache.stratos.messaging.message.processor.topology.updater.TopologyUpdater;
import org.apache.stratos.messaging.util.Util;
@@ -46,40 +48,40 @@ public class ApplicationActivatedMessageProcessor extends MessageProcessor {
@Override
public boolean process(String type, String message, Object object) {
- Topology topology = (Topology) object;
+ Applications applications = (Applications) object;
if (ApplicationActivatedEvent.class.getName().equals(type)) {
- // Return if topology has not been initialized
- if (!topology.isInitialized())
+ // Return if applications has not been initialized
+ if (!applications.isInitialized())
return false;
// Parse complete message and build event
ApplicationActivatedEvent event = (ApplicationActivatedEvent) Util.
jsonToObject(message, ApplicationActivatedEvent.class);
- TopologyUpdater.acquireWriteLockForApplication(event.getAppId());
+ ApplicationsUpdater.acquireWriteLockForApplication(event.getAppId());
try {
- return doProcess(event, topology);
+ return doProcess(event, applications);
} finally {
- TopologyUpdater.releaseWriteLockForApplication(event.getAppId());
+ ApplicationsUpdater.releaseWriteLockForApplication(event.getAppId());
}
} else {
if (nextProcessor != null) {
// ask the next processor to take care of the message.
- return nextProcessor.process(type, message, topology);
+ return nextProcessor.process(type, message, applications);
} else {
throw new RuntimeException(String.format("Failed to process message using available message processors: [type] %s [body] %s", type, message));
}
}
}
- private boolean doProcess(ApplicationActivatedEvent event, Topology topology) {
+ private boolean doProcess(ApplicationActivatedEvent event, Applications applications) {
- // Validate event against the existing topology
- Application application = topology.getApplication(event.getAppId());
+ // Validate event against the existing applications
+ Application application = applications.getApplication(event.getAppId());
if (application == null) {
if (log.isWarnEnabled()) {
log.warn(String.format("Application does not exist: [service] %s",
@@ -87,7 +89,7 @@ public class ApplicationActivatedMessageProcessor extends MessageProcessor {
}
return false;
} else {
- // Apply changes to the topology
+ // Apply changes to the applications
if (!application.isStateTransitionValid(ApplicationStatus.Active)) {
log.error("Invalid State transfer from [ " + application.getStatus() +
" ] to [ " + ApplicationStatus.Active + " ]");
http://git-wip-us.apache.org/repos/asf/stratos/blob/c42d7c1d/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationCreatedMessageProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationCreatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationCreatedMessageProcessor.java
index db8e3c8..cfe8500 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationCreatedMessageProcessor.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationCreatedMessageProcessor.java
@@ -22,15 +22,11 @@ package org.apache.stratos.messaging.message.processor.applications;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.stratos.messaging.domain.applications.Applications;
-import org.apache.stratos.messaging.domain.applications.ClusterDataHolder;
-import org.apache.stratos.messaging.domain.topology.Cluster;
import org.apache.stratos.messaging.event.applications.ApplicationCreatedEvent;
import org.apache.stratos.messaging.message.processor.MessageProcessor;
-import org.apache.stratos.messaging.message.processor.topology.updater.TopologyUpdater;
+import org.apache.stratos.messaging.message.processor.applications.updater.ApplicationsUpdater;
import org.apache.stratos.messaging.util.Util;
-import java.util.Set;
-
public class ApplicationCreatedMessageProcessor extends MessageProcessor {
private static final Log log = LogFactory.getLog(ApplicationCreatedMessageProcessor.class);
@@ -57,12 +53,12 @@ public class ApplicationCreatedMessageProcessor extends MessageProcessor {
return false;
}
- TopologyUpdater.acquireWriteLockForApplications();
+ ApplicationsUpdater.acquireWriteLockForApplications();
try {
return doProcess(event, applications);
} finally {
- TopologyUpdater.releaseWriteLockForApplications();
+ ApplicationsUpdater.releaseWriteLockForApplications();
}
} else {
@@ -75,7 +71,7 @@ public class ApplicationCreatedMessageProcessor extends MessageProcessor {
}
}
- private boolean doProcess(ApplicationCreatedEvent event, Applications topology) {
+ private boolean doProcess(ApplicationCreatedEvent event, Applications applications) {
// check if required properties are available
if (event.getApplication() == null) {
@@ -90,13 +86,13 @@ public class ApplicationCreatedMessageProcessor extends MessageProcessor {
throw new RuntimeException(errorMsg);
}
- // check if an Application with same name exists in topology
- if (topology.applicationExists(event.getApplication().getUniqueIdentifier())) {
+ // check if an Application with same name exists in applications
+ if (applications.applicationExists(event.getApplication().getUniqueIdentifier())) {
log.warn("Application with id [ " + event.getApplication().getUniqueIdentifier() + " ] already exists in Topology");
} else {
// add application and the clusters to Topology
- topology.addApplication(event.getApplication());
+ applications.addApplication(event.getApplication());
}
notifyEventListeners(event);
http://git-wip-us.apache.org/repos/asf/stratos/blob/c42d7c1d/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationInactivatedMessageProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationInactivatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationInactivatedMessageProcessor.java
index 91eae8c..e97e3fc 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationInactivatedMessageProcessor.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationInactivatedMessageProcessor.java
@@ -22,9 +22,11 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.stratos.messaging.domain.applications.Application;
import org.apache.stratos.messaging.domain.applications.ApplicationStatus;
+import org.apache.stratos.messaging.domain.applications.Applications;
import org.apache.stratos.messaging.domain.topology.Topology;
import org.apache.stratos.messaging.event.topology.ApplicationInactivatedEvent;
import org.apache.stratos.messaging.message.processor.MessageProcessor;
+import org.apache.stratos.messaging.message.processor.applications.updater.ApplicationsUpdater;
import org.apache.stratos.messaging.message.processor.topology.updater.TopologyUpdater;
import org.apache.stratos.messaging.util.Util;
@@ -46,40 +48,40 @@ public class ApplicationInactivatedMessageProcessor extends MessageProcessor {
@Override
public boolean process(String type, String message, Object object) {
- Topology topology = (Topology) object;
+ Applications applications = (Applications) object;
if (ApplicationInactivatedEvent.class.getName().equals(type)) {
- // Return if topology has not been initialized
- if (!topology.isInitialized())
+ // Return if applications has not been initialized
+ if (!applications.isInitialized())
return false;
// Parse complete message and build event
ApplicationInactivatedEvent event = (ApplicationInactivatedEvent) Util.
jsonToObject(message, ApplicationInactivatedEvent.class);
- TopologyUpdater.acquireWriteLockForApplication(event.getAppId());
+ ApplicationsUpdater.acquireWriteLockForApplication(event.getAppId());
try {
- return doProcess(event, topology);
+ return doProcess(event, applications);
} finally {
- TopologyUpdater.releaseWriteLockForApplication(event.getAppId());
+ ApplicationsUpdater.releaseWriteLockForApplication(event.getAppId());
}
} else {
if (nextProcessor != null) {
// ask the next processor to take care of the message.
- return nextProcessor.process(type, message, topology);
+ return nextProcessor.process(type, message, applications);
} else {
throw new RuntimeException(String.format("Failed to process message using available message processors: [type] %s [body] %s", type, message));
}
}
}
- private boolean doProcess (ApplicationInactivatedEvent event, Topology topology) {
+ private boolean doProcess (ApplicationInactivatedEvent event, Applications applications) {
- // Validate event against the existing topology
- Application application = topology.getApplication(event.getAppId());
+ // Validate event against the existing applications
+ Application application = applications.getApplication(event.getAppId());
if (application == null) {
if (log.isWarnEnabled()) {
log.warn(String.format("Application does not exist: [service] %s",
@@ -87,7 +89,7 @@ public class ApplicationInactivatedMessageProcessor extends MessageProcessor {
}
return false;
} else {
- // Apply changes to the topology
+ // Apply changes to the applications
if (!application.isStateTransitionValid(ApplicationStatus.Inactive)) {
log.error("Invalid State transfer from [ " + application.getStatus() +
" ] to [ " + ApplicationStatus.Inactive + " ]");
http://git-wip-us.apache.org/repos/asf/stratos/blob/c42d7c1d/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationTerminatedMessageProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationTerminatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationTerminatedMessageProcessor.java
index 8cd2182..99d08fe 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationTerminatedMessageProcessor.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationTerminatedMessageProcessor.java
@@ -20,10 +20,12 @@ package org.apache.stratos.messaging.message.processor.applications;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.messaging.domain.applications.Applications;
import org.apache.stratos.messaging.domain.applications.ClusterDataHolder;
import org.apache.stratos.messaging.domain.topology.*;
import org.apache.stratos.messaging.event.topology.ApplicationTerminatedEvent;
import org.apache.stratos.messaging.message.processor.MessageProcessor;
+import org.apache.stratos.messaging.message.processor.applications.updater.ApplicationsUpdater;
import org.apache.stratos.messaging.message.processor.topology.updater.TopologyUpdater;
import org.apache.stratos.messaging.util.Util;
@@ -47,18 +49,18 @@ public class ApplicationTerminatedMessageProcessor extends MessageProcessor {
@Override
public boolean process(String type, String message, Object object) {
- Topology topology = (Topology) object;
+ Applications applications = (Applications) object;
if (ApplicationTerminatedEvent.class.getName().equals(type)) {
- // Return if topology has not been initialized
- if (!topology.isInitialized())
+ // Return if applications has not been initialized
+ if (!applications.isInitialized())
return false;
// Parse complete message and build event
ApplicationTerminatedEvent event = (ApplicationTerminatedEvent) Util.
jsonToObject(message, ApplicationTerminatedEvent.class);
- TopologyUpdater.acquireWriteLockForApplications();
+ ApplicationsUpdater.acquireWriteLockForApplications();
Set<ClusterDataHolder> clusterDataHolders = event.getClusterData();
if (clusterDataHolders != null) {
for (ClusterDataHolder clusterData : clusterDataHolders) {
@@ -67,10 +69,10 @@ public class ApplicationTerminatedMessageProcessor extends MessageProcessor {
}
try {
- return doProcess(event, topology);
+ return doProcess(event, applications);
} finally {
- TopologyUpdater.releaseWriteLockForApplications();
+ ApplicationsUpdater.releaseWriteLockForApplications();
if (clusterDataHolders != null) {
for (ClusterDataHolder clusterData : clusterDataHolders) {
TopologyUpdater.releaseWriteLockForService(clusterData.getServiceType());
@@ -81,14 +83,14 @@ public class ApplicationTerminatedMessageProcessor extends MessageProcessor {
} else {
if (nextProcessor != null) {
// ask the next processor to take care of the message.
- return nextProcessor.process(type, message, topology);
+ return nextProcessor.process(type, message, applications);
} else {
throw new RuntimeException(String.format("Failed to process message using available message processors: [type] %s [body] %s", type, message));
}
}
}
- private boolean doProcess (ApplicationTerminatedEvent event, Topology topology) {
+ private boolean doProcess (ApplicationTerminatedEvent event, Applications applications) {
// check if required properties are available
if (event.getAppId() == null) {
@@ -103,25 +105,26 @@ public class ApplicationTerminatedMessageProcessor extends MessageProcessor {
throw new RuntimeException(errorMsg);
}
- // check if an Application with same name exists in topology
+ // check if an Application with same name exists in applications
String appId = event.getAppId();
- if (topology.applicationExists(appId)) {
+ if (applications.applicationExists(appId)) {
log.warn("Application with id [ " + appId + " ] still exists in Topology, removing it");
- topology.removeApplication(appId);
+ applications.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!");
- }
+ log.info("################################ TODO ################################");
+// Service service = applications.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!");
+// }
}
}
http://git-wip-us.apache.org/repos/asf/stratos/blob/c42d7c1d/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationTerminatingMessageProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationTerminatingMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationTerminatingMessageProcessor.java
index 057d013..633e080 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationTerminatingMessageProcessor.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationTerminatingMessageProcessor.java
@@ -22,9 +22,11 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.stratos.messaging.domain.applications.Application;
import org.apache.stratos.messaging.domain.applications.ApplicationStatus;
+import org.apache.stratos.messaging.domain.applications.Applications;
import org.apache.stratos.messaging.domain.topology.Topology;
import org.apache.stratos.messaging.event.topology.ApplicationTerminatingEvent;
import org.apache.stratos.messaging.message.processor.MessageProcessor;
+import org.apache.stratos.messaging.message.processor.applications.updater.ApplicationsUpdater;
import org.apache.stratos.messaging.message.processor.topology.updater.TopologyUpdater;
import org.apache.stratos.messaging.util.Util;
@@ -46,40 +48,40 @@ public class ApplicationTerminatingMessageProcessor extends MessageProcessor {
@Override
public boolean process(String type, String message, Object object) {
- Topology topology = (Topology) object;
+ Applications applications = (Applications) object;
if (ApplicationTerminatingEvent.class.getName().equals(type)) {
- // Return if topology has not been initialized
- if (!topology.isInitialized())
+ // Return if applications has not been initialized
+ if (!applications.isInitialized())
return false;
// Parse complete message and build event
ApplicationTerminatingEvent event = (ApplicationTerminatingEvent) Util.
jsonToObject(message, ApplicationTerminatingEvent.class);
- TopologyUpdater.acquireWriteLockForApplication(event.getAppId());
+ ApplicationsUpdater.acquireWriteLockForApplication(event.getAppId());
try {
- return doProcess(event, topology);
+ return doProcess(event, applications);
} finally {
- TopologyUpdater.releaseWriteLockForApplication(event.getAppId());
+ ApplicationsUpdater.releaseWriteLockForApplication(event.getAppId());
}
} else {
if (nextProcessor != null) {
// ask the next processor to take care of the message.
- return nextProcessor.process(type, message, topology);
+ return nextProcessor.process(type, message, applications);
} else {
throw new RuntimeException(String.format("Failed to process message using available message processors: [type] %s [body] %s", type, message));
}
}
}
- private boolean doProcess (ApplicationTerminatingEvent event, Topology topology) {
+ private boolean doProcess (ApplicationTerminatingEvent event, Applications applications) {
- // Validate event against the existing topology
- Application application = topology.getApplication(event.getAppId());
+ // Validate event against the existing applications
+ Application application = applications.getApplication(event.getAppId());
if (application == null) {
if (log.isWarnEnabled()) {
log.warn(String.format("Application does not exist: [service] %s",
@@ -87,7 +89,7 @@ public class ApplicationTerminatingMessageProcessor extends MessageProcessor {
}
return false;
} else {
- // Apply changes to the topology
+ // Apply changes to the applications
if (!application.isStateTransitionValid(ApplicationStatus.Terminating)) {
log.error("Invalid State transfer from [ " + application.getStatus() +
" ] to [ " + ApplicationStatus.Terminating + " ]");
http://git-wip-us.apache.org/repos/asf/stratos/blob/c42d7c1d/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationUndeployedMessageProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationUndeployedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationUndeployedMessageProcessor.java
index 7e91ab8..e911b77 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationUndeployedMessageProcessor.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationUndeployedMessageProcessor.java
@@ -23,10 +23,12 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.stratos.messaging.domain.applications.Application;
import org.apache.stratos.messaging.domain.applications.ApplicationStatus;
+import org.apache.stratos.messaging.domain.applications.Applications;
import org.apache.stratos.messaging.domain.applications.ClusterDataHolder;
import org.apache.stratos.messaging.domain.topology.*;
import org.apache.stratos.messaging.event.topology.ApplicationUndeployedEvent;
import org.apache.stratos.messaging.message.processor.MessageProcessor;
+import org.apache.stratos.messaging.message.processor.applications.updater.ApplicationsUpdater;
import org.apache.stratos.messaging.message.processor.topology.updater.TopologyUpdater;
import org.apache.stratos.messaging.util.Util;
@@ -46,10 +48,10 @@ public class ApplicationUndeployedMessageProcessor extends MessageProcessor {
@Override
public boolean process(String type, String message, Object object) {
- Topology topology = (Topology) object;
+ Applications applications = (Applications) object;
if (ApplicationUndeployedEvent.class.getName().equals(type)) {
- if (!topology.isInitialized()) {
+ if (!applications.isInitialized()) {
return false;
}
@@ -61,7 +63,7 @@ public class ApplicationUndeployedMessageProcessor extends MessageProcessor {
}
// get write lock for the application and relevant Clusters
- TopologyUpdater.acquireWriteLockForApplication(event.getApplicationId());
+ ApplicationsUpdater.acquireWriteLockForApplication(event.getApplicationId());
Set<ClusterDataHolder> clusterDataHolders = event.getClusterData();
if (clusterDataHolders != null) {
for (ClusterDataHolder clusterData : clusterDataHolders) {
@@ -71,7 +73,7 @@ public class ApplicationUndeployedMessageProcessor extends MessageProcessor {
}
try {
- return doProcess(event, topology);
+ return doProcess(event, applications);
} finally {
// remove locks
@@ -81,13 +83,13 @@ public class ApplicationUndeployedMessageProcessor extends MessageProcessor {
clusterData.getClusterId());
}
}
- TopologyUpdater.releaseWriteLockForApplication(event.getApplicationId());
+ ApplicationsUpdater.releaseWriteLockForApplication(event.getApplicationId());
}
} else {
if (nextProcessor != null) {
// ask the next processor to take care of the message.
- return nextProcessor.process(type, message, topology);
+ return nextProcessor.process(type, message, applications);
} else {
throw new RuntimeException(String.format
("Failed to process message using available message processors: [type] %s [body] %s", type, message));
@@ -95,10 +97,10 @@ public class ApplicationUndeployedMessageProcessor extends MessageProcessor {
}
}
- private boolean doProcess (ApplicationUndeployedEvent event, Topology topology) {
+ private boolean doProcess (ApplicationUndeployedEvent event, Applications applications) {
// update the application status to Terminating
- Application application = topology.getApplication(event.getApplicationId());
+ Application application = applications.getApplication(event.getApplicationId());
// check and update application status to 'Terminating'
if (!application.isStateTransitionValid(ApplicationStatus.Terminating)) {
log.error("Invalid state transfer from " + application.getStatus() + " to " + ApplicationStatus.Terminating);
@@ -110,27 +112,28 @@ public class ApplicationUndeployedMessageProcessor extends MessageProcessor {
Set<ClusterDataHolder> clusterData = application.getClusterDataRecursively();
// update the Cluster statuses to Terminating
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 remove cluster with cluster id: " + clusterDataHolder.getClusterId() + " from Topology, " +
- " associated Service [ " + clusterDataHolder.getServiceType() + " ] npt found");
- }
+ log.info("############################### TODO ###############################");
+// Service service = applications.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 remove cluster with cluster id: " + clusterDataHolder.getClusterId() + " from Topology, " +
+// " associated Service [ " + clusterDataHolder.getServiceType() + " ] npt found");
+// }
}
notifyEventListeners(event);
http://git-wip-us.apache.org/repos/asf/stratos/blob/c42d7c1d/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/CompleteApplicationsMessageProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/CompleteApplicationsMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/CompleteApplicationsMessageProcessor.java
index 53c469b..c9af67a 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/CompleteApplicationsMessageProcessor.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/CompleteApplicationsMessageProcessor.java
@@ -22,25 +22,12 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.stratos.messaging.domain.applications.Application;
import org.apache.stratos.messaging.domain.applications.Applications;
-import org.apache.stratos.messaging.domain.topology.Cluster;
-import org.apache.stratos.messaging.domain.topology.Member;
-import org.apache.stratos.messaging.domain.topology.Service;
-import org.apache.stratos.messaging.domain.topology.Topology;
-import org.apache.stratos.messaging.domain.topology.locking.TopologyLock;
-import org.apache.stratos.messaging.domain.topology.locking.TopologyLockHierarchy;
import org.apache.stratos.messaging.event.applications.CompleteApplicationsEvent;
-import org.apache.stratos.messaging.event.topology.CompleteTopologyEvent;
-import org.apache.stratos.messaging.message.filter.topology.TopologyClusterFilter;
-import org.apache.stratos.messaging.message.filter.topology.TopologyMemberFilter;
-import org.apache.stratos.messaging.message.filter.topology.TopologyServiceFilter;
import org.apache.stratos.messaging.message.processor.MessageProcessor;
import org.apache.stratos.messaging.message.processor.applications.updater.ApplicationsUpdater;
-import org.apache.stratos.messaging.message.processor.topology.updater.TopologyUpdater;
import org.apache.stratos.messaging.util.Util;
-import java.util.ArrayList;
import java.util.Collection;
-import java.util.List;
public class CompleteApplicationsMessageProcessor extends MessageProcessor {
@@ -62,13 +49,13 @@ public class CompleteApplicationsMessageProcessor extends MessageProcessor {
jsonToObject(message, CompleteApplicationsEvent.class);
if (!applications.isInitialized()) {
- ApplicationsUpdater.acquireWriteLock();
+ ApplicationsUpdater.acquireWriteLockForApplications();
try {
doProcess(event, applications);
} finally {
- ApplicationsUpdater.releaseWriteLock();
+ ApplicationsUpdater.releaseWriteLockForApplications();
}
}
http://git-wip-us.apache.org/repos/asf/stratos/blob/c42d7c1d/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupActivatedProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupActivatedProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupActivatedProcessor.java
index 845e933..5c8d477 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupActivatedProcessor.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupActivatedProcessor.java
@@ -21,11 +21,13 @@ package org.apache.stratos.messaging.message.processor.applications;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.stratos.messaging.domain.applications.Application;
+import org.apache.stratos.messaging.domain.applications.Applications;
import org.apache.stratos.messaging.domain.applications.Group;
import org.apache.stratos.messaging.domain.applications.GroupStatus;
import org.apache.stratos.messaging.domain.topology.*;
import org.apache.stratos.messaging.event.topology.GroupActivatedEvent;
import org.apache.stratos.messaging.message.processor.MessageProcessor;
+import org.apache.stratos.messaging.message.processor.applications.updater.ApplicationsUpdater;
import org.apache.stratos.messaging.message.processor.topology.updater.TopologyUpdater;
import org.apache.stratos.messaging.util.Util;
@@ -43,40 +45,40 @@ public class GroupActivatedProcessor extends MessageProcessor {
@Override
public boolean process(String type, String message, Object object) {
- Topology topology = (Topology) object;
+ Applications applications = (Applications) object;
if (GroupActivatedEvent.class.getName().equals(type)) {
- // Return if topology has not been initialized
- if (!topology.isInitialized())
+ // Return if applications has not been initialized
+ if (!applications.isInitialized())
return false;
// Parse complete message and build event
GroupActivatedEvent event = (GroupActivatedEvent) Util.
jsonToObject(message, GroupActivatedEvent.class);
- TopologyUpdater.acquireWriteLockForApplication(event.getAppId());
+ ApplicationsUpdater.acquireWriteLockForApplication(event.getAppId());
try {
- return doProcess(event, topology);
+ return doProcess(event, applications);
} finally {
- TopologyUpdater.releaseWriteLockForApplication(event.getAppId());
+ ApplicationsUpdater.releaseWriteLockForApplication(event.getAppId());
}
} else {
if (nextProcessor != null) {
// ask the next processor to take care of the message.
- return nextProcessor.process(type, message, topology);
+ return nextProcessor.process(type, message, applications);
} else {
throw new RuntimeException(String.format("Failed to process message using available message processors: [type] %s [body] %s", type, message));
}
}
}
- private boolean doProcess (GroupActivatedEvent event,Topology topology) {
+ private boolean doProcess (GroupActivatedEvent event, Applications applications) {
// Validate event against the existing topology
- Application application = topology.getApplication(event.getAppId());
+ Application application = applications.getApplication(event.getAppId());
if (application == null) {
if (log.isWarnEnabled()) {
log.warn(String.format("Application does not exist: [service] %s",
http://git-wip-us.apache.org/repos/asf/stratos/blob/c42d7c1d/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupCreatedProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupCreatedProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupCreatedProcessor.java
index 47d4457..67861e4 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupCreatedProcessor.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupCreatedProcessor.java
@@ -21,11 +21,13 @@ package org.apache.stratos.messaging.message.processor.applications;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.stratos.messaging.domain.applications.Application;
+import org.apache.stratos.messaging.domain.applications.Applications;
import org.apache.stratos.messaging.domain.applications.Group;
import org.apache.stratos.messaging.domain.applications.GroupStatus;
import org.apache.stratos.messaging.domain.topology.Topology;
import org.apache.stratos.messaging.event.topology.GroupCreatedEvent;
import org.apache.stratos.messaging.message.processor.MessageProcessor;
+import org.apache.stratos.messaging.message.processor.applications.updater.ApplicationsUpdater;
import org.apache.stratos.messaging.message.processor.topology.updater.TopologyUpdater;
import org.apache.stratos.messaging.util.Util;
@@ -43,40 +45,40 @@ public class GroupCreatedProcessor extends MessageProcessor {
@Override
public boolean process(String type, String message, Object object) {
- Topology topology = (Topology) object;
+ Applications applications = (Applications) object;
if (GroupCreatedEvent.class.getName().equals(type)) {
- // Return if topology has not been initialized
- if (!topology.isInitialized())
+ // Return if applications has not been initialized
+ if (!applications.isInitialized())
return false;
// Parse complete message and build event
GroupCreatedEvent event = (GroupCreatedEvent) Util.
jsonToObject(message, GroupCreatedEvent.class);
- TopologyUpdater.acquireWriteLockForApplication(event.getAppId());
+ ApplicationsUpdater.acquireWriteLockForApplication(event.getAppId());
try {
- return doProcess(event, topology);
+ return doProcess(event, applications);
} finally {
- TopologyUpdater.releaseWriteLockForApplication(event.getAppId());
+ ApplicationsUpdater.releaseWriteLockForApplication(event.getAppId());
}
} else {
if (nextProcessor != null) {
// ask the next processor to take care of the message.
- return nextProcessor.process(type, message, topology);
+ return nextProcessor.process(type, message, applications);
} else {
throw new RuntimeException(String.format("Failed to process message using available message processors: [type] %s [body] %s", type, message));
}
}
}
- private boolean doProcess (GroupCreatedEvent event,Topology topology) {
+ private boolean doProcess (GroupCreatedEvent event,Applications applications) {
- // Validate event against the existing topology
- Application application = topology.getApplication(event.getAppId());
+ // Validate event against the existing applications
+ Application application = applications.getApplication(event.getAppId());
if (application == null) {
if (log.isWarnEnabled()) {
log.warn(String.format("Application does not exist: [service] %s",
@@ -92,7 +94,7 @@ public class GroupCreatedProcessor extends MessageProcessor {
event.getGroupId()));
}
} else {
- // Apply changes to the topology
+ // Apply changes to the applications
if (!group.isStateTransitionValid(GroupStatus.Created)) {
log.error("Invalid State Transition from " + group.getStatus() + " to " + GroupStatus.Created + " " +
"for Group " + group.getAlias());
http://git-wip-us.apache.org/repos/asf/stratos/blob/c42d7c1d/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupInActivateProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupInActivateProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupInActivateProcessor.java
index 063a3de..4f2e581 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupInActivateProcessor.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupInActivateProcessor.java
@@ -21,11 +21,13 @@ package org.apache.stratos.messaging.message.processor.applications;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.stratos.messaging.domain.applications.Application;
+import org.apache.stratos.messaging.domain.applications.Applications;
import org.apache.stratos.messaging.domain.applications.Group;
import org.apache.stratos.messaging.domain.applications.GroupStatus;
import org.apache.stratos.messaging.domain.topology.Topology;
import org.apache.stratos.messaging.event.topology.GroupInactivateEvent;
import org.apache.stratos.messaging.message.processor.MessageProcessor;
+import org.apache.stratos.messaging.message.processor.applications.updater.ApplicationsUpdater;
import org.apache.stratos.messaging.message.processor.topology.updater.TopologyUpdater;
import org.apache.stratos.messaging.util.Util;
@@ -43,40 +45,40 @@ public class GroupInActivateProcessor extends MessageProcessor {
@Override
public boolean process(String type, String message, Object object) {
- Topology topology = (Topology) object;
+ Applications applications = (Applications) object;
if (GroupInactivateEvent.class.getName().equals(type)) {
- // Return if topology has not been initialized
- if (!topology.isInitialized())
+ // Return if applications has not been initialized
+ if (!applications.isInitialized())
return false;
// Parse complete message and build event
GroupInactivateEvent event = (GroupInactivateEvent) Util.
jsonToObject(message, GroupInactivateEvent.class);
- TopologyUpdater.acquireWriteLockForApplication(event.getAppId());
+ ApplicationsUpdater.acquireWriteLockForApplication(event.getAppId());
try {
- return doProcess(event, topology);
+ return doProcess(event, applications);
} finally {
- TopologyUpdater.releaseWriteLockForApplication(event.getAppId());
+ ApplicationsUpdater.releaseWriteLockForApplication(event.getAppId());
}
} else {
if (nextProcessor != null) {
// ask the next processor to take care of the message.
- return nextProcessor.process(type, message, topology);
+ return nextProcessor.process(type, message, applications);
} else {
throw new RuntimeException(String.format("Failed to process message using available message processors: [type] %s [body] %s", type, message));
}
}
}
- private boolean doProcess(GroupInactivateEvent event, Topology topology) {
+ private boolean doProcess(GroupInactivateEvent event, Applications applications) {
- // Validate event against the existing topology
- Application application = topology.getApplication(event.getAppId());
+ // Validate event against the existing applications
+ Application application = applications.getApplication(event.getAppId());
if (application == null) {
if (log.isWarnEnabled()) {
log.warn(String.format("Application does not exist: [service] %s",
http://git-wip-us.apache.org/repos/asf/stratos/blob/c42d7c1d/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupTerminatedProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupTerminatedProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupTerminatedProcessor.java
index 3de0914..6e985b7 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupTerminatedProcessor.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupTerminatedProcessor.java
@@ -21,11 +21,13 @@ package org.apache.stratos.messaging.message.processor.applications;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.stratos.messaging.domain.applications.Application;
+import org.apache.stratos.messaging.domain.applications.Applications;
import org.apache.stratos.messaging.domain.applications.Group;
import org.apache.stratos.messaging.domain.applications.GroupStatus;
import org.apache.stratos.messaging.domain.topology.Topology;
import org.apache.stratos.messaging.event.topology.GroupTerminatedEvent;
import org.apache.stratos.messaging.message.processor.MessageProcessor;
+import org.apache.stratos.messaging.message.processor.applications.updater.ApplicationsUpdater;
import org.apache.stratos.messaging.message.processor.topology.updater.TopologyUpdater;
import org.apache.stratos.messaging.util.Util;
@@ -43,40 +45,40 @@ public class GroupTerminatedProcessor extends MessageProcessor {
@Override
public boolean process(String type, String message, Object object) {
- Topology topology = (Topology) object;
+ Applications applications = (Applications) object;
if (GroupTerminatedEvent.class.getName().equals(type)) {
- // Return if topology has not been initialized
- if (!topology.isInitialized())
+ // Return if applications has not been initialized
+ if (!applications.isInitialized())
return false;
// Parse complete message and build event
GroupTerminatedEvent event = (GroupTerminatedEvent) Util.
jsonToObject(message, GroupTerminatedEvent.class);
- TopologyUpdater.acquireWriteLockForApplication(event.getAppId());
+ ApplicationsUpdater.acquireWriteLockForApplication(event.getAppId());
try {
- return doProcess(event, topology);
+ return doProcess(event, applications);
} finally {
- TopologyUpdater.releaseWriteLockForApplication(event.getAppId());
+ ApplicationsUpdater.releaseWriteLockForApplication(event.getAppId());
}
} else {
if (nextProcessor != null) {
// ask the next processor to take care of the message.
- return nextProcessor.process(type, message, topology);
+ return nextProcessor.process(type, message, applications);
} else {
throw new RuntimeException(String.format("Failed to process message using available message processors: [type] %s [body] %s", type, message));
}
}
}
- private boolean doProcess (GroupTerminatedEvent event,Topology topology) {
+ private boolean doProcess (GroupTerminatedEvent event, Applications applications) {
- // Validate event against the existing topology
- Application application = topology.getApplication(event.getAppId());
+ // Validate event against the existing applications
+ Application application = applications.getApplication(event.getAppId());
if (application == null) {
if (log.isWarnEnabled()) {
log.warn(String.format("Application does not exist: [service] %s",
@@ -92,7 +94,7 @@ public class GroupTerminatedProcessor extends MessageProcessor {
event.getGroupId()));
}
} else {
- // Apply changes to the topology
+ // Apply changes to the applications
if (!group.isStateTransitionValid(GroupStatus.Terminated)) {
log.error("Invalid State Transition from " + group.getStatus() + " to " + GroupStatus.Terminated);
}
http://git-wip-us.apache.org/repos/asf/stratos/blob/c42d7c1d/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupTerminatingProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupTerminatingProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupTerminatingProcessor.java
index e124b7b..c9a136f 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupTerminatingProcessor.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupTerminatingProcessor.java
@@ -21,11 +21,13 @@ package org.apache.stratos.messaging.message.processor.applications;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.stratos.messaging.domain.applications.Application;
+import org.apache.stratos.messaging.domain.applications.Applications;
import org.apache.stratos.messaging.domain.applications.Group;
import org.apache.stratos.messaging.domain.applications.GroupStatus;
import org.apache.stratos.messaging.domain.topology.Topology;
import org.apache.stratos.messaging.event.topology.GroupTerminatingEvent;
import org.apache.stratos.messaging.message.processor.MessageProcessor;
+import org.apache.stratos.messaging.message.processor.applications.updater.ApplicationsUpdater;
import org.apache.stratos.messaging.message.processor.topology.updater.TopologyUpdater;
import org.apache.stratos.messaging.util.Util;
@@ -43,40 +45,40 @@ public class GroupTerminatingProcessor extends MessageProcessor {
@Override
public boolean process(String type, String message, Object object) {
- Topology topology = (Topology) object;
+ Applications applications = (Applications) object;
if (GroupTerminatingEvent.class.getName().equals(type)) {
- // Return if topology has not been initialized
- if (!topology.isInitialized())
+ // Return if applications has not been initialized
+ if (!applications.isInitialized())
return false;
// Parse complete message and build event
GroupTerminatingEvent event = (GroupTerminatingEvent) Util.
jsonToObject(message, GroupTerminatingEvent.class);
- TopologyUpdater.acquireWriteLockForApplication(event.getAppId());
+ ApplicationsUpdater.acquireWriteLockForApplication(event.getAppId());
try {
- return doProcess(event, topology);
+ return doProcess(event, applications);
} finally {
- TopologyUpdater.releaseWriteLockForApplication(event.getAppId());
+ ApplicationsUpdater.releaseWriteLockForApplication(event.getAppId());
}
} else {
if (nextProcessor != null) {
// ask the next processor to take care of the message.
- return nextProcessor.process(type, message, topology);
+ return nextProcessor.process(type, message, applications);
} else {
throw new RuntimeException(String.format("Failed to process message using available message processors: [type] %s [body] %s", type, message));
}
}
}
- private boolean doProcess (GroupTerminatingEvent event,Topology topology) {
+ private boolean doProcess (GroupTerminatingEvent event,Applications applications) {
- // Validate event against the existing topology
- Application application = topology.getApplication(event.getAppId());
+ // Validate event against the existing applications
+ Application application = applications.getApplication(event.getAppId());
if (application == null) {
if (log.isWarnEnabled()) {
log.warn(String.format("Application does not exist: [service] %s",
@@ -92,7 +94,7 @@ public class GroupTerminatingProcessor extends MessageProcessor {
event.getGroupId()));
}
} else {
- // Apply changes to the topology
+ // Apply changes to the applications
if (!group.isStateTransitionValid(GroupStatus.Terminating)) {
log.error("Invalid State Transition from " + group.getStatus() + " to " + GroupStatus.Active);
}
[2/4] moving applications stuff to autoscaler - II
Posted by is...@apache.org.
http://git-wip-us.apache.org/repos/asf/stratos/blob/c42d7c1d/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/updater/ApplicationsUpdater.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/updater/ApplicationsUpdater.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/updater/ApplicationsUpdater.java
index bbbfbf5..e987abf 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/updater/ApplicationsUpdater.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/updater/ApplicationsUpdater.java
@@ -23,8 +23,7 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.stratos.messaging.domain.applications.locking.ApplicationLock;
import org.apache.stratos.messaging.domain.applications.locking.ApplicationLockHierarchy;
-import org.apache.stratos.messaging.domain.topology.locking.TopologyLock;
-import org.apache.stratos.messaging.domain.topology.locking.TopologyLockHierarchy;
+import org.apache.stratos.messaging.message.receiver.applications.ApplicationManager;
import org.apache.stratos.messaging.message.receiver.topology.TopologyManager;
/**
@@ -67,21 +66,21 @@ public class ApplicationsUpdater {
// Top level locks - should be used to lock the entire Topology
/**
- * Acquires write lock for the Complete Topology
+ * Acquires write lock for all Applications
*/
- public static void acquireWriteLock() {
+ public static void acquireWriteLockForApplications() {
if(log.isDebugEnabled()) {
- log.debug("Write lock acquired for Topology");
+ log.debug("Write lock acquired for Applications");
}
applicationLockHierarchy.getApplicationLock().acquireWriteLock();
}
/**
- * Releases write lock for the Complete Topology
+ * Releases write lock for all Applications
*/
- public static void releaseWriteLock() {
+ public static void releaseWriteLockForApplications() {
if(log.isDebugEnabled()) {
- log.debug("Write lock released for Topology");
+ log.debug("Write lock released for Applications");
}
applicationLockHierarchy.getApplicationLock().releaseWritelock();
}
@@ -94,9 +93,9 @@ public class ApplicationsUpdater {
public static void acquireWriteLockForApplication (String appId) {
// acquire read lock for all Applications
- TopologyManager.acquireReadLockForApplications();
+ ApplicationManager.acquireReadLockForApplications();
- ApplicationLock applicationLock = applicationLockHierarchy.getLock(appId);
+ ApplicationLock applicationLock = applicationLockHierarchy.getLockForApplication(appId);
if (applicationLock == null) {
handleLockNotFound("Topology lock not found for Application " + appId);
@@ -116,7 +115,7 @@ public class ApplicationsUpdater {
*/
public static void releaseWriteLockForApplication (String appId) {
- ApplicationLock applicationLock = applicationLockHierarchy.getLock(appId);
+ ApplicationLock applicationLock = applicationLockHierarchy.getLockForApplication(appId);
if (applicationLock == null) {
handleLockNotFound("Topology lock not found for Application " + appId);
@@ -129,7 +128,7 @@ public class ApplicationsUpdater {
}
// release read lock for all Applications
- TopologyManager.releaseReadLockForApplications();
+ ApplicationManager.releaseReadLockForApplications();
}
private static void handleLockNotFound (String errorMsg) {
http://git-wip-us.apache.org/repos/asf/stratos/blob/c42d7c1d/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/CompleteTopologyMessageProcessor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/CompleteTopologyMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/CompleteTopologyMessageProcessor.java
index 787ac74..ea1f83b 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/CompleteTopologyMessageProcessor.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/CompleteTopologyMessageProcessor.java
@@ -149,21 +149,6 @@ public class CompleteTopologyMessageProcessor extends MessageProcessor {
}
}
- // add existing Applications to Topology
- Collection<Application> applications = event.getTopology().getApplications();
- if (applications != null && !applications.isEmpty()) {
- for (Application application : applications) {
- topology.addApplication(application);
- if (log.isDebugEnabled()) {
- log.debug("Application with id [ " + application.getUniqueIdentifier() + " ] added to Topology");
- }
- }
- } else {
- if (log.isDebugEnabled()) {
- log.debug("No Application information found in Complete Topology event");
- }
- }
-
if (log.isInfoEnabled()) {
log.info("Topology initialized");
}
http://git-wip-us.apache.org/repos/asf/stratos/blob/c42d7c1d/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/updater/TopologyUpdater.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/updater/TopologyUpdater.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/updater/TopologyUpdater.java
index 9867223..e4b1c66 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/updater/TopologyUpdater.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/updater/TopologyUpdater.java
@@ -83,27 +83,7 @@ public class TopologyUpdater {
topologyLockHierarchy.getCompleteTopologyLock().releaseWritelock();
}
- // Application and Service write locks
- /**
- * Acquires write lock for the all Applications
- */
- public static void acquireWriteLockForApplications() {
- if(log.isDebugEnabled()) {
- log.debug("Write lock acquired for Applications");
- }
- topologyLockHierarchy.getApplicatioLock().acquireWriteLock();
- }
-
- /**
- * Releases write lock for the all Applications
- */
- public static void releaseWriteLockForApplications() {
- if(log.isDebugEnabled()) {
- log.debug("Write lock released for Applications");
- }
- topologyLockHierarchy.getApplicatioLock().releaseWritelock();
- }
-
+ // Service write locks
/**
* Acquires write lock for the all Services
*/
@@ -218,52 +198,6 @@ public class TopologyUpdater {
TopologyManager.releaseReadLockForService(serviceName);
}
- /**
- * Acquires write lock for the Application
- *
- * @param appId Application id
- */
- public static void acquireWriteLockForApplication (String appId) {
-
- // acquire read lock for all Applications
- TopologyManager.acquireReadLockForApplications();
-
- TopologyLock topologyAppLock = topologyLockHierarchy.getTopologyLockForApplication(appId);
- if (topologyAppLock == null) {
- handleLockNotFound("Topology lock not found for Application " + appId);
-
- } else {
- // now, lock Application
- topologyAppLock.acquireWriteLock();
- if(log.isDebugEnabled()) {
- log.debug("Write lock acquired for Application " + appId);
- }
- }
- }
-
- /**
- * Releases write lock for the Application
- *
- * @param appId Application id
- */
- public static void releaseWriteLockForApplication (String appId) {
-
- TopologyLock topologyAppLock = topologyLockHierarchy.getTopologyLockForApplication(appId);
- if (topologyAppLock == null) {
- handleLockNotFound("Topology lock not found for Application " + appId);
-
- } else {
- // release App lock
- topologyAppLock.releaseWritelock();
- if(log.isDebugEnabled()) {
- log.debug("Write lock released for Application " + appId);
- }
- }
-
- // release read lock for all Applications
- TopologyManager.releaseReadLockForApplications();
- }
-
private static void handleLockNotFound (String errorMsg) {
log.warn(errorMsg);
//throw new RuntimeException(errorMsg);
http://git-wip-us.apache.org/repos/asf/stratos/blob/c42d7c1d/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/applications/ApplicationManager.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/applications/ApplicationManager.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/applications/ApplicationManager.java
new file mode 100644
index 0000000..0c3aa0e
--- /dev/null
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/applications/ApplicationManager.java
@@ -0,0 +1,119 @@
+/*
+ * 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.receiver.applications;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.messaging.domain.applications.Applications;
+import org.apache.stratos.messaging.domain.applications.locking.ApplicationLock;
+import org.apache.stratos.messaging.domain.applications.locking.ApplicationLockHierarchy;
+
+public class ApplicationManager {
+
+ private static final Log log = LogFactory.getLog(ApplicationManager.class);
+
+ private static volatile Applications applications;
+ private static volatile ApplicationLockHierarchy applicationLockHierarchy =
+ ApplicationLockHierarchy.getInstance();
+
+ public static Applications getApplications () {
+
+ if (applications == null) {
+ synchronized (ApplicationManager.class){
+ if (applications == null) {
+ applications = new Applications();
+ if(log.isDebugEnabled()) {
+ log.debug("Applications object created");
+ }
+ }
+ }
+ }
+ return applications;
+ }
+
+ /**
+ * Acquires read lock for all Applications
+ */
+ public static void acquireReadLockForApplications() {
+ if(log.isDebugEnabled()) {
+ log.debug("Read lock acquired for Applications");
+ }
+ applicationLockHierarchy.getApplicationLock().acquireReadLock();
+ }
+
+ /**
+ * Releases read lock for all Applications
+ */
+ public static void releaseReadLockForApplications() {
+ if(log.isDebugEnabled()) {
+ log.debug("Read lock released for Applications");
+ }
+ applicationLockHierarchy.getApplicationLock().releaseReadLock();
+ }
+
+ /**
+ * Acquires read lock for an Application
+ *
+ * @param applicationId Application Id to acquire read lock
+ */
+ public static void acquireReadLockForApplication(String applicationId) {
+
+ // acquire read lock for all Applications
+ acquireReadLockForApplications();
+
+ ApplicationLock applicationLock = applicationLockHierarchy.getLockForApplication(applicationId);
+ if (applicationLock == null) {
+ handleLockNotFound("Application lock not found for Application " + applicationId);
+
+ } else {
+ applicationLock.acquireReadLock();
+ if(log.isDebugEnabled()) {
+ log.debug("Read lock acquired for Application " + applicationId);
+ }
+ }
+ }
+
+ /**
+ * Releases read lock for an Application
+ *
+ * @param applicationId Application Id to release read lock
+ */
+ public static void releaseReadLockForApplication(String applicationId) {
+
+ ApplicationLock applicationLock = applicationLockHierarchy.getLockForApplication(applicationId);
+ if (applicationLock == null) {
+ handleLockNotFound("Application lock not found for Application " + applicationId);
+
+ } else {
+ applicationLock.releaseReadLock();
+ if(log.isDebugEnabled()) {
+ log.debug("Read lock released for Application " + applicationId);
+ }
+ }
+
+ // release read lock for all Applications
+ releaseReadLockForApplications();
+ }
+
+ private static void handleLockNotFound (String errorMsg) {
+ log.warn(errorMsg);
+ //throw new RuntimeException(errorMsg);
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/c42d7c1d/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/topology/TopologyManager.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/topology/TopologyManager.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/topology/TopologyManager.java
index 1d74616..159e128 100644
--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/topology/TopologyManager.java
+++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/topology/TopologyManager.java
@@ -85,26 +85,7 @@ public class TopologyManager {
topologyLockHierarchy.getCompleteTopologyLock().releaseReadLock();
}
- // Application and Service read locks
- /**
- * Acquires read lock for the all Applications
- */
- public static void acquireReadLockForApplications() {
- if(log.isDebugEnabled()) {
- log.debug("Read lock acquired for Applications");
- }
- topologyLockHierarchy.getApplicatioLock().acquireReadLock();
- }
-
- /**
- * Releases read lock for the all Applications
- */
- public static void releaseReadLockForApplications() {
- if(log.isDebugEnabled()) {
- log.debug("Read lock released for Applications");
- }
- topologyLockHierarchy.getApplicatioLock().releaseReadLock();
- }
+ // Service read locks
/**
* Acquires read lock for the all Services
@@ -222,52 +203,6 @@ public class TopologyManager {
releaseReadLockForService(serviceName);
}
- /**
- * Acquires read lock for the Application
- *
- * @param appId Application id
- */
- public static void acquireReadLockForApplication (String appId) {
-
- // acquire read lock for all Applications
- acquireReadLockForApplications();
-
- TopologyLock topologyAppLock = topologyLockHierarchy.getTopologyLockForApplication(appId);
- if (topologyAppLock == null) {
- handleLockNotFound("Topology lock not found for Application " + appId);
-
- } else {
- // now, lock Application
- topologyAppLock.acquireReadLock();
- if(log.isDebugEnabled()) {
- log.debug("Read lock acquired for Application " + appId);
- }
- }
- }
-
- /**
- * Releases read lock for the Application
- *
- * @param appId Application id
- */
- public static void releaseReadLockForApplication (String appId) {
-
- TopologyLock topologyAppLock = topologyLockHierarchy.getTopologyLockForApplication(appId);
- if (topologyAppLock == null) {
- handleLockNotFound("Topology lock not found for Application " + appId);
-
- } else {
- // release App lock
- topologyAppLock.releaseReadLock();
- if(log.isDebugEnabled()) {
- log.debug("Read lock released for Application " + appId);
- }
- }
-
- // release read lock for all Applications
- releaseReadLockForApplications();
- }
-
private static void handleLockNotFound (String errorMsg) {
log.warn(errorMsg);
//throw new RuntimeException(errorMsg);