All Downloads are FREE. Search and download functionalities are using the official Maven repository.

zed.deployer.DockerUriStatusResolver Maven / Gradle / Ivy

Go to download

A application used as an example on how to set up pushing its components to the Central Repository.

The newest version!
package zed.deployer;

import com.github.dockerjava.api.DockerClient;
import com.github.dockerjava.api.model.Container;
import zed.deployer.manager.DeployableDescriptor;

import java.util.List;
import java.util.stream.Collectors;

public class DockerUriStatusResolver implements UriStatusResolver {

    private final DockerClient docker;

    public DockerUriStatusResolver(DockerClient docker) {
        this.docker = docker;
    }

    @Override
    public boolean support(String uri) {
        return uri.contains("docker:") ||
                uri.contains(":docker");
    }

    @Override
    public boolean status(DeployableDescriptor deployableDescriptor) {
        List containers = docker.listContainersCmd().exec();
        long size = containers.parallelStream().filter(c -> c.getId().equals(deployableDescriptor.pid()) && c.getStatus().startsWith("Up ")).collect(Collectors.toList()).size();
        return size == 1;
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy