本文整理汇总了Java中com.github.dockerjava.api.model.Container.getId方法的典型用法代码示例。如果您正苦于以下问题:Java Container.getId方法的具体用法?Java Container.getId怎么用?Java Container.getId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.github.dockerjava.api.model.Container
的用法示例。
在下文中一共展示了Container.getId方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: DockerService
import com.github.dockerjava.api.model.Container; //导入方法依赖的package包/类
public DockerService(Container container, String host) {
this.host = host;
containerId = container.getId();
containerNames = Arrays.stream(container.getNames()).collect(Collectors.toList());
if (!containerNames.isEmpty()) {
name = containerNames.get(0);
} else {
name = containerId;
}
for (ContainerPort port : container.getPorts()) {
Record record = createRecord(container, port);
if (record != null) {
records.add(record);
}
}
}
示例2: LogstashExecutorContainer
import com.github.dockerjava.api.model.Container; //导入方法依赖的package包/类
public LogstashExecutorContainer(DockerClient dockerClient) {
this.dockerClient = dockerClient;
await().atMost(60, TimeUnit.SECONDS).until(
() -> dockerClient.listContainersCmd().exec().size() > 0);
List<Container> containers = dockerClient.listContainersCmd().exec();
String id = null;
// Find a single executor container
for (Container container : containers) {
if (container.getImage().contains("executor")) {
id = container.getId();
break;
}
}
executorId = id;
}
示例3: build
import com.github.dockerjava.api.model.Container; //导入方法依赖的package包/类
public static KieContainer build(Container container) {
if (container == null || container.getId() == null ||
container.getNames() == null || container.getNames().length == 0) {
// If container is being started just when querying it, or not id or name assigned, do not build the instance.
return null;
}
KieContainer kieContainer = new KieContainer();
kieContainer.setId(container.getId());
kieContainer.setTruncId(container.getId().substring(0, 12));
kieContainer.setImage(container.getImage());
if (container.getNames() != null) {
}
final String cName = container.getNames()[0];
kieContainer.setName(cName.substring(1, cName.length()));
kieContainer.setCommand(container.getCommand());
final long cDateTime = container.getCreated();
final Date cDate = new Date(cDateTime * 1000);
kieContainer.setCreated(cDate);
kieContainer.setStatus(container.getStatus());
final String[] _n = parseImageName(container.getImage(), null);
kieContainer.setRegistry(_n[0]);
kieContainer.setRepository(_n[1]);
kieContainer.setTag(_n[2]);
// Ports.
final ContainerPort[] ports = container.getPorts();
if (ports != null) {
final List<KieContainerPort> kiePorts = new LinkedList<KieContainerPort>();
for (final ContainerPort port : ports) {
final KieContainerPort kiePort = new KieContainerPort();
kiePort.setIp(port.getIp());
kiePort.setPrivatePort(port.getPrivatePort());
if (port.getPublicPort() != null) kiePort.setPublicPort(port.getPublicPort());
kiePort.setType(port.getType());
kiePorts.add(kiePort);
}
kieContainer.setPorts(kiePorts);
}
// Container types.
final KieImageType kieAppType = KieImageTypeManager.getKIEAppType(kieContainer.getRepository());
final KieImageType appServerType = KieImageTypeManager.getAppServerType(kieContainer.getRepository());
KieImageType dbmsType = null;
if (SharedUtils.supportsDatabase(kieAppType)) {
// Try to obtain the DBMS used in this container by its name, to avoid inspecting the container and firing new request.
dbmsType = parseDbmsType(kieContainer.getName());
if (dbmsType == null) {
// Container name does not provide the DBMS type used, try to find out it by inspecting the container.
dbmsType = KieImageTypeManager.getDBMSType(kieContainer.getRepository(), dockerService.inspect(container.getId()));
}
}
KieImageType type = null;
final List<KieImageType> types = new LinkedList<KieImageType>();
if (kieAppType != null) type = kieAppType;
if (appServerType != null && type != null) types.add(appServerType);
else type = appServerType;
if (dbmsType != null && type != null) types.add(dbmsType);
if (type == null) type = OthersType.INSTANCE;
kieContainer.setType(type);
if (!types.isEmpty()) kieContainer.setSubTypes(types);
// Application status.
if (SharedUtils.isKieApp(kieContainer)) {
KieAppStatus status = statusManager.getStatus(kieContainer.getImage());
if (status == null) {
status = statusManager.getStatus(kieContainer);
statusManager.addStatus(kieContainer.getImage(), status);
}
kieContainer.setAppStatus(status != null ? status : KieAppStatus.NOT_EVALUATED);
}
return kieContainer;
}
示例4: loadRunningCluster
import com.github.dockerjava.api.model.Container; //导入方法依赖的package包/类
@Override
public void loadRunningCluster(MesosCluster cluster) {
String clusterId = cluster.getClusterId();
List<ClusterProcess> containers = cluster.getMemberProcesses();
List<Container> dockerContainers = DockerContainersUtil.getContainers(false).getContainers();
dockerContainers.sort(Comparator.comparingLong(Container::getCreated));
for (Container container : dockerContainers) {
String name = ContainerName.getFromDockerNames(container.getNames());
if (ContainerName.belongsToCluster(name, clusterId)) {
String containerId = container.getId();
String[] parts = name.split("-");
if (parts.length > 3) {
String role = parts[1];
String uuid = parts[3];
switch (role) {
case "zookeeper":
containers.add(createZooKeeper(cluster, uuid, containerId));
break;
case "agent":
containers.add(createMesosAgent(cluster, uuid, containerId));
break;
case "master":
MesosMaster master = createMesosMaster(cluster, uuid, containerId);
containers.add(master);
restoreMapToPorts(cluster, container);
break;
case "marathon":
containers.add(createMarathon(cluster, uuid, containerId));
break;
case "consul":
containers.add(createConsul(cluster, uuid, containerId));
break;
case "registrator":
containers.add(createRegistrator(cluster, uuid, containerId));
break;
case "mesosdns":
containers.add(createMesosDns(cluster, uuid, containerId));
}
}
}
}
}