當前位置: 首頁>>代碼示例>>Java>>正文


Java ContainerPort類代碼示例

本文整理匯總了Java中com.github.dockerjava.api.model.ContainerPort的典型用法代碼示例。如果您正苦於以下問題:Java ContainerPort類的具體用法?Java ContainerPort怎麽用?Java ContainerPort使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


ContainerPort類屬於com.github.dockerjava.api.model包,在下文中一共展示了ContainerPort類的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: DockerService

import com.github.dockerjava.api.model.ContainerPort; //導入依賴的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);
    }
  }

}
 
開發者ID:vert-x3,項目名稱:vertx-service-discovery,代碼行數:19,代碼來源:DockerService.java

示例2: createRecord

import com.github.dockerjava.api.model.ContainerPort; //導入依賴的package包/類
public Record createRecord(Container container, ContainerPort port) {
  Record record = new Record()
      .setName(name);

  Map<String, String> labels = container.getLabels();
  if (labels != null) {
    for (Map.Entry<String, String> entry : labels.entrySet()) {
      record.getMetadata().put(entry.getKey(), entry.getValue());
    }
  }

  JsonArray names = new JsonArray();
  containerNames.forEach(names::add);
  record.getMetadata().put("docker.names", names);
  record.getMetadata().put("docker.name", name);
  record.getMetadata().put("docker.id", containerId);

  String type = labels != null ? labels.get("service.type") : ServiceType.UNKNOWN;
  if (type == null) {
    type = ServiceType.UNKNOWN;
  }

  switch (type) {
    case "http-endpoint":
      return manageHttpService(record, port, labels);
    default:
      return manageUnknownService(record, port);
  }
}
 
開發者ID:vert-x3,項目名稱:vertx-service-discovery,代碼行數:30,代碼來源:DockerService.java

示例3: 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);
}
 
開發者ID:vert-x3,項目名稱:vertx-service-discovery,代碼行數:13,代碼來源:DockerService.java

示例4: 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());
}
 
開發者ID:vert-x3,項目名稱:vertx-service-discovery,代碼行數:15,代碼來源:DockerService.java

示例5: restoreMapToPorts

import com.github.dockerjava.api.model.ContainerPort; //導入依賴的package包/類
private void restoreMapToPorts(MesosCluster cluster, Container container) {
    // Restore "map ports to host" attribute
    ContainerPort[] ports = container.getPorts();
    if (ports != null) {
        for (ContainerPort port : ports) {
            if (port.getIp() != null && port.getPrivatePort() == MesosMasterConfig.MESOS_MASTER_PORT) {
                cluster.setMapPortsToHost(true);
            }
        }
    }
}
 
開發者ID:ContainerSolutions,項目名稱:minimesos,代碼行數:12,代碼來源:MesosClusterContainersFactory.java

示例6: 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;
}
 
開發者ID:kiegroup,項目名稱:kie-docker-ci,代碼行數:78,代碼來源:KieDockerArtifactBuilder.java


注:本文中的com.github.dockerjava.api.model.ContainerPort類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。