• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java AccessMode类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: build

import com.github.dockerjava.api.model.AccessMode; //导入依赖的package包/类
@Override
public CreateContainerCmd build(TestDescriptor td, CreateContainerCmd cmd, Volume v) {
	Bind[] binds = cmd.getBinds();
	
	String hostPath = v.useClasspath() 
			? Thread.currentThread().getContextClassLoader()
					.getResource(v.host()).getPath()
			: v.host();
	
	Bind bind = new Bind(hostPath, 
			new com.github.dockerjava.api.model.Volume(v.container()), 
			AccessMode.fromBoolean(v.accessMode().equals(Volume.AccessMode.RW)));
	
	List<Bind> bindsList = new ArrayList<>();
	if(binds != null) {
		bindsList.addAll(Arrays.asList(binds));
	} 
	bindsList.add(bind);  	
    return cmd.withBinds(bindsList);
}
 
开发者ID:qzagarese,项目名称:dockerunit,代码行数:21,代码来源:VolumeExtensionInterpreter.java


示例2: run

import com.github.dockerjava.api.model.AccessMode; //导入依赖的package包/类
@Override
public List<String> run(TestEnvironment testEnvironment) {
    String hostOsMountDir = System.getProperties().getProperty("buildDirectory");


    CreateContainerCmd containerBuilder = dockerClient.createContainerCmd(testEnvironment.getImage())
            .withBinds(new Bind(hostOsMountDir, new Volume(Constants.HAWKULAR_APM_AGENT_DIRECTORY),
                            AccessMode.ro, SELContext.shared),
                new Bind(scenarioDirectory, new Volume(Constants.HAWKULAR_APM_TEST_DIRECTORY),
                        AccessMode.ro, SELContext.shared))
            .withExtraHosts(Constants.HOST_ADDED_TO_ETC_HOSTS + ":" + apmBindAddress);

    if (userDefinedNetwork) {
        if (network == null) {
            throw new IllegalStateException("Create network before running environment");
        }
        containerBuilder.withNetworkMode(network.getName());
    }

    containerBuilder.withEnv(apmEnvVariables(testEnvironment.getType()));

    if (testEnvironment.isPull()) {
        log.info("Pulling image...");
        dockerClient.pullImageCmd(testEnvironment.getImage()).exec(new PullImageResultCallback()).awaitSuccess();
    }

    CreateContainerResponse containerResponse = containerBuilder.exec();
    log.info(String.format("Starting docker container: %s", containerResponse));

    try {
        dockerClient.startContainerCmd(containerResponse.getId()).exec();
    } catch (DockerException ex) {
        log.severe(String.format("Could not create or start docker container: %s", containerResponse));
        throw new EnvironmentException("Could not create or start docker container.", ex);
    }

    return Arrays.asList(containerResponse.getId());
}
 
开发者ID:hawkular,项目名称:hawkular-apm,代码行数:39,代码来源:DockerImageExecutor.java


示例3: dockerCommand

import com.github.dockerjava.api.model.AccessMode; //导入依赖的package包/类
@Override
protected CreateContainerCmd dockerCommand() {
    final String[] cmd = asList(
            "--mesos.master=" + mesosMasterIpAddress + ":5050",
            "--mesos.zookeeper.server=" + zookeeperIpAddress + ":2181",
            mesosRole.map(role -> "--mesos-role=" + role).orElse(null),
            "--enable.failover=false",
            elasticsearchHost.map(host -> "--logstash.elasticsearch-host=" + host).orElse(null),
            "--executor.heap-size=64",
            "--logstash.heap-size=256",
            "--enable.docker=" + useDocker,
            logstashConfig.map(file -> "--logstash.config-file=/config/" + file.getName()).orElse(null),
            withSyslog ? "--enable.syslog=true" : null
    ).stream().filter(StringUtils::isNotEmpty).toArray(String[]::new);

    final CreateContainerCmd containerCmd = dockerClient.createContainerCmd(SCHEDULER_IMAGE);
    logstashConfig.ifPresent(file -> {
        try {
            containerCmd.withBinds(new Bind(file.getParentFile().getCanonicalPath(), new Volume("/config"), AccessMode.ro));
        } catch (IOException e) {
            throw new IllegalStateException("Path error", e);
        }
    });
    return containerCmd
            .withName(SCHEDULER_NAME + "_" + new SecureRandom().nextInt())
            .withExposedPorts(ExposedPort.tcp(9092))
            .withCmd(cmd);
}
 
开发者ID:mesos,项目名称:logstash,代码行数:29,代码来源:LogstashSchedulerContainer.java


示例4: verify_container_SIMPLE_create_with_ports_and_volumes_and_variables

import com.github.dockerjava.api.model.AccessMode; //导入依赖的package包/类
@Test
public void verify_container_SIMPLE_create_with_ports_and_volumes_and_variables ()
		throws Exception {

	String imageName = BUSY_BOX;
	loadImageIfNeeded( imageName );

	String containerName = "/java-simple-" + LocalDateTime.now().format( DateTimeFormatter.ofPattern( "MMM.d-HH.mm.ss" ) );
	List<String> entryParameters = Arrays.asList( "nginx", "-g", "daemon off;" );
	List<String> cmdParameters = Arrays.asList( "nginx", "-v" );

	// ref. https://github.com/docker-java/docker-java/wiki
	ExposedPort tcp80 = ExposedPort.tcp( 80 );
	List<ExposedPort> exposedList = new ArrayList<>();
	// exposedList.add( tcp80 ) ;
	// ExposedPort tcp23 = ExposedPort.tcp(23);

	Ports portBindings = new Ports();
	portBindings.bind( tcp80, Ports.Binding.bindPort( 90 ) );
	// portBindings.bind( tcp80, Ports.Binding("") );

	List<Volumes> volumes = new ArrayList<>();
	Bind javaVolumeBind = new Bind( "/opt/java", new Volume( "/java" ), AccessMode.ro, SELContext.shared );

	List<String> environmentVariables = new ArrayList<>();
	environmentVariables.add( "JAVA_HOME=/opt/java" );
	environmentVariables.add( "WORKING_DIR=/working" );
	environmentVariables.add( "JAVA_OPTS=some path" );

	List<Ulimit> ulimits = new ArrayList<>();
	ulimits.add( new Ulimit( "nofile", 1000, 1000 ) );
	ulimits.add( new Ulimit( "nproc", 10, 10 ) );

	Map<String, String> jsonLogConfig = new HashMap<>();
	jsonLogConfig.put( "max-size", "10m" );
	jsonLogConfig.put( "max-file", "2" );

	LogConfig logConfig = new LogConfig( LoggingType.JSON_FILE, jsonLogConfig );
	CreateContainerResponse container = dockerClient
		.createContainerCmd( imageName )
		.withName( containerName )
		// .withCmd( cmdParameters )
		// .withEntrypoint( entryParameters )
		.withCpusetCpus( "0-1" )
		.withLogConfig( logConfig )
		.withCpuPeriod( 400000 )
		.withMemory( 20 * CSAP.MB_FROM_BYTES )
		.withUlimits( ulimits )
		.withExposedPorts( exposedList )
		.withPortBindings( portBindings )
		.withBinds( javaVolumeBind )
		.withHostName( "peter" )
		// .withNetworkMode( "host" )
		.withEnv( environmentVariables )
		.exec();

	InspectContainerResponse containerInfo = getContainerStatus( containerName );

	ObjectNode containerInfoJson = jacksonMapper.convertValue( containerInfo, ObjectNode.class );
	logger.info( "Name: {} ,  InfoJson: \n {}", containerInfo.getName(), pp( containerInfoJson ) );

	dockerClient.startContainerCmd( container.getId() )
		.exec();

	dockerClient
		.removeContainerCmd( container.getId() )
		.withRemoveVolumes( true )
		.withForce( true )
		.exec();
}
 
开发者ID:csap-platform,项目名称:csap-core,代码行数:71,代码来源:Docker_Java.java


示例5: createBind

import com.github.dockerjava.api.model.AccessMode; //导入依赖的package包/类
private Bind createBind(InstanceStartRequest request) {
    String outer = configManager.getOuterWebPackageRootDir(request.getAppId(), request.getInstanceIndex());
    Volume inner = new Volume(configManager.getInnerWebPackageRootDir());

    return new Bind(outer, inner, AccessMode.rw);
}
 
开发者ID:dianping,项目名称:Dolphin,代码行数:7,代码来源:BindVolumeCreateContainerPostProcessor.java


示例6: defaultAccessMode_blank

import com.github.dockerjava.api.model.AccessMode; //导入依赖的package包/类
@Test
public void defaultAccessMode_blank() {
    assertCreatesBinds(input("/host /container"), 
            expected("/host", "/container", AccessMode.DEFAULT));
}
 
开发者ID:jenkinsci,项目名称:docker-build-step-plugin,代码行数:6,代码来源:BindParserTest.java


示例7: defaultAccessMode_colon

import com.github.dockerjava.api.model.AccessMode; //导入依赖的package包/类
@Test
public void defaultAccessMode_colon() {
    assertCreatesBinds(input("/host:/container"), 
            expected("/host", "/container", AccessMode.DEFAULT));
}
 
开发者ID:jenkinsci,项目名称:docker-build-step-plugin,代码行数:6,代码来源:BindParserTest.java


示例8: Expected

import com.github.dockerjava.api.model.AccessMode; //导入依赖的package包/类
public Expected(String hostPath, String containerPath, AccessMode accessMode) {
    this.hostPath = hostPath;
    this.containerPath = containerPath;
    this.accessMode = accessMode;
}
 
开发者ID:jenkinsci,项目名称:docker-build-step-plugin,代码行数:6,代码来源:BindParserTest.java


示例9: expected

import com.github.dockerjava.api.model.AccessMode; //导入依赖的package包/类
/**
 * Designates the arguments as the expected result of parsing.<br>
 * For increased readability.
 * 
 * @param hostPath the expected host path of the parsing result
 * @param containerPath the expected container path of the parsing result
 * @param accessMode the access mode of the parsing result
 * @return a container object for the expected values
 */
private static Expected expected(String hostPath, String containerPath, AccessMode accessMode) {
    return new Expected(hostPath, containerPath, accessMode);
}
 
开发者ID:jenkinsci,项目名称:docker-build-step-plugin,代码行数:13,代码来源:BindParserTest.java



注:本文中的com.github.dockerjava.api.model.AccessMode类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java SVNErrorMessage类代码示例发布时间:2022-05-22
下一篇:
Java RegisterNodeManagerResponseProto类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap