use of de.cinovo.cloudconductor.api.lib.exceptions.CloudConductorException in project cloudconductor-agent-redhat by cinovo.
the class ServiceHandler method collectRunningServices.
private List<String> collectRunningServices() throws ExecutionError {
Set<Service> services = null;
try {
services = ServerCom.getServices();
} catch (CloudConductorException e) {
throw new ExecutionError("Error getting services from server: ", e);
}
List<String> runningServices = new ArrayList<String>();
ScriptExecutor serviceStateHandler = ScriptExecutor.generateCheckServiceState(services);
serviceStateHandler.execute();
try (Scanner s = new Scanner(serviceStateHandler.getResult())) {
while (s.hasNextLine()) {
String scriptName = s.next().trim();
for (Service service : services) {
if (service.getInitScript().equalsIgnoreCase(scriptName) && !runningServices.contains(service.getName())) {
runningServices.add(service.getName());
}
}
}
}
ServiceHandler.LOGGER.debug(services.size() + " services registered, " + runningServices.size() + " running.");
return runningServices;
}
Aggregations