Alissa Bonas has uploaded a new change for review.

Change subject: core: add lock of storage conn id to edit/rmv conn
......................................................................

core: add lock of storage conn id to edit/rmv conn

Add locking of connection's id when editing/removing the connection
to avoid edit/removing it in the same time by a different user/request.

Change-Id: I5da517d69789ead2b891498b8086b15a6899269e
Signed-off-by: Alissa Bonas <[email protected]>
---
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/RemoveStorageServerConnectionCommand.java
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/UpdateStorageServerConnectionCommand.java
2 files changed, 16 insertions(+), 4 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/09/16009/1

diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/RemoveStorageServerConnectionCommand.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/RemoveStorageServerConnectionCommand.java
index 854e4b4..c2f78ee 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/RemoveStorageServerConnectionCommand.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/RemoveStorageServerConnectionCommand.java
@@ -1,7 +1,7 @@
 package org.ovirt.engine.core.bll.storage;
 
 import java.util.ArrayList;
-import java.util.Collections;
+import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
@@ -140,9 +140,16 @@
 
     @Override
     protected Map<String, Pair<String, String>> getExclusiveLocks() {
-        return Collections.singletonMap(getConnection().getconnection(),
+        Map<String, Pair<String, String>> locks = new HashMap<String, 
Pair<String, String>>();
+        locks.put(getConnection().getconnection(),
                 
LockMessagesMatchUtil.makeLockingPair(LockingGroup.STORAGE_CONNECTION,
                         VdcBllMessages.ACTION_TYPE_FAILED_OBJECT_LOCKED));
+        // lock connection's id to avoid editing or removing this connection 
at the same time
+        // by another user
+        locks.put(getConnection().getid(),
+                
LockMessagesMatchUtil.makeLockingPair(LockingGroup.STORAGE_CONNECTION,
+                        VdcBllMessages.ACTION_TYPE_FAILED_OBJECT_LOCKED));
+        return locks;
     }
 
     @Override
diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/UpdateStorageServerConnectionCommand.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/UpdateStorageServerConnectionCommand.java
index caf9aa4..700d64a 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/UpdateStorageServerConnectionCommand.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/UpdateStorageServerConnectionCommand.java
@@ -267,11 +267,16 @@
                     LockMessagesMatchUtil.makeLockingPair(LockingGroup.STORAGE,
                             VdcBllMessages.ACTION_TYPE_FAILED_OBJECT_LOCKED));
         }
-        // lock the path to NFS to avoid at the same time if some other user 
tries to:
-        // add new storage domain to same path or edit another storage server 
connection to point to same path
+        // lock the path to avoid at the same time if some other user tries to:
+        // add new storage connection to same path or edit another storage 
server connection to point to same path
         locks.put(getParameters().getStorageServerConnection().getconnection(),
                 
LockMessagesMatchUtil.makeLockingPair(LockingGroup.STORAGE_CONNECTION,
                         VdcBllMessages.ACTION_TYPE_FAILED_OBJECT_LOCKED));
+        // lock connection's id to avoid editing or removing this connection 
at the same time
+        // by another user
+        locks.put(getParameters().getStorageServerConnection().getid(),
+                
LockMessagesMatchUtil.makeLockingPair(LockingGroup.STORAGE_CONNECTION,
+                        VdcBllMessages.ACTION_TYPE_FAILED_OBJECT_LOCKED));
         return locks;
     }
 


-- 
To view, visit http://gerrit.ovirt.org/16009
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I5da517d69789ead2b891498b8086b15a6899269e
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Alissa Bonas <[email protected]>
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to