Source:
<code>protected void executeCommand() { entity = getGlusterHook(); addCustomValue(GlusterConstants.HOOK_NAME, entity.getName()); List<GlusterServerHook> serverHooks = entity.getServerHooks(); if (getAllUpServers().size() < getClusterUtils().getServerCount(getGlusterHook().getClusterId())) { errors.add(VdcBllMessages.CLUSTER_ALL_SERVERS_NOT_UP.toString()); } List<Callable<Pair<VDS, VDSReturnValue>>> taskList = new ArrayList<Callable<Pair<VDS, VDSReturnValue>>>(); for (final VDS upServer : getAllUpServers()) { taskList.add(new Callable<Pair<VDS, VDSReturnValue>>() { @Override public Pair<VDS, VDSReturnValue> call() throws Exception { VDSReturnValue returnValue = runVdsCommand( getStatusChangeVDSCommand(), new GlusterHookVDSParameters(upServer.getId(), entity.getGlusterCommand(), entity.getStage(), entity.getName())); return new Pair<VDS, VDSReturnValue>(upServer, returnValue); } }); } boolean atLeastOneSuccess = false; List<Pair<VDS, VDSReturnValue>> pairResults = ThreadPoolUtil.invokeAll(taskList); for (Pair<VDS, VDSReturnValue> pairResult : pairResults) { VDSReturnValue retValue = pairResult.getSecond(); if (retValue.getSucceeded() ) { atLeastOneSuccess = true; <START> addOrUpdateServerHook(serverHooks, pairResult); <END> } else { errors.add(retValue.getVdsError().getMessage()); } } setSucceeded(atLeastOneSuccess); if (errors.size() > 0) { entity.addStatusConflict(); handleVdsErrors(getAuditLogTypeValue(), errors); addCustomValue(GlusterConstants.FAILURE_MESSAGE , StringUtils.join(errors, SystemUtils.LINE_SEPARATOR)); } if (getSucceeded()) { entity.setStatus(getNewStatus()); entity.removeStatusConflict(); updateHookInDb(entity); if (entity.getConflictStatus() == 0) { getGlusterHooksDao().removeGlusterServerHooks(entity.getId()); } } }</code><technical_language>call updateServerHookStatusInDb() here. remove unused serverHooks</technical_language>

Target:
protected void executeCommand() { entity = getGlusterHook(); addCustomValue(GlusterConstants.HOOK_NAME, entity.getName()); if (getAllUpServers().size() < getClusterUtils().getServerCount(getGlusterHook().getClusterId())) { errors.add(VdcBllMessages.CLUSTER_ALL_SERVERS_NOT_UP.toString()); } List<Callable<Pair<VDS, VDSReturnValue>>> taskList = new ArrayList<Callable<Pair<VDS, VDSReturnValue>>>(); for (final VDS upServer : getAllUpServers()) { taskList.add(new Callable<Pair<VDS, VDSReturnValue>>() { @Override public Pair<VDS, VDSReturnValue> call() throws Exception { VDSReturnValue returnValue = runVdsCommand( getStatusChangeVDSCommand(), new GlusterHookVDSParameters(upServer.getId(), entity.getGlusterCommand(), entity.getStage(), entity.getName())); return new Pair<VDS, VDSReturnValue>(upServer, returnValue); } }); } boolean atLeastOneSuccess = false; List<Pair<VDS, VDSReturnValue>> pairResults = ThreadPoolUtil.invokeAll(taskList); for (Pair<VDS, VDSReturnValue> pairResult : pairResults) { VDSReturnValue retValue = pairResult.getSecond(); if (retValue.getSucceeded() ) { atLeastOneSuccess = true; updateServerHookStatusInDb(getGlusterHook().getId(), pairResult.getFirst().getId(), getNewStatus()); } else { errors.add(retValue.getVdsError().getMessage()); } } setSucceeded(atLeastOneSuccess); if (errors.size() > 0) { entity.addStatusConflict(); handleVdsErrors(getAuditLogTypeValue(), errors); addCustomValue(GlusterConstants.FAILURE_MESSAGE , StringUtils.join(errors, SystemUtils.LINE_SEPARATOR)); } if (getSucceeded()) { entity.setStatus(getNewStatus()); entity.removeStatusConflict(); updateHookInDb(entity); if (entity.getConflictStatus() == 0) { getGlusterHooksDao().removeGlusterServerHooks(entity.getId()); } } }