Source:
public void attemptResolution() { Pair<Boolean, VmJob> isMergeRunning = isMergeRunning(); if (isMergeRunning.getFirst()) { log.debug("Merge is already running, job id is: {}", isMergeRunning.getSecond().getId()); MergeStatusReturnValue returnValue = new MergeStatusReturnValue(); returnValue.setIsMergeRunning(true); getReturnValue().setActionReturnValue(returnValue); return; } Set<Guid> chainFromStorage; if (getVmDao().get(getParameters().getVmId()).isDown()) { StoragePool pool = getStoragePoolDao().get(getParameters().getStoragePoolId()); if (pool.getSpmVdsId() == null || pool.getStatus() != StoragePoolStatus.Up) { log.info("VM down, waiting on SPM election to resolve Live Merge"); setSucceeded(true); return; } else { log.error("VM is not running, proceeding with Live Merge recovery"); chainFromStorage = getVolumeChainFromRecovery(); } } else { chainFromStorage = getVolumeChain(); } if (chainFromStorage == null) { setCommandStatus(CommandStatus.FAILED); return; } Collection<Guid> imagesToRemove = CollectionUtils.subtract(getImageChainFromDb(), chainFromStorage); if (imagesToRemove.size() != 1) { log.error("Failed to live merge, still in volume chain: {}", imagesToRemove); setCommandStatus(CommandStatus.FAILED); return; } log.info("Successfully removed volume(s): {}", imagesToRemove); VmBlockJobType jobType = chainFromStorage.contains(getParameters().getBaseImage().getImageId()) ? VmBlockJobType.COMMIT : VmBlockJobType.PULL; log.info("Volume merge type '{}'", jobType.name()); MergeStatusReturnValue returnValue = new MergeStatusReturnValue(jobType, Collections.singleton(imagesToRemove.stream().findFirst().get())); getReturnValue().setActionReturnValue(returnValue); setSucceeded(true); persistCommand(getParameters().getParentCommand(), true); setCommandStatus(CommandStatus.SUCCEEDED); }

Target:
public void attemptResolution() { Pair<Boolean, VmBlockJob> isMergeRunning = isMergeRunning(); if (isMergeRunning.getFirst()) { log.info("Merge is already running, job id is: {}", isMergeRunning.getSecond().getId()); MergeStatusReturnValue returnValue = new MergeStatusReturnValue(); returnValue.setIsMergeRunning(true); getReturnValue().setActionReturnValue(returnValue); return; } Set<Guid> chainFromStorage; if (getVmDao().get(getParameters().getVmId()).isDown()) { StoragePool pool = getStoragePoolDao().get(getParameters().getStoragePoolId()); if (pool.getSpmVdsId() == null || pool.getStatus() != StoragePoolStatus.Up) { log.info("VM down, waiting on SPM election to resolve Live Merge"); setSucceeded(true); return; } else { log.error("VM is not running, proceeding with Live Merge recovery"); chainFromStorage = getVolumeChainFromRecovery(); } } else { chainFromStorage = getVolumeChain(); } if (chainFromStorage == null) { setCommandStatus(CommandStatus.FAILED); return; } Collection<Guid> imagesToRemove = CollectionUtils.subtract(getImageChainFromDb(), chainFromStorage); if (imagesToRemove.size() != 1) { log.error("Failed to live merge, still in volume chain: {}", imagesToRemove); setCommandStatus(CommandStatus.FAILED); return; } log.info("Successfully removed volume(s): {}", imagesToRemove); VmBlockJobType jobType = chainFromStorage.contains(getParameters().getBaseImage().getImageId()) ? VmBlockJobType.COMMIT : VmBlockJobType.PULL; log.info("Volume merge type '{}'", jobType.name()); MergeStatusReturnValue returnValue = new MergeStatusReturnValue(jobType, Collections.singleton(imagesToRemove.stream().findFirst().get())); getReturnValue().setActionReturnValue(returnValue); setSucceeded(true); persistCommand(getParameters().getParentCommand(), true); setCommandStatus(CommandStatus.SUCCEEDED); }