Sahina Bose has uploaded a new change for review.

Change subject: gluster: Resolve conflict for gluster hook content
......................................................................

gluster: Resolve conflict for gluster hook content

While resolving content conflict in gluster hook and
user chooses the hook content from one of the server,
the hook should be copied on all servers - not just
conflicting servers.

Change-Id: Ifc2d8ad65af2e019eda0d24b6b1f2f87561c8f73
Bug-Url: https://bugzilla.redhat.com/973137
Signed-off-by: Sahina Bose <sab...@redhat.com>
---
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/AddGlusterHookCommand.java
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/GlusterHookCommandBase.java
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/UpdateGlusterHookCommand.java
3 files changed, 37 insertions(+), 12 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/17/15717/1

diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/AddGlusterHookCommand.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/AddGlusterHookCommand.java
index 7db01ce..08bb4b8 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/AddGlusterHookCommand.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/AddGlusterHookCommand.java
@@ -135,7 +135,7 @@
 
         if (getSucceeded()) {
             entity.removeMissingConflict();
-            getGlusterHooksDao().updateGlusterHook(entity);
+            updateGlusterHook(entity);
         }
 
     }
diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/GlusterHookCommandBase.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/GlusterHookCommandBase.java
index 391ad33..82ab56e 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/GlusterHookCommandBase.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/GlusterHookCommandBase.java
@@ -77,4 +77,12 @@
         getGlusterHooksDao().saveGlusterServerHook(serverHook);
     }
 
+    protected void updateGlusterHook(GlusterHookEntity entity) {
+        if (entity.getConflictStatus() == 0) {
+            getGlusterHooksDao().removeGlusterServerHooks(entity.getId());
+        }
+        getGlusterHooksDao().updateGlusterHook(entity);
+
+    }
+
 }
diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/UpdateGlusterHookCommand.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/UpdateGlusterHookCommand.java
index bb9e02b..99fc05a 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/UpdateGlusterHookCommand.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/UpdateGlusterHookCommand.java
@@ -23,6 +23,7 @@
 import org.ovirt.engine.core.common.vdscommands.VDSCommandType;
 import org.ovirt.engine.core.common.vdscommands.VDSReturnValue;
 import 
org.ovirt.engine.core.common.vdscommands.gluster.GlusterHookVDSParameters;
+import org.ovirt.engine.core.compat.Guid;
 import org.ovirt.engine.core.utils.threadpool.ThreadPoolUtil;
 
 /**
@@ -81,7 +82,7 @@
     @Override
     protected void executeCommand() {
         //check source to copy hook from - if engine copy or server copy
-        final Boolean copyfromEngine = (getParameters().getSourceServerId() == 
null) ?  true : false;
+        final Boolean copyfromEngine = (getParameters().getSourceServerId() == 
null);
 
         entity = getGlusterHook();
         addCustomValue(GlusterConstants.HOOK_NAME, entity.getName());
@@ -112,22 +113,37 @@
         }
 
 
-        List<Callable<Pair<GlusterServerHook, VDSReturnValue>>> taskList = new 
ArrayList<Callable<Pair<GlusterServerHook, VDSReturnValue>>>();
-        for (final GlusterServerHook serverHook : 
getContentConflictServerHooks()) {
-            taskList.add(new Callable<Pair<GlusterServerHook, 
VDSReturnValue>>() {
+        List<Callable<Pair<Guid, VDSReturnValue>>> taskList = new 
ArrayList<Callable<Pair<Guid, VDSReturnValue>>>();
+        List<Guid> serverIdsToUpdate = new ArrayList<Guid>();
+        if (copyfromEngine) {
+            for (final GlusterServerHook serverHook : 
getContentConflictServerHooks()) {
+                serverIdsToUpdate.add(serverHook.getServerId());
+            }
+        } else {
+            // if copying from one of the servers, all servers other than 
source server
+            // need to be updated with hook content
+            for (final VDS server : 
getClusterUtils().getAllUpServers(entity.getClusterId())) {
+                if 
(!server.getId().equals(getParameters().getSourceServerId())) {
+                    serverIdsToUpdate.add(server.getId());
+                }
+            }
+        }
+
+        for (final Guid serverId : serverIdsToUpdate) {
+            taskList.add(new Callable<Pair<Guid, VDSReturnValue>>() {
                 @Override
-                public Pair<GlusterServerHook, VDSReturnValue> call() throws 
Exception {
+                public Pair<Guid, VDSReturnValue> call() throws Exception {
                     VDSReturnValue returnValue;
                         returnValue =
                                runVdsCommand(
                                        VDSCommandType.UpdateGlusterHook,
-                                       new 
GlusterHookVDSParameters(serverHook.getServerId(),
+                                       new GlusterHookVDSParameters(serverId,
                                                entity.getGlusterCommand(),
                                                entity.getStage(),
                                                entity.getName(),
                                                hookContent,
                                                hookChecksum));
-                     return new Pair<GlusterServerHook, 
VDSReturnValue>(serverHook, returnValue);
+                     return new Pair<Guid, VDSReturnValue>(serverId, 
returnValue);
 
                 }
             });
@@ -135,8 +151,8 @@
 
         setSucceeded(true);
         if (!taskList.isEmpty()) {
-            List<Pair<GlusterServerHook, VDSReturnValue>> pairResults = 
ThreadPoolUtil.invokeAll(taskList);
-            for (Pair<GlusterServerHook, VDSReturnValue> pairResult : 
pairResults) {
+            List<Pair<Guid, VDSReturnValue>> pairResults = 
ThreadPoolUtil.invokeAll(taskList);
+            for (Pair<Guid, VDSReturnValue> pairResult : pairResults) {
 
                 VDSReturnValue retValue = pairResult.getSecond();
                 if (!retValue.getSucceeded() ) {
@@ -162,10 +178,11 @@
         }
 
         if (getSucceeded()) {
-            entity.removeMissingConflict();
-            getGlusterHooksDao().updateGlusterHook(entity);
+            entity.removeContentConflict();
+            updateGlusterHook(entity);
         }
 
+
     }
 
 


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ifc2d8ad65af2e019eda0d24b6b1f2f87561c8f73
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Sahina Bose <sab...@redhat.com>
_______________________________________________
Engine-patches mailing list
Engine-patches@ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to