Source:
<code>private void performActionForServicesOfCluster() { List<VDS> servers = getClusterUtils().getAllUpServers(clusterId); List<GlusterServerService> serviceList = null; List<Callable<Pair<VDS, VDSReturnValue>>> taskList = new ArrayList<Callable<Pair<VDS, VDSReturnValue>>>(); for (final VDS upServer : servers) { <START> serviceList = getGlusterServerServiceDao().getByServerId(upServer.getId()); <END> final List<String> serviceListStr = new ArrayList<String>(); for (GlusterServerService srvc : serviceList) { serviceListStr.add(srvc.getServiceName()); } taskList.add(new Callable<Pair<VDS, VDSReturnValue>>() { @Override public Pair<VDS, VDSReturnValue> call() throws Exception { VDSReturnValue returnValue = runVdsCommand( manageActionDetailsMap.get(getParameters().getActionType()).getVdsCmdType(), new GlusterServiceVDSParameters(upServer.getId(), serviceListStr, actionType)); 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; updateService(serviceList, pairResult); } else { errors.add(retValue.getVdsError().getMessage()); } } setSucceeded(atLeastOneSuccess); if (errors.size() > 0) { handleVdsErrors(getAuditLogTypeValue(), errors); addCustomValue(GlusterConstants.FAILURE_MESSAGE, StringUtils.join(errors, SystemUtils.LINE_SEPARATOR)); } else { setSucceeded(true); } }</code><technical_language>I serviceList server, gluster_services table based service type. design is generic services for a server, do want start/stop of services. serviceList building moved of this method for cluster/server - GlusterServiceDao</technical_language>

Target:
private void performActionForServicesOfCluster() { List<VDS> servers = getClusterUtils().getAllUpServers(clusterId); final List<GlusterService> serviceList = getServiceList(); List<Callable<Pair<VDS, VDSReturnValue>>> taskList = new ArrayList<Callable<Pair<VDS, VDSReturnValue>>>(); for (final VDS upServer : servers) { final List<String> serviceListStr = new ArrayList<String>(); for (GlusterService srvc : serviceList) { serviceListStr.add(srvc.getServiceName()); } taskList.add(new Callable<Pair<VDS, VDSReturnValue>>() { @Override public Pair<VDS, VDSReturnValue> call() throws Exception { VDSReturnValue returnValue; returnValue = runVdsCommand( VDSCommandType.ManageGlusterService, new GlusterServiceVDSParameters(upServer.getId(), serviceListStr, actionType)); Pair<VDS, VDSReturnValue> pairRetVal = new Pair<VDS, VDSReturnValue>(upServer, returnValue); if (returnValue.getSucceeded()) updateService(upServer.getId(), serviceList, pairRetVal); return pairRetVal; } }); } setSucceeded(true); if (!taskList.isEmpty()) { List<Pair<VDS, VDSReturnValue>> pairResults = ThreadPoolUtil.invokeAll(taskList); for (Pair<VDS, VDSReturnValue> pairResult : pairResults) { VDSReturnValue retValue = pairResult.getSecond(); if (!retValue.getSucceeded()) { errors.add(retValue.getVdsError().getMessage()); } } } else { setSucceeded(false); } if (errors.size() > 0) { setSucceeded(false); handleVdsErrors(getAuditLogTypeValue(), errors); addCustomValue(GlusterConstants.FAILURE_MESSAGE, StringUtils.join(errors, SystemUtils.LINE_SEPARATOR)); } else { setSucceeded(true); } }