當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。