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);
}
}
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);
}
}
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);
}
}
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);
}
}
}
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);
}
}
Aggregations