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


Java Ulimit类代码示例

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


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

示例1: verify_container_SIMPLE_create_with_ports_and_volumes_and_variables

import com.github.dockerjava.api.model.Ulimit; //导入依赖的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

示例2: withUlimit

import com.github.dockerjava.api.model.Ulimit; //导入依赖的package包/类
@Override
public Docker.CreateContainerCommand withUlimit(String name, int softLimit, int hardLimit) {
    ulimits.add(new Ulimit(name, softLimit, hardLimit));
    return this;
}
 
开发者ID:vespa-engine,项目名称:vespa,代码行数:6,代码来源:CreateContainerCommandImpl.java

示例3: getUlimits

import com.github.dockerjava.api.model.Ulimit; //导入依赖的package包/类
@CheckForNull
Ulimit[] getUlimits();
 
开发者ID:docker-java,项目名称:docker-java,代码行数:3,代码来源:CreateContainerCmd.java

示例4: getUlimits

import com.github.dockerjava.api.model.Ulimit; //导入依赖的package包/类
@Override
@JsonIgnore
public Ulimit[] getUlimits() {
    return hostConfig.getUlimits();
}
 
开发者ID:docker-java,项目名称:docker-java,代码行数:6,代码来源:CreateContainerCmdImpl.java

示例5: withUlimits

import com.github.dockerjava.api.model.Ulimit; //导入依赖的package包/类
@Override
public CreateContainerCmd withUlimits(Ulimit... ulimits) {
    checkNotNull(ulimits, "no ulimits was specified");
    hostConfig.withUlimits(ulimits);
    return this;
}
 
开发者ID:docker-java,项目名称:docker-java,代码行数:7,代码来源:CreateContainerCmdImpl.java

示例6: createContainerWithULimits

import com.github.dockerjava.api.model.Ulimit; //导入依赖的package包/类
@Test
public void createContainerWithULimits() throws DockerException {
    String containerName = "containerulimit" + dockerRule.getKind();
    Ulimit[] ulimits = {new Ulimit("nproc", 709, 1026), new Ulimit("nofile", 1024, 4096)};

    CreateContainerResponse container = dockerRule.getClient().createContainerCmd(DEFAULT_IMAGE)
            .withName(containerName)
            .withUlimits(ulimits).exec();

    LOG.info("Created container {}", container.toString());

    assertThat(container.getId(), not(isEmptyString()));

    InspectContainerResponse inspectContainerResponse = dockerRule.getClient().inspectContainerCmd(container.getId()).exec();

    assertThat(Arrays.asList(inspectContainerResponse.getHostConfig().getUlimits()),
            containsInAnyOrder(new Ulimit("nproc", 709, 1026), new Ulimit("nofile", 1024, 4096)));

}
 
开发者ID:docker-java,项目名称:docker-java,代码行数:20,代码来源:CreateContainerCmdIT.java

示例7: withUlimits

import com.github.dockerjava.api.model.Ulimit; //导入依赖的package包/类
CreateContainerCmd withUlimits(Ulimit... ulimits); 
开发者ID:docker-java,项目名称:docker-java,代码行数:2,代码来源:CreateContainerCmd.java


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