Liron Aravot has uploaded a new change for review. Change subject: core: removal unneeded boolean and finally block from recovery command. ......................................................................
core: removal unneeded boolean and finally block from recovery command. *removal of unneeded boolean *removal of unneeded finally block Change-Id: I5c14601c1b9f5097c600c0139f785cbe43f4a588 Signed-off-by: Liron Aravot <lara...@redhat.com> --- M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/RecoveryStoragePoolCommand.java 1 file changed, 55 insertions(+), 51 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/20/11620/1 diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/RecoveryStoragePoolCommand.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/RecoveryStoragePoolCommand.java index cf06178..414607f 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/RecoveryStoragePoolCommand.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/RecoveryStoragePoolCommand.java @@ -92,62 +92,66 @@ @Override protected void executeCommand() { - boolean reconstructOpSucceeded = false; - try { - if (StorageHelperDirector.getInstance().getItem(getStorageDomain().getstorage_type()) - .connectStorageToDomainByVdsId(getNewMaster(false), getVds().getId())) { - getRecoveryStoragePoolParametersData().setStorageDomainId(getStorageDomainId().getValue()); - EventResult res = ((EventQueue) EjbUtils.findBean(BeanType.EVENTQUEUE_MANAGER, BeanProxyType.LOCAL)).submitEventSync(new Event(getRecoveryStoragePoolParametersData().getStoragePoolId(), - _newMasterStorageDomainId, - null, - EventType.RECOVERY), - new Callable<EventResult>() { - @Override - public EventResult call() { - // set those to null in order to reload them during canDoAction - - // canDo checks should be performed on updated values and not staled ones. - // canDoAction checks are needed here as Recovery operations aren't cleared from the event queue - // after reconstruct, in order to provide the user ability to recover from the state of non working pool - // without him to be in a race with automatic triggered reconstruct. because of that, we don't want to run - // the recovery operation if it's unneeded so we need to re-check the canDoAction result. canDoAction() method was - // as is in order to provide the user immediate response whether it's possible to initiate the command when - // he attempts to run recovery. - setStorageDomain(null); - setStoragePool(null); - boolean succeded = false; - if (canDoAction()) { - StoragePoolIsoMap domainPoolMap = - new StoragePoolIsoMap(getRecoveryStoragePoolParametersData() - .getNewMasterDomainId(), - getRecoveryStoragePoolParametersData().getStoragePoolId(), - StorageDomainStatus.Active); - DbFacade.getInstance() - .getStoragePoolIsoMapDao() - .save(domainPoolMap); + if (StorageHelperDirector.getInstance().getItem(getStorageDomain().getstorage_type()) + .connectStorageToDomainByVdsId(getNewMaster(false), getVds().getId())) { + getRecoveryStoragePoolParametersData().setStorageDomainId(getStorageDomainId().getValue()); - getRecoveryStoragePoolParametersData().setVdsId(getVds().getId()); - VdcReturnValueBase returnVal = Backend.getInstance().runInternalAction( - VdcActionType.ReconstructMasterDomain, getParameters()); + ((EventQueue) EjbUtils.findBean(BeanType.EVENTQUEUE_MANAGER, BeanProxyType.LOCAL)).submitEventSync(new Event(getRecoveryStoragePoolParametersData().getStoragePoolId(), + _newMasterStorageDomainId, + null, + EventType.RECOVERY), + new Callable<EventResult>() { + @Override + public EventResult call() { + // set those to null in order to reload them during canDoAction - + // canDo checks should be performed on updated values and not staled ones. + // canDoAction checks are needed here as Recovery operations aren't cleared from the + // event queue + // after reconstruct, in order to provide the user ability to recover from the state + // of non working pool + // without him to be in a race with automatic triggered reconstruct. because of + // that, we don't want to run + // the recovery operation if it's unneeded so we need to re-check the canDoAction + // result. canDoAction() method was + // as is in order to provide the user immediate response whether it's possible to + // initiate the command when + // he attempts to run recovery. + setStorageDomain(null); + setStoragePool(null); + boolean succeded = false; + if (canDoAction()) { + StoragePoolIsoMap domainPoolMap = + new StoragePoolIsoMap(getRecoveryStoragePoolParametersData() + .getNewMasterDomainId(), + getRecoveryStoragePoolParametersData().getStoragePoolId(), + StorageDomainStatus.Active); + DbFacade.getInstance() + .getStoragePoolIsoMapDao() + .save(domainPoolMap); - succeded = (returnVal.getActionReturnValue() != null) ? - (Boolean)returnVal.getActionReturnValue() : false; + getRecoveryStoragePoolParametersData().setVdsId(getVds().getId()); + VdcReturnValueBase returnVal = Backend.getInstance().runInternalAction( + VdcActionType.ReconstructMasterDomain, getParameters()); - getStoragePoolDAO().updateStatus(getStoragePool().getId(), StoragePoolStatus.Problematic); + succeded = (returnVal.getActionReturnValue() != null) ? + (Boolean) returnVal.getActionReturnValue() : false; + + getStoragePoolDAO().updateStatus(getStoragePool().getId(), + StoragePoolStatus.Problematic); + + if (!succeded) { + getStoragePoolIsoMapDAO().remove(new StoragePoolIsoMapId(getRecoveryStoragePoolParametersData() + .getNewMasterDomainId(), + getRecoveryStoragePoolParametersData().getStoragePoolId())); } - return new EventResult(succeded, EventType.RECONSTRUCT); } - }); - reconstructOpSucceeded = res != null ? res.isSuccess() : false; - } else { - getReturnValue().setFault(new VdcFault(new VdcBLLException(VdcBllErrors.StorageServerConnectionError, - "Failed to connect storage"), - VdcBllErrors.StorageServerConnectionError)); - } - } finally { - if (!reconstructOpSucceeded) { - getStoragePoolIsoMapDAO().remove(new StoragePoolIsoMapId(getRecoveryStoragePoolParametersData() - .getNewMasterDomainId(), getRecoveryStoragePoolParametersData().getStoragePoolId())); - } + return new EventResult(succeded, EventType.RECONSTRUCT); + } + }); + } else { + getReturnValue().setFault(new VdcFault(new VdcBLLException(VdcBllErrors.StorageServerConnectionError, + "Failed to connect storage"), + VdcBllErrors.StorageServerConnectionError)); } } } -- To view, visit http://gerrit.ovirt.org/11620 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I5c14601c1b9f5097c600c0139f785cbe43f4a588 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Liron Aravot <lara...@redhat.com> _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches