当前位置: 首页>>代码示例>>Java>>正文


Java AccessMode类代码示例

本文整理汇总了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;未经允许,请勿转载。