cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From yas...@apache.org
Subject [1/3] git commit: updated refs/heads/master to 3e097a0
Date Tue, 11 Mar 2014 20:24:35 GMT
Repository: cloudstack
Updated Branches:
  refs/heads/master 36558e461 -> 3e097a0fb


CLOUDSTACK-6218: Serialize VR commands in VR resource


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

Branch: refs/heads/master
Commit: b399c315a3fceae699fa24dc1ff2bbae191ddd07
Parents: 36558e4
Author: Sheng Yang <sheng.yang@citrix.com>
Authored: Mon Mar 10 12:52:07 2014 -0700
Committer: Sheng Yang <sheng.yang@citrix.com>
Committed: Tue Mar 11 11:58:56 2014 -0700

----------------------------------------------------------------------
 .../virtualnetwork/VirtualRoutingResource.java       | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b399c315/core/src/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResource.java
----------------------------------------------------------------------
diff --git a/core/src/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResource.java
b/core/src/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResource.java
index f22a0db..29a176a 100755
--- a/core/src/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResource.java
+++ b/core/src/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResource.java
@@ -77,6 +77,8 @@ import java.util.Map;
 import java.util.Queue;
 import java.util.UUID;
 import java.util.concurrent.LinkedBlockingQueue;
+import java.util.concurrent.locks.Lock;
+import java.util.concurrent.locks.ReentrantLock;
 
 /**
  * VirtualNetworkResource controls and configures virtual networking
@@ -123,6 +125,7 @@ public class VirtualRoutingResource {
     private static final Logger s_logger = Logger.getLogger(VirtualRoutingResource.class);
     private VirtualRouterDeployer _vrDeployer;
     private Map <String, Queue> _vrAggregateCommandsSet;
+    protected Map<String, Lock> _vrLockMap = new HashMap<String, Lock>();
 
     private String _name;
     private int _sleep;
@@ -137,13 +140,22 @@ public class VirtualRoutingResource {
 
     public Answer executeRequest(final NetworkElementCommand cmd) {
         boolean aggregated = false;
+        String routerName = cmd.getAccessDetail(NetworkElementCommand.ROUTER_NAME);
+        Lock lock;
+        if (_vrLockMap.containsKey(routerName)) {
+            lock = _vrLockMap.get(routerName);
+        } else {
+            lock = new ReentrantLock();
+            _vrLockMap.put(routerName, lock);
+        }
+        lock.lock();
+
         try {
             ExecutionResult rc = _vrDeployer.prepareCommand(cmd);
             if (!rc.isSuccess()) {
                 s_logger.error("Failed to prepare VR command due to " + rc.getDetails());
                 return new Answer(cmd, false, rc.getDetails());
             }
-            String routerName = cmd.getAccessDetail(NetworkElementCommand.ROUTER_NAME);
 
             assert cmd.getRouterAccessIp() != null : "Why there is no access IP for VR?";
 
@@ -174,6 +186,7 @@ public class VirtualRoutingResource {
         } catch (final IllegalArgumentException e) {
             return new Answer(cmd, false, e.getMessage());
         } finally {
+            lock.unlock();
             if (!aggregated) {
                 ExecutionResult rc = _vrDeployer.cleanupCommand(cmd);
                 if (!rc.isSuccess()) {


Mime
View raw message