当前位置: 首页>>代码示例>>Java>>正文


Java ServiceCreateResponse类代码示例

本文整理汇总了Java中com.spotify.docker.client.messages.ServiceCreateResponse的典型用法代码示例。如果您正苦于以下问题:Java ServiceCreateResponse类的具体用法?Java ServiceCreateResponse怎么用?Java ServiceCreateResponse使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ServiceCreateResponse类属于com.spotify.docker.client.messages包,在下文中一共展示了ServiceCreateResponse类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: create

import com.spotify.docker.client.messages.ServiceCreateResponse; //导入依赖的package包/类
public static DockerService create(CreateAgentRequest request, PluginSettings settings, DockerClient docker) throws InterruptedException, DockerException {
    String serviceName = UUID.randomUUID().toString();

    HashMap<String, String> labels = labelsFrom(request);
    String imageName = image(request.properties());
    String[] env = environmentFrom(request, settings, serviceName);

    final ContainerSpec.Builder containerSpecBuilder = ContainerSpec.builder()
            .image(imageName)
            .env(env);

    if (StringUtils.isNotBlank(request.properties().get("Command"))) {
        containerSpecBuilder.command(splitIntoLinesAndTrimSpaces(request.properties().get("Command")).toArray(new String[]{}));
    }

    if (dockerApiVersionAtLeast(docker, "1.26")) {
        containerSpecBuilder.hosts(new Hosts().hosts(request.properties().get("Hosts")));
        final DockerMounts dockerMounts = DockerMounts.fromString(request.properties().get("Mounts"));
        containerSpecBuilder.mounts(dockerMounts.toMount(docker.listVolumes().volumes()));
        final DockerSecrets dockerSecrets = DockerSecrets.fromString(request.properties().get("Secrets"));
        containerSpecBuilder.secrets(dockerSecrets.toSecretBind(docker.listSecrets()));
    } else {
        LOG.warn(format("Detected docker version and api version is {0} and {1} respectively. Docker with api version 1.26 or above is required to use volume mounts, secrets and host file entries. Please refer https://docs.docker.com/engine/api/v1.32/#section/Versioning for more information about docker release.", docker.version().version(), docker.version().apiVersion()));
    }

    TaskSpec taskSpec = TaskSpec.builder()
            .containerSpec(containerSpecBuilder.build())
            .resources(requirements(request))
            .placement(Placement.create(Util.linesToList(request.properties().get("Constraints"))))
            .build();

    ServiceSpec serviceSpec = ServiceSpec.builder()
            .name(serviceName)
            .labels(labels)
            .taskTemplate(taskSpec)
            .networks(Networks.fromString(request.properties().get("Networks"), docker.listNetworks()))
            .build();

    ServiceCreateResponse service = docker.createService(serviceSpec);

    String id = service.id();

    Service serviceInfo = docker.inspectService(id);

    LOG.debug("Created service " + serviceInfo.spec().name());
    return new DockerService(serviceName,
            serviceInfo.createdAt(),
            request.properties(),
            request.environment(),
            request.jobIdentifier().getJobId());
}
 
开发者ID:gocd-contrib,项目名称:docker-swarm-elastic-agents,代码行数:52,代码来源:DockerService.java

示例2: createService

import com.spotify.docker.client.messages.ServiceCreateResponse; //导入依赖的package包/类
@Override
public ServiceCreateResponse createService(ServiceSpec ss, RegistryAuth ra) {
    throw new IllegalStateException(DISCONNECTED); 
}
 
开发者ID:amihaiemil,项目名称:comdor,代码行数:5,代码来源:Disconnected.java


注:本文中的com.spotify.docker.client.messages.ServiceCreateResponse类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。