本文整理汇总了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());
}
示例2: createService
import com.spotify.docker.client.messages.ServiceCreateResponse; //导入依赖的package包/类
@Override
public ServiceCreateResponse createService(ServiceSpec ss, RegistryAuth ra) {
throw new IllegalStateException(DISCONNECTED);
}