use of com.spotify.docker.client.messages.ContainerInfo 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 com.spotify.docker.client.messages.ContainerInfo in project opennms by OpenNMS.
the class SyslogKafkaElasticsearch5OutageIT method getEs5Address.
protected InetSocketAddress getEs5Address() {
try {
// Fetch an up-to-date ContainerInfo for the ELASTICSEARCH_5 container
final DockerClient docker = ((AbstractTestEnvironment) testEnvironment).getDockerClient();
final String id = testEnvironment.getContainerInfo(ContainerAlias.ELASTICSEARCH_5).id();
ContainerInfo info = docker.inspectContainer(id);
return testEnvironment.getServiceAddress(info, 9200, "tcp");
} catch (DockerException | InterruptedException e) {
LOG.error("Unexpected exception trying to fetch Elassticsearch port", e);
return null;
}
}
use of com.spotify.docker.client.messages.ContainerInfo in project opennms by OpenNMS.
the class SyslogKafkaElasticsearchBufferingIT method getServiceAddress.
protected static InetSocketAddress getServiceAddress(AbstractTestEnvironment env, ContainerAlias alias, int port, String protocol) {
try {
// Fetch an up-to-date ContainerInfo for the ELASTICSEARCH_5 container
final DockerClient docker = env.getDockerClient();
final String id = env.getContainerInfo(alias).id();
ContainerInfo info = docker.inspectContainer(id);
return env.getServiceAddress(info, port, protocol);
} catch (DockerException | InterruptedException e) {
LOG.error("Unexpected exception trying to fetch Elassticsearch port", e);
return null;
}
}
use of com.spotify.docker.client.messages.ContainerInfo in project opennms by OpenNMS.
the class RequisitionBuilder method withContainer.
public RequisitionBuilder withContainer(final ContainerAlias alias, final String... services) {
// We're assuming that the Minion container is on the same
// host as the service containers
final ContainerInfo containerInfo = minionSystem.getContainerInfo(alias);
final String containerIpAddr = containerInfo.networkSettings().ipAddress();
RequisitionNode node = new RequisitionNode();
node.setNodeLabel(alias.toString());
node.setForeignId(alias.toString());
RequisitionInterface iface = new RequisitionInterface();
iface.setSnmpPrimary(PrimaryType.PRIMARY);
iface.setIpAddr(containerIpAddr);
for (String svcName : services) {
RequisitionMonitoredService svc = new RequisitionMonitoredService();
svc.setServiceName(svcName);
iface.putMonitoredService(svc);
}
node.putInterface(iface);
requisition.putNode(node);
return this;
}
use of com.spotify.docker.client.messages.ContainerInfo in project linuxtools by eclipse.
the class DockerConnection method commitContainer.
@Override
public void commitContainer(final String id, final String repo, final String tag, final String comment, final String author) throws DockerException {
ContainerInfo info;
try {
info = client.inspectContainer(id);
client.commitContainer(id, repo, tag, info.config(), comment, author);
// update images list
// FIXME: are we refreshing the list of images twice ?
listImages();
getImages(true);
} catch (com.spotify.docker.client.exceptions.DockerRequestException e) {
throw new DockerException(e.message());
} catch (com.spotify.docker.client.exceptions.DockerException | InterruptedException e) {
throw new DockerException(e.getMessage(), e.getCause());
}
}
Aggregations