Martin Peřina has uploaded a new change for review.

Change subject: core: Introduce createFenceExecutor method
......................................................................

core: Introduce createFenceExecutor method

Introduces createFenceExecutor() method with fence action type as
a parameter, which will create FenceExecutor instance with specified
fence action type and other parameters with default values.

Change-Id: Id4630801fc7b6940caabb646c653ef10df3f63a4
Bug-Url: https://bugzilla.redhat.com/1090799
Signed-off-by: Martin Perina <mper...@redhat.com>
---
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/FenceVdsBaseCommand.java
1 file changed, 22 insertions(+), 12 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/35/31235/1

diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/FenceVdsBaseCommand.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/FenceVdsBaseCommand.java
index 21babcc..2180d88 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/FenceVdsBaseCommand.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/FenceVdsBaseCommand.java
@@ -202,12 +202,12 @@
      * @param lastStatus
      */
     private void handleSingleAgent(VDSStatus lastStatus, VDSReturnValue 
vdsReturnValue) {
-        executor = new FenceExecutor(getVds(), getParameters().getAction());
+        executor = createFenceExecutor(getParameters().getAction());
         if (executor.findProxyHost()) {
             vdsReturnValue = executor.fence();
             setFenceSucceeded(vdsReturnValue.getSucceeded());
             if (getFenceSucceeded()) {
-                executor = new FenceExecutor(getVds(), FenceActionType.Status);
+                executor = createFenceExecutor(FenceActionType.Status);
                 if (waitForStatus(getVds().getName(), 
getParameters().getAction(), FenceAgentOrder.Primary)) {
                     handleSpecificCommandActions();
                 } else {
@@ -229,17 +229,17 @@
      * @param lastStatus
      */
     private void handleMultipleSequentialAgents(VDSStatus lastStatus, 
VDSReturnValue vdsReturnValue) {
-        executor = new FenceExecutor(getVds(), getParameters().getAction());
+        executor = createFenceExecutor(getParameters().getAction());
         if (executor.findProxyHost()) {
             vdsReturnValue = executor.fence(FenceAgentOrder.Primary);
             setFenceSucceeded(vdsReturnValue.getSucceeded());
             if (getFenceSucceeded()) {
-                executor = new FenceExecutor(getVds(), FenceActionType.Status);
+                executor = createFenceExecutor(FenceActionType.Status);
                 if (waitForStatus(getVds().getName(), 
getParameters().getAction(), FenceAgentOrder.Primary)) {
                     handleSpecificCommandActions();
                 } else {
                     // set the executor to perform the action
-                    executor = new FenceExecutor(getVds(), 
getParameters().getAction());
+                    executor = 
createFenceExecutor(getParameters().getAction());
                     tryOtherSequentialAgent(lastStatus, vdsReturnValue);
                 }
             } else {
@@ -257,12 +257,12 @@
      * @param lastStatus
      */
     private void tryOtherSequentialAgent(VDSStatus lastStatus, VDSReturnValue 
vdsReturnValue) {
-        executor = new FenceExecutor(getVds(), getParameters().getAction());
+        executor = createFenceExecutor(getParameters().getAction());
         if (executor.findProxyHost()) {
             vdsReturnValue = executor.fence(FenceAgentOrder.Secondary);
             setFenceSucceeded(vdsReturnValue.getSucceeded());
             if (getFenceSucceeded()) {
-                executor = new FenceExecutor(getVds(), FenceActionType.Status);
+                executor = createFenceExecutor(FenceActionType.Status);
                 if (waitForStatus(getVds().getName(), 
getParameters().getAction(), FenceAgentOrder.Secondary)) {
                     // raise an alert that secondary agent was used
                     AuditLogableBase logable = new AuditLogableBase();
@@ -292,8 +292,8 @@
      * @param lastStatus
      */
     private void handleMultipleConcurrentAgents(VDSStatus lastStatus, 
VDSReturnValue vdsReturnValue) {
-        primaryExecutor = new FenceExecutor(getVds(), 
getParameters().getAction());
-        secondaryExecutor = new FenceExecutor(getVds(), 
getParameters().getAction());
+        primaryExecutor = createFenceExecutor(getParameters().getAction());
+        secondaryExecutor = createFenceExecutor(getParameters().getAction());
         if (primaryExecutor.findProxyHost() && 
secondaryExecutor.findProxyHost()) {
             primaryResult = new FenceInvocationResult();
             secondaryResult = new FenceInvocationResult();
@@ -392,7 +392,7 @@
         fenceInvocationResult.setOrder(order);
         fenceInvocationResult.setValue(fenceExecutor.fence(order));
         if (fenceInvocationResult.getValue().getSucceeded()) {
-            this.executor = new FenceExecutor(getVds(), 
FenceActionType.Status);
+            this.executor = createFenceExecutor(FenceActionType.Status);
             
fenceInvocationResult.setSucceeded(waitForStatus(getVds().getName(), 
getParameters().getAction(), order));
         }
         return fenceInvocationResult;
@@ -404,11 +404,11 @@
         // invocation and not on its result), we have to try the Start command 
again
         // before giving up
         if (getParameters().getAction() == FenceActionType.Start) {
-            executor = new FenceExecutor(getVds(), FenceActionType.Start);
+            executor = createFenceExecutor(FenceActionType.Start);
             vdsReturnValue = executor.fence(order);
             setFenceSucceeded(vdsReturnValue.getSucceeded());
             if (getFenceSucceeded()) {
-                executor = new FenceExecutor(getVds(), FenceActionType.Status);
+                executor = createFenceExecutor(FenceActionType.Status);
                 if (waitForStatus(getVds().getName(), FenceActionType.Start, 
order)) {
                     handleSpecificCommandActions();
                 } else {
@@ -611,4 +611,14 @@
                 LockingGroup.VDS_FENCE,
                 
VdcBllMessages.POWER_MANAGEMENT_ACTION_ON_ENTITY_ALREADY_IN_PROGRESS));
     }
+
+    /**
+     * Creates {@code FenceExecutor} instance with default VDS and specified 
fence action type
+     */
+    private FenceExecutor createFenceExecutor(FenceActionType actionType) {
+        return new FenceExecutor(
+                getVds(),
+                actionType
+        );
+    }
 }


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Id4630801fc7b6940caabb646c653ef10df3f63a4
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: ovirt-engine-3.5
Gerrit-Owner: Martin Peřina <mper...@redhat.com>
_______________________________________________
Engine-patches mailing list
Engine-patches@ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to