Search in sources :

Example 1 with RuntimeOperationException

use of org.guvnor.ala.exceptions.RuntimeOperationException in project kie-wb-common by kiegroup.

the class DockerRuntimeManager method stop.

@Override
public void stop(RuntimeId runtimeId) throws RuntimeOperationException {
    DockerRuntime runtime = (DockerRuntime) runtimeRegistry.getRuntimeById(runtimeId.getId());
    try {
        LOG.info("Stopping container: " + runtimeId.getId());
        docker.getDockerClient(runtime.getProviderId()).stopContainer(runtime.getId(), 1);
        refresh(runtimeId);
    } catch (DockerException | InterruptedException ex) {
        LOG.error("Error Stopping container: " + runtimeId.getId(), ex);
        throw new RuntimeOperationException("Error Stopping container: " + runtimeId.getId(), ex);
    }
}
Also used : DockerRuntime(org.guvnor.ala.docker.model.DockerRuntime) DockerException(com.spotify.docker.client.DockerException) RuntimeOperationException(org.guvnor.ala.exceptions.RuntimeOperationException)

Example 2 with RuntimeOperationException

use of org.guvnor.ala.exceptions.RuntimeOperationException in project kie-wb-common by kiegroup.

the class DockerRuntimeManager method refresh.

@Override
public void refresh(RuntimeId runtimeId) throws RuntimeOperationException {
    DockerRuntime runtime = (DockerRuntime) runtimeRegistry.getRuntimeById(runtimeId.getId());
    try {
        ContainerInfo containerInfo = docker.getDockerClient(runtime.getProviderId()).inspectContainer(runtime.getId());
        ContainerState state = containerInfo.state();
        String stateString = STOPPED;
        if (state.running() && !state.paused()) {
            stateString = RUNNING;
        } else if (state.paused()) {
            stateString = "Paused";
        } else if (state.restarting()) {
            stateString = "Restarting";
        } else if (state.oomKilled()) {
            stateString = "Killed";
        }
        DockerRuntime newRuntime = new DockerRuntime(runtime.getId(), runtime.getName(), runtime.getConfig(), runtime.getProviderId(), runtime.getEndpoint(), runtime.getInfo(), new DockerRuntimeState(stateString, state.startedAt().toString()));
        runtimeRegistry.registerRuntime(newRuntime);
    } catch (DockerException | InterruptedException ex) {
        LOG.error("Error Refreshing container: " + runtimeId.getId(), ex);
        throw new RuntimeOperationException("Error Refreshing container: " + runtimeId.getId(), ex);
    }
}
Also used : DockerRuntime(org.guvnor.ala.docker.model.DockerRuntime) DockerException(com.spotify.docker.client.DockerException) ContainerInfo(com.spotify.docker.client.messages.ContainerInfo) DockerRuntimeState(org.guvnor.ala.docker.model.DockerRuntimeState) RuntimeOperationException(org.guvnor.ala.exceptions.RuntimeOperationException) ContainerState(com.spotify.docker.client.messages.ContainerState)

Example 3 with RuntimeOperationException

use of org.guvnor.ala.exceptions.RuntimeOperationException in project kie-wb-common by kiegroup.

the class DockerRuntimeManager method pause.

@Override
public void pause(RuntimeId runtimeId) throws RuntimeOperationException {
    DockerRuntime runtime = (DockerRuntime) runtimeRegistry.getRuntimeById(runtimeId.getId());
    try {
        docker.getDockerClient(runtime.getProviderId()).pauseContainer(runtime.getId());
        refresh(runtimeId);
    } catch (DockerException | InterruptedException ex) {
        LOG.error("Error Pausing container: " + runtimeId.getId(), ex);
        throw new RuntimeOperationException("Error Pausing container: " + runtimeId.getId(), ex);
    }
}
Also used : DockerRuntime(org.guvnor.ala.docker.model.DockerRuntime) DockerException(com.spotify.docker.client.DockerException) RuntimeOperationException(org.guvnor.ala.exceptions.RuntimeOperationException)

Example 4 with RuntimeOperationException

use of org.guvnor.ala.exceptions.RuntimeOperationException in project kie-wb-common by kiegroup.

the class OpenShiftRuntimeManager method refresh.

@Override
public void refresh(RuntimeId runtimeId) throws RuntimeOperationException {
    OpenShiftRuntime runtime = (OpenShiftRuntime) runtimeRegistry.getRuntimeById(runtimeId.getId());
    if (runtime != null) {
        try {
            // LOG.info( "Refreshing runtime: " + runtimeId.getId() );
            OpenShiftRuntimeState runtimeState = openshift.getOpenShiftClient(runtime.getProviderId()).getRuntimeState(runtime.getId());
            OpenShiftRuntime newRuntime = new OpenShiftRuntime(runtime.getId(), runtime.getName(), runtime.getConfig(), runtime.getProviderId(), runtime.getEndpoint(), runtime.getInfo(), runtimeState);
            runtimeRegistry.registerRuntime(newRuntime);
        } catch (OpenShiftClientException ex) {
            LOG.error("Error Refreshing runtime: " + runtimeId.getId(), ex);
            throw new RuntimeOperationException("Error Refreshing runtime: " + runtimeId.getId(), ex);
        }
    }
}
Also used : OpenShiftRuntime(org.guvnor.ala.openshift.model.OpenShiftRuntime) OpenShiftRuntimeState(org.guvnor.ala.openshift.model.OpenShiftRuntimeState) OpenShiftClientException(org.guvnor.ala.openshift.access.exceptions.OpenShiftClientException) RuntimeOperationException(org.guvnor.ala.exceptions.RuntimeOperationException)

Example 5 with RuntimeOperationException

use of org.guvnor.ala.exceptions.RuntimeOperationException in project kie-wb-common by kiegroup.

the class OpenShiftRuntimeManager method stop.

@Override
public void stop(RuntimeId runtimeId) throws RuntimeOperationException {
    OpenShiftRuntime runtime = (OpenShiftRuntime) runtimeRegistry.getRuntimeById(runtimeId.getId());
    try {
        LOG.info("Stopping runtime: " + runtimeId.getId());
        openshift.getOpenShiftClient(runtime.getProviderId()).stop(runtime.getId());
        refresh(runtimeId);
        LOG.info("Stopped runtime: " + runtimeId.getId());
    } catch (OpenShiftClientException ex) {
        LOG.error("Error Stopping runtime: " + runtimeId.getId(), ex);
        throw new RuntimeOperationException("Error Stopping runtime: " + runtimeId.getId(), ex);
    }
}
Also used : OpenShiftRuntime(org.guvnor.ala.openshift.model.OpenShiftRuntime) OpenShiftClientException(org.guvnor.ala.openshift.access.exceptions.OpenShiftClientException) RuntimeOperationException(org.guvnor.ala.exceptions.RuntimeOperationException)

Aggregations

RuntimeOperationException (org.guvnor.ala.exceptions.RuntimeOperationException)16 OpenShiftClientException (org.guvnor.ala.openshift.access.exceptions.OpenShiftClientException)6 DockerException (com.spotify.docker.client.DockerException)5 DockerRuntime (org.guvnor.ala.docker.model.DockerRuntime)5 OpenShiftRuntime (org.guvnor.ala.openshift.model.OpenShiftRuntime)5 WildflyRuntime (org.guvnor.ala.wildfly.model.WildflyRuntime)5 WildflyClientException (org.guvnor.ala.wildfly.access.exceptions.WildflyClientException)4 ContainerInfo (com.spotify.docker.client.messages.ContainerInfo)1 ContainerState (com.spotify.docker.client.messages.ContainerState)1 DockerRuntimeState (org.guvnor.ala.docker.model.DockerRuntimeState)1 OpenShiftProvider (org.guvnor.ala.openshift.model.OpenShiftProvider)1 OpenShiftRuntimeState (org.guvnor.ala.openshift.model.OpenShiftRuntimeState)1 WildflyAppState (org.guvnor.ala.wildfly.access.WildflyAppState)1 WildflyRuntimeState (org.guvnor.ala.wildfly.model.WildflyRuntimeState)1