stratos-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From isu...@apache.org
Subject git commit: fixing bugs
Date Fri, 10 Oct 2014 09:45:01 GMT
Repository: stratos
Updated Branches:
  refs/heads/4.0.0-grouping 62387055a -> d11103577


fixing bugs


Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/d1110357
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/d1110357
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/d1110357

Branch: refs/heads/4.0.0-grouping
Commit: d11103577c1f86e59d0fdcdb3aa4db96bbef086e
Parents: 6238705
Author: Isuru Haththotuwa <isuruh@apache.org>
Authored: Fri Oct 10 15:14:26 2014 +0530
Committer: Isuru Haththotuwa <isuruh@apache.org>
Committed: Fri Oct 10 15:14:26 2014 +0530

----------------------------------------------------------------------
 .../stratos/autoscaler/monitor/Monitor.java     |  4 +--
 .../CompleteTopologyMessageProcessor.java       | 27 +++++++++++++++++---
 .../topology/updater/TopologyUpdater.java       |  2 +-
 .../receiver/topology/TopologyManager.java      |  2 +-
 4 files changed, 28 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/d1110357/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/Monitor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/Monitor.java
b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/Monitor.java
index 800ed64..3cdcdc5 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/Monitor.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/Monitor.java
@@ -131,7 +131,7 @@ public abstract class Monitor implements EventHandler {
                 }
                 Cluster cluster;
                 //acquire read lock for the service and cluster
-                TopologyManager.acquireReadLockForCluster(clusterId, serviceName);
+                TopologyManager.acquireReadLockForCluster(serviceName, clusterId);
                 try {
                     Topology topology = TopologyManager.getTopology();
                     if (topology.serviceExists(serviceName)) {
@@ -154,7 +154,7 @@ public abstract class Monitor implements EventHandler {
                     }
                 } finally {
                     //release read lock for the service and cluster
-                    TopologyManager.releaseReadLockForCluster(clusterId, serviceName);
+                    TopologyManager.releaseReadLockForCluster(serviceName, clusterId);
                 }
             }
         }

http://git-wip-us.apache.org/repos/asf/stratos/blob/d1110357/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 6414951..f6af300 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
@@ -21,6 +21,8 @@ package org.apache.stratos.messaging.message.processor.topology;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.stratos.messaging.domain.topology.*;
+import org.apache.stratos.messaging.domain.topology.locking.TopologyLock;
+import org.apache.stratos.messaging.domain.topology.locking.TopologyLockHierarchy;
 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;
@@ -55,9 +57,7 @@ public class CompleteTopologyMessageProcessor extends MessageProcessor {
                 TopologyUpdater.acquireWriteLock();
 
                 try {
-                    if (!topology.isInitialized()) {
-                        doProcess(event, topology);
-                    }
+                    doProcess(event, topology);
 
                 } finally {
                     TopologyUpdater.releaseWriteLock();
@@ -79,6 +79,9 @@ public class CompleteTopologyMessageProcessor extends MessageProcessor {
 
     private void doProcess (CompleteTopologyEvent event, Topology topology) {
 
+        // add locks for all the Clusters currently in Topology
+        addTopologyLocksForClusters(event.getTopology().getServices());
+
         // Apply service filter
         if (TopologyServiceFilter.getInstance().isActive()) {
             // Add services included in service filter
@@ -167,4 +170,22 @@ public class CompleteTopologyMessageProcessor extends MessageProcessor
{
         // Set topology initialized
         topology.setInitialized(true);
     }
+
+
+    private void addTopologyLocksForClusters (Collection<Service> services) {
+
+        if (services == null) {
+            return;
+        }
+
+        for (Service service : services) {
+            // get all the clusters and add locks
+            if (service.getClusters() != null) {
+                for (Cluster aCluster: service.getClusters()) {
+                    TopologyLockHierarchy.getInstance().addClusterLock(aCluster.getClusterId(),
+                            new TopologyLock());
+                }
+            }
+        }
+    }
 }

http://git-wip-us.apache.org/repos/asf/stratos/blob/d1110357/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 3da5835..9867223 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
@@ -59,7 +59,7 @@ public class TopologyUpdater {
 
     private static final Log log = LogFactory.getLog(TopologyUpdater.class);
 
-    private static final TopologyLockHierarchy topologyLockHierarchy = TopologyLockHierarchy.getInstance();
+    private static volatile TopologyLockHierarchy topologyLockHierarchy = TopologyLockHierarchy.getInstance();
 
     // Top level locks - should be used to lock the entire Topology
 

http://git-wip-us.apache.org/repos/asf/stratos/blob/d1110357/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 fbb2faf..1d74616 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
@@ -62,7 +62,7 @@ public class TopologyManager {
     private static final Log log = LogFactory.getLog(TopologyManager.class);
 
     private static volatile Topology topology;
-    private static final TopologyLockHierarchy topologyLockHierarchy =
+    private static volatile TopologyLockHierarchy topologyLockHierarchy =
             TopologyLockHierarchy.getInstance();
 
     /**


Mime
View raw message