Search in sources :

Example 16 with CloudConductorException

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;
}
Also used : CloudConductorException(de.cinovo.cloudconductor.api.lib.exceptions.CloudConductorException) Scanner(java.util.Scanner) ExecutionError(de.cinovo.cloudconductor.agent.exceptions.ExecutionError) ArrayList(java.util.ArrayList) Service(de.cinovo.cloudconductor.api.model.Service) ScriptExecutor(de.cinovo.cloudconductor.agent.executors.ScriptExecutor)

Aggregations

CloudConductorException (de.cinovo.cloudconductor.api.lib.exceptions.CloudConductorException)16 ExecutionError (de.cinovo.cloudconductor.agent.exceptions.ExecutionError)9 ScriptExecutor (de.cinovo.cloudconductor.agent.executors.ScriptExecutor)3 IOException (java.io.IOException)3 TransformationErrorException (de.cinovo.cloudconductor.agent.exceptions.TransformationErrorException)2 ConfigFile (de.cinovo.cloudconductor.api.model.ConfigFile)2 HashCode (com.google.common.hash.HashCode)1 JWTClaimsSet (com.nimbusds.jwt.JWTClaimsSet)1 ServerConnectionException (de.cinovo.cloudconductor.agent.exceptions.ServerConnectionException)1 FileExecutor (de.cinovo.cloudconductor.agent.executors.FileExecutor)1 InstalledPackages (de.cinovo.cloudconductor.agent.executors.InstalledPackages)1 RefreshJWTJob (de.cinovo.cloudconductor.agent.jobs.RefreshJWTJob)1 ConfigFileHandler (de.cinovo.cloudconductor.agent.jobs.handler.ConfigFileHandler)1 OptionHandler (de.cinovo.cloudconductor.agent.jobs.handler.OptionHandler)1 PackageHandler (de.cinovo.cloudconductor.agent.jobs.handler.PackageHandler)1 RepoHandler (de.cinovo.cloudconductor.agent.jobs.handler.RepoHandler)1 AgentOption (de.cinovo.cloudconductor.api.model.AgentOption)1 ConfigValue (de.cinovo.cloudconductor.api.model.ConfigValue)1 PackageState (de.cinovo.cloudconductor.api.model.PackageState)1 Repo (de.cinovo.cloudconductor.api.model.Repo)1