Source:
protected void executeCommand() { entity = getGlusterHook(); addCustomValue(GlusterConstants.HOOK_NAME, entity.getName()); final boolean hookEnabled = entity.getStatus() == GlusterHookStatus.ENABLED ? true : false; List<Callable<Pair<GlusterServerHook, VDSReturnValue>>> taskList = new ArrayList<Callable<Pair<GlusterServerHook, VDSReturnValue>>>(); for (final GlusterServerHook serverHook : getMissingServerHooks()) { taskList.add(new Callable<Pair<GlusterServerHook, VDSReturnValue>>() { @Override public Pair<GlusterServerHook, VDSReturnValue> call() throws Exception { VDSReturnValue returnValue; returnValue = runVdsCommand( VDSCommandType.AddGlusterHook, new GlusterHookVDSParameters(serverHook.getServerId(), entity.getGlusterCommand(), entity.getStage(), entity.getName(), entity.getContent(), entity.getChecksum(), hookEnabled)); return new Pair<GlusterServerHook, VDSReturnValue>(serverHook, returnValue); } }); } setSucceeded(true); if (!taskList.isEmpty()) { List<Pair<GlusterServerHook, VDSReturnValue>> pairResults = ThreadPoolUtil.invokeAll(taskList); for (Pair<GlusterServerHook, VDSReturnValue> pairResult : pairResults) { VDSReturnValue retValue = pairResult.getSecond(); if (!retValue.getSucceeded() ) { errors.add(retValue.getVdsError().getMessage()); } else { getGlusterHooksDao().removeGlusterServerHook(pairResult.getFirst().getHookId(), pairResult.getFirst().getServerId()); } } } else { setSucceeded(false); } if (errors.size() > 0) { setSucceeded(false); errorType = AuditLogType.GLUSTER_HOOK_ADD_FAILED; handleVdsErrors(getAuditLogTypeValue(), errors); addCustomValue(GlusterConstants.FAILURE_MESSAGE , StringUtils.join(errors, SystemUtils.LINE_SEPARATOR)); } if (getSucceeded()) { entity.removeMissingConflict(); getGlusterHooksDao().updateGlusterHook(entity); } }

Target:
protected void executeCommand() { entity = getGlusterHook(); addCustomValue(GlusterConstants.HOOK_NAME, entity.getName()); final boolean hookEnabled = entity.getStatus() == GlusterHookStatus.ENABLED; List<Callable<Pair<GlusterServerHook, VDSReturnValue>>> taskList = new ArrayList<Callable<Pair<GlusterServerHook, VDSReturnValue>>>(); for (final GlusterServerHook serverHook : getMissingServerHooks()) { taskList.add(new Callable<Pair<GlusterServerHook, VDSReturnValue>>() { @Override public Pair<GlusterServerHook, VDSReturnValue> call() throws Exception { VDSReturnValue returnValue; returnValue = runVdsCommand( VDSCommandType.AddGlusterHook, new GlusterHookVDSParameters(serverHook.getServerId(), entity.getGlusterCommand(), entity.getStage(), entity.getName(), entity.getContent(), entity.getChecksum(), hookEnabled)); return new Pair<GlusterServerHook, VDSReturnValue>(serverHook, returnValue); } }); } if (!taskList.isEmpty()) { List<Pair<GlusterServerHook, VDSReturnValue>> pairResults = ThreadPoolUtil.invokeAll(taskList); for (Pair<GlusterServerHook, VDSReturnValue> pairResult : pairResults) { VDSReturnValue retValue = pairResult.getSecond(); if (!retValue.getSucceeded() ) { errors.add(retValue.getVdsError().getMessage()); } else { getGlusterHooksDao().removeGlusterServerHook(pairResult.getFirst().getHookId(), pairResult.getFirst().getServerId()); } } } if (errors.size() > 0) { setSucceeded(false); errorType = AuditLogType.GLUSTER_HOOK_ADD_FAILED; handleVdsErrors(getAuditLogTypeValue(), errors); addCustomValue(GlusterConstants.FAILURE_MESSAGE , StringUtils.join(errors, SystemUtils.LINE_SEPARATOR)); } else { setSucceeded(true); } if (getSucceeded()) { entity.removeMissingConflict(); getGlusterHooksDao().updateGlusterHook(entity); } }