• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java Docker类的典型用法和代码示例

java 1次浏览

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

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

示例1: setDockerImage

点赞 3

import mesosphere.marathon.client.model.v2.Docker; //导入依赖的package包/类
private void setDockerImage() {
    if (config.getDocker() != null && config.getDocker().trim().length() > 0) {
        final String imageName = Util.replaceMacro(config.getDocker(), envVars);

        if (imageName == null || imageName.trim().length() == 0) {
            return;
        }

        if (getApp().getContainer() == null) {
            getApp().setContainer(new Container());
        }

        if (getApp().getContainer().getDocker() == null) {
            getApp().getContainer().setDocker(new Docker());
        }

        getApp().getContainer().setType("DOCKER");
        getApp().getContainer().getDocker().setImage(imageName);
        getApp().getContainer().getDocker().setForcePullImage(config.getDockerForcePull());
    }
}
 

开发者ID:jenkinsci,
项目名称:marathon-plugin,
代码行数:22,
代码来源:MarathonBuilderImpl.java

示例2: createContainer

点赞 3

import mesosphere.marathon.client.model.v2.Docker; //导入依赖的package包/类
private Container createContainer(AppDeploymentRequest request) {
	Container container = new Container();
	Docker docker = new Docker();
	String image = null;
	try {
		image = request.getResource().getURI().getSchemeSpecificPart();
	} catch (IOException e) {
		throw new IllegalArgumentException("Unable to get URI for " + request.getResource(), e);
	}
	logger.info("Using Docker image: " + image);
	docker.setImage(image);
	Port port = new Port(8080);
	port.setHostPort(0);
	docker.setPortMappings(Arrays.asList(port));
	docker.setNetwork("BRIDGE");
	container.setDocker(docker);
	return container;
}
 

开发者ID:spring-cloud,
项目名称:spring-cloud-deployer-mesos,
代码行数:19,
代码来源:MarathonAppDeployer.java

示例3: createZookeeperApp

点赞 3

import mesosphere.marathon.client.model.v2.Docker; //导入依赖的package包/类
private App createZookeeperApp() {
    App app = new App();
    app.setId(this.id);
    app.setCpus(cpu);
    app.setMem(mem);
    app.setInstances(instances);
    app.setContainer(new Container());
    app.getContainer().setType(CONTAINER_TYPE);
    app.getContainer().setDocker(new Docker());
    app.getContainer().getDocker().setImage(ZK_IMAGE);
    List<HealthCheck> healthCheckList = new ArrayList<>();
    final HealthCheck hc = setHealthCheck(300, "TCP", false, 60, 20, 0, ZKSERVICE_ZKPORT);
    healthCheckList.add(hc);
    app.setHealthChecks(healthCheckList);

    return app;
}
 

开发者ID:pravega,
项目名称:pravega,
代码行数:18,
代码来源:ZookeeperService.java

示例4: AppDescriptor

点赞 2

import mesosphere.marathon.client.model.v2.Docker; //导入依赖的package包/类
public AppDescriptor(App app) {
  this.id = app.getId();
  this.app = app;
  Docker docker = app.getContainer().getDocker();
  String version = parseVersion(docker.getImage());
  String channel = parseChannel(docker.getImage());
  String branch = parseBranch(docker.getImage());
  String commit = parseCommit(docker.getImage());
  this.revision = new Revision(version, channel, branch, commit);
  this.dockerImageUrl = parseImage(docker.getImage());
}
 

开发者ID:ecg-mechaniker,
项目名称:mechaniker,
代码行数:12,
代码来源:AppDescriptor.java

示例5: createPravegaControllerApp

点赞 2

import mesosphere.marathon.client.model.v2.Docker; //导入依赖的package包/类
/**
 * To configure the controller app.
 *
 * @return App instance of marathon app
 */
private App createPravegaControllerApp() {
    App app = new App();
    app.setId(this.id);
    app.setCpus(cpu);
    app.setMem(mem);
    app.setInstances(instances);
    app.setConstraints(setConstraint("hostname", "UNIQUE"));
    app.setContainer(new Container());
    app.getContainer().setType(CONTAINER_TYPE);
    app.getContainer().setDocker(new Docker());
    app.getContainer().getDocker().setImage(IMAGE_PATH + "/nautilus/pravega:" + PRAVEGA_VERSION);
    String zk = zkUri.getHost() + ":" + ZKSERVICE_ZKPORT;
    //set port
    app.setPortDefinitions(Arrays.asList(createPortDefinition(CONTROLLER_PORT), createPortDefinition(REST_PORT)));
    app.setRequirePorts(true);
    List<HealthCheck> healthCheckList = new ArrayList<HealthCheck>();
    healthCheckList.add(setHealthCheck(300, "TCP", false, 60, 20, 0, CONTROLLER_PORT));
    app.setHealthChecks(healthCheckList);
    //set env
    String controllerSystemProperties = "-Xmx512m" +
            setSystemProperty("ZK_URL", zk) +
            setSystemProperty("CONTROLLER_RPC_PUBLISHED_HOST", this.id + ".marathon.mesos") +
            setSystemProperty("CONTROLLER_RPC_PUBLISHED_PORT", String.valueOf(CONTROLLER_PORT)) +
            setSystemProperty("CONTROLLER_SERVER_PORT", String.valueOf(CONTROLLER_PORT)) +
            setSystemProperty("REST_SERVER_PORT", String.valueOf(REST_PORT)) +
            setSystemProperty("log.level", "DEBUG") +
            setSystemProperty("log.dir", "$MESOS_SANDBOX/pravegaLogs") +
            setSystemProperty("curator-default-session-timeout", String.valueOf(10 * 1000)) +
            setSystemProperty("MAX_LEASE_VALUE", String.valueOf(60 * 1000)) +
            setSystemProperty("MAX_SCALE_GRACE_PERIOD", String.valueOf(60 * 1000));
    Map<String, Object> map = new HashMap<>();
    map.put("PRAVEGA_CONTROLLER_OPTS", controllerSystemProperties);
    app.setEnv(map);
    app.setArgs(Arrays.asList("controller"));

    return app;
}
 

开发者ID:pravega,
项目名称:pravega,
代码行数:43,
代码来源:PravegaControllerService.java

示例6: createBookieApp

点赞 2

import mesosphere.marathon.client.model.v2.Docker; //导入依赖的package包/类
private App createBookieApp() {
    App app = new App();
    app.setId(this.id);
    app.setCpus(cpu);
    app.setMem(mem);
    app.setInstances(instances);
    app.setConstraints(setConstraint("hostname", "UNIQUE"));
    app.setContainer(new Container());
    app.getContainer().setType(CONTAINER_TYPE);
    app.getContainer().setDocker(new Docker());
    app.getContainer().getDocker().setImage(IMAGE_PATH + "/nautilus/bookkeeper:" + PRAVEGA_VERSION);
    Collection<Volume> volumeCollection = new ArrayList<>();
    volumeCollection.add(createVolume("/bk", "mnt", "RW"));
    //TODO: add persistent volume  (see issue https://github.com/pravega/pravega/issues/639)
    app.getContainer().setVolumes(volumeCollection);
    app.setPorts(Arrays.asList(BK_PORT));
    app.setRequirePorts(true);
    //set env
    String zk = zkUri.getHost() + ":" + ZKSERVICE_ZKPORT;
    Map<String, Object> map = new HashMap<>();
    map.put("ZK_URL", zk);
    map.put("ZK", zk);
    map.put("bookiePort", String.valueOf(BK_PORT));
    map.put("DLOG_EXTRA_OPTS", "-Xms512m");
    app.setEnv(map);
    //healthchecks
    List<HealthCheck> healthCheckList = new ArrayList<>();
    healthCheckList.add(setHealthCheck(300, "TCP", false, 60, 20, 0, BK_PORT));
    app.setHealthChecks(healthCheckList);

    return app;
}
 

开发者ID:pravega,
项目名称:pravega,
代码行数:33,
代码来源:BookkeeperService.java

示例7: generateContainer

点赞 2

import mesosphere.marathon.client.model.v2.Docker; //导入依赖的package包/类
private Container generateContainer(MesosContainer mesosContainer) {
  Container container = new Container();
  if (mesosContainer.getType() == MesosContainer.Type.DOCKER) {
    container.setType(MesosContainer.Type.DOCKER.getName());
    container.setVolumes(mesosContainer
        .getVolumes()
        .stream()
        .map(this::generateVolume)
        .collect(Collectors.toList()));
    Docker docker = new Docker();
    container.setDocker(docker);
    docker.setImage(mesosContainer.getImage());
    List<Port> ports = mesosContainer
        .getPortMappings()
        .stream()
        .map(this::generatePort)
        .collect(Collectors.toList());
    docker.setPortMappings(ports);

    docker.setForcePullImage(mesosContainer.isForcePullImage());
    docker.setPrivileged(mesosContainer.isPriviliged());

    //// HARDCODED BITS //////
    docker.setNetwork("BRIDGE");
    //////////////////////////
  } else {
    throw new DeploymentException(
        "Unknown Mesos container type: " + mesosContainer.getType().toString());
  }
  return container;
}
 

开发者ID:indigo-dc,
项目名称:orchestrator,
代码行数:32,
代码来源:MarathonServiceImpl.java

示例8: initModules

点赞 2

import mesosphere.marathon.client.model.v2.Docker; //导入依赖的package包/类
private static void initModules() {
  path(
      "/internal",
      () -> {
        get("/ping", ((request, response) -> "pong"));
      });
  get(
      "/list",
      (request, resp) -> {
        try {
          List<AppDescriptor> appDescriptors = Beans.marathonService.getAppDescriptors();
          List<AvailableApp> result =
              appDescriptors
                  .stream()
                  .map(OutputMapper::toAvailableApp)
                  .collect(Collectors.toList());
          return new ObjectMapper().writeValueAsString(result);
        } catch (Exception e) {
          logger.warn(e.getMessage(), e);
          throw e;
        }
      });
  post(
      "/deploy",
      (request, resp) -> {
        Deploy deploy = new ObjectMapper().readValue(request.body(), Deploy.class);

        // find running application in marathon
        Optional<AppDescriptor> appDescriptor =
            Beans.marathonService
                .getAppDescriptors()
                .stream()
                .filter(desc -> desc.getId().equals(deploy.getApplication()))
                .findFirst();

        if (!appDescriptor.isPresent()) {
          resp.status(404);
          logger.warn("app not running in marathon");
          return "app not running in marathon";
        }
        App app = appDescriptor.get().getApp();

        // find latest revision in Docker Registry
        Optional<Revision> revision =
            Beans.dockerService.latestRevision(
                ParseHelper.getFullDockerImageName(appDescriptor.get().getDockerImageUrl()),
                deploy.getBranch(),
                deploy.getChannel());

        if (!revision.isPresent()) {
          resp.status(404);
          logger.warn("revision not found");
          return "revision not found";
        }

        // upgrade application
        Docker docker = app.getContainer().getDocker();
        String image = appDescriptor.get().getDockerImageUrl() + ":" + revision.get().fullName();
        docker.setImage(image);
        Optional<String> deploymentId = Beans.marathonService.putApp(app);
        if (deploymentId.isPresent()) {
          return new ObjectMapper().writeValueAsString(toViewRevision(revision.get()));
        } else {
          resp.status(500);
          logger.warn("Deployment request {} failed to deploy {}", deploy, image);
          return "failed";
        }
      });
}
 

开发者ID:ecg-mechaniker,
项目名称:mechaniker,
代码行数:70,
代码来源:SparkWebapp.java

示例9: createPravegaSegmentStoreApp

点赞 2

import mesosphere.marathon.client.model.v2.Docker; //导入依赖的package包/类
private App createPravegaSegmentStoreApp() {
    App app = new App();
    app.setId(this.id);
    app.setCpus(cpu);
    app.setMem(mem);
    app.setInstances(instances);
    //set constraints
    app.setConstraints(setConstraint("hostname", "UNIQUE"));
    //docker container
    app.setContainer(new Container());
    app.getContainer().setType(CONTAINER_TYPE);
    app.getContainer().setDocker(new Docker());
    //set the image and network
    app.getContainer().getDocker().setImage(IMAGE_PATH + "/nautilus/pravega:" + PRAVEGA_VERSION);
    //set port
    app.setPortDefinitions(Arrays.asList(createPortDefinition(SEGMENTSTORE_PORT)));
    app.setRequirePorts(true);
    //healthchecks
    List<HealthCheck> healthCheckList = new ArrayList<HealthCheck>();
    healthCheckList.add(setHealthCheck(300, "TCP", false, 60, 20, 0, SEGMENTSTORE_PORT));
    app.setHealthChecks(healthCheckList);
    //set env
    String zk = zkUri.getHost() + ":" + ZKSERVICE_ZKPORT;

    //Environment variables to configure SS service.
    Map<String, Object> map = new HashMap<>();
    map.put("ZK_URL", zk);
    map.put("BK_ZK_URL", zk);
    map.put("CONTROLLER_URL", conUri.toString());
    getCustomEnvVars(map, SEGMENTSTORE_EXTRA_ENV);

    //Properties set to override defaults for system tests
    String hostSystemProperties = "-Xmx1024m" +
            setSystemProperty("autoScale.muteInSeconds", "120") +
            setSystemProperty("autoScale.cooldownInSeconds", "120") +
            setSystemProperty("autoScale.cacheExpiryInSeconds", "120") +
            setSystemProperty("autoScale.cacheCleanUpInSeconds", "120") +
            setSystemProperty("log.level", "DEBUG") +
            setSystemProperty("log.dir", "$MESOS_SANDBOX/pravegaLogs") +
            setSystemProperty("curator-default-session-timeout", String.valueOf(30 * 1000)) +
            setSystemProperty("hdfs.replaceDataNodesOnFailure", "false");

    map.put("PRAVEGA_SEGMENTSTORE_OPTS", hostSystemProperties);
    app.setEnv(map);
    app.setArgs(Arrays.asList("segmentstore"));

    return app;
}
 

开发者ID:pravega,
项目名称:pravega,
代码行数:49,
代码来源:PravegaSegmentStoreService.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)