本文整理汇总了Java中com.github.dockerjava.api.model.ContainerPort.getPublicPort方法的典型用法代码示例。如果您正苦于以下问题:Java ContainerPort.getPublicPort方法的具体用法?Java ContainerPort.getPublicPort怎么用?Java ContainerPort.getPublicPort使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.github.dockerjava.api.model.ContainerPort
的用法示例。
在下文中一共展示了ContainerPort.getPublicPort方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: manageUnknownService
import com.github.dockerjava.api.model.ContainerPort; //导入方法依赖的package包/类
private Record manageUnknownService(Record record, ContainerPort port) {
if (port.getPublicPort() == null || port.getPublicPort() == 0) {
return null;
}
JsonObject location = new JsonObject();
location.put("port", port.getPublicPort());
location.put("internal-port", port.getPrivatePort());
location.put("type", port.getType());
location.put("ip", host);
return record.setLocation(location).setType(ServiceType.UNKNOWN);
}
示例2: manageHttpService
import com.github.dockerjava.api.model.ContainerPort; //导入方法依赖的package包/类
private static Record manageHttpService(Record record, ContainerPort port, Map<String, String> labels) {
if (port.getPublicPort() == null || port.getPublicPort() == 0) {
return null;
}
record.setType(HttpEndpoint.TYPE);
HttpLocation location = new HttpLocation()
.setHost(port.getIp())
.setPort(port.getPublicPort());
if (isTrue(labels, "ssl") || port.getPrivatePort() == 443) {
location.setSsl(true);
}
return record.setLocation(location.toJson());
}
示例3: build
import com.github.dockerjava.api.model.ContainerPort; //导入方法依赖的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;
}