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

Java AppDefinition类代码示例

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

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



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

示例1: deployWithEnvironmentWithCommaDelimitedValue

import org.springframework.cloud.deployer.spi.core.AppDefinition; //导入依赖的package包/类
@Test
public void deployWithEnvironmentWithCommaDelimitedValue() throws Exception {
	AppDefinition definition = new AppDefinition("app-test", null);
	Map<String, String> props = new HashMap<>();
	props.put("spring.cloud.deployer.kubernetes.environmentVariables",
		"foo='bar,baz',car=caz,boo='zoo,gnu',doo=dar");

	AppDeploymentRequest appDeploymentRequest = new AppDeploymentRequest(definition, getResource(), props);

	deployer = new KubernetesAppDeployer(bindDeployerProperties(), null);
	PodSpec podSpec = deployer.createPodSpec("1", appDeploymentRequest, 8080, false);

	assertThat(podSpec.getContainers().get(0).getEnv())
		.contains(
			new EnvVar("foo", "bar,baz", null),
			new EnvVar("car", "caz", null),
			new EnvVar("boo", "zoo,gnu", null),
			new EnvVar("doo", "dar", null));
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-deployer-kubernetes,代码行数:20,代码来源:KubernetesAppDeployerTests.java


示例2: create

import org.springframework.cloud.deployer.spi.core.AppDefinition; //导入依赖的package包/类
@Test
public void create() {
	KubernetesDeployerProperties kubernetesDeployerProperties = new KubernetesDeployerProperties();
	DefaultContainerFactory defaultContainerFactory = new DefaultContainerFactory(
			kubernetesDeployerProperties);

	AppDefinition definition = new AppDefinition("app-test", null);
	Resource resource = getResource();
	Map<String, String> props = new HashMap<>();
	props.put("spring.cloud.deployer.kubernetes.memory", "128Mi");
	props.put("spring.cloud.deployer.kubernetes.environmentVariables",
			"JAVA_OPTIONS=-Xmx64m,KUBERNETES_NAMESPACE=test-space");
	AppDeploymentRequest appDeploymentRequest = new AppDeploymentRequest(definition,
			resource, props);

	Container container = defaultContainerFactory.create("app-test",
			appDeploymentRequest, null, null, false);
	assertNotNull(container);
	assertEquals(3, container.getEnv().size());
	EnvVar envVar1 = container.getEnv().get(0);
	EnvVar envVar2 = container.getEnv().get(1);
	assertEquals("JAVA_OPTIONS", envVar1.getName());
	assertEquals("-Xmx64m", envVar1.getValue());
	assertEquals("KUBERNETES_NAMESPACE", envVar2.getName());
	assertEquals("test-space", envVar2.getValue());
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-deployer-kubernetes,代码行数:27,代码来源:DefaultContainerFactoryTests.java


示例3: createWithContainerCommand

import org.springframework.cloud.deployer.spi.core.AppDefinition; //导入依赖的package包/类
@Test
public void createWithContainerCommand() {
	KubernetesDeployerProperties kubernetesDeployerProperties = new KubernetesDeployerProperties();
	DefaultContainerFactory defaultContainerFactory = new DefaultContainerFactory(
			kubernetesDeployerProperties);

	AppDefinition definition = new AppDefinition("app-test", null);
	Resource resource = getResource();
	Map<String, String> props = new HashMap<>();
	props.put("spring.cloud.deployer.kubernetes.containerCommand",
			"echo arg1 'arg2'");
	AppDeploymentRequest appDeploymentRequest = new AppDeploymentRequest(definition,
			resource, props);

	Container container = defaultContainerFactory.create("app-test",
			appDeploymentRequest, null, null, false);
	assertNotNull(container);
	assertThat(container.getCommand()).containsExactly("echo", "arg1", "arg2");
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-deployer-kubernetes,代码行数:20,代码来源:DefaultContainerFactoryTests.java


示例4: createWithPorts

import org.springframework.cloud.deployer.spi.core.AppDefinition; //导入依赖的package包/类
@Test
public void createWithPorts() {
	KubernetesDeployerProperties kubernetesDeployerProperties = new KubernetesDeployerProperties();
	DefaultContainerFactory defaultContainerFactory = new DefaultContainerFactory(
			kubernetesDeployerProperties);

	AppDefinition definition = new AppDefinition("app-test", null);
	Resource resource = getResource();
	Map<String, String> props = new HashMap<>();
	props.put("spring.cloud.deployer.kubernetes.containerPorts",
			"8081, 8082, 65535");
	AppDeploymentRequest appDeploymentRequest = new AppDeploymentRequest(definition,
			resource, props);

	Container container = defaultContainerFactory.create("app-test",
			appDeploymentRequest, null, null, false);
	assertNotNull(container);
	List<ContainerPort> containerPorts = container.getPorts();
	assertNotNull(containerPorts);
	assertTrue("There should be three ports set", containerPorts.size() == 3);
	assertTrue(8081 == containerPorts.get(0).getContainerPort());
	assertTrue(8082 == containerPorts.get(1).getContainerPort());
	assertTrue(65535 == containerPorts.get(2).getContainerPort());
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-deployer-kubernetes,代码行数:25,代码来源:DefaultContainerFactoryTests.java


示例5: createWithInvalidPort

import org.springframework.cloud.deployer.spi.core.AppDefinition; //导入依赖的package包/类
@Test(expected = NumberFormatException.class)
public void createWithInvalidPort() {
	KubernetesDeployerProperties kubernetesDeployerProperties = new KubernetesDeployerProperties();
	DefaultContainerFactory defaultContainerFactory = new DefaultContainerFactory(
			kubernetesDeployerProperties);

	AppDefinition definition = new AppDefinition("app-test", null);
	Resource resource = getResource();
	Map<String, String> props = new HashMap<>();
	props.put("spring.cloud.deployer.kubernetes.containerPorts",
			"8081, 8082, invalid, 9212");
	AppDeploymentRequest appDeploymentRequest = new AppDeploymentRequest(definition,
			resource, props);

	//Attempting to create with an invalid integer set for a port should cause an exception to bubble up.
	defaultContainerFactory.create("app-test", appDeploymentRequest, null, null, false);
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-deployer-kubernetes,代码行数:18,代码来源:DefaultContainerFactoryTests.java


示例6: testGoodDeploymentWithLoadBalancer

import org.springframework.cloud.deployer.spi.core.AppDefinition; //导入依赖的package包/类
@Test
public void testGoodDeploymentWithLoadBalancer() {
	log.info("Testing {}...", "GoodDeploymentWithLoadBalancer");
	KubernetesDeployerProperties deployProperties = new KubernetesDeployerProperties();
	deployProperties.setCreateDeployment(originalProperties.isCreateDeployment());
	deployProperties.setCreateLoadBalancer(true);
	deployProperties.setMinutesToWaitForLoadBalancer(1);
	ContainerFactory containerFactory = new DefaultContainerFactory(deployProperties);
	KubernetesAppDeployer lbAppDeployer = new KubernetesAppDeployer(deployProperties, kubernetesClient, containerFactory);

	AppDefinition definition = new AppDefinition(randomName(), null);
	Resource resource = testApplication();
	AppDeploymentRequest request = new AppDeploymentRequest(definition, resource);

	log.info("Deploying {}...", request.getDefinition().getName());
	String deploymentId = lbAppDeployer.deploy(request);
	Timeout timeout = deploymentTimeout();
	assertThat(deploymentId, eventually(hasStatusThat(
			Matchers.hasProperty("state", is(deployed))), timeout.maxAttempts, timeout.pause));

	log.info("Undeploying {}...", deploymentId);
	timeout = undeploymentTimeout();
	lbAppDeployer.undeploy(deploymentId);
	assertThat(deploymentId, eventually(hasStatusThat(
			Matchers.hasProperty("state", is(unknown))), timeout.maxAttempts, timeout.pause));
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-deployer-kubernetes,代码行数:27,代码来源:KubernetesAppDeployerIntegrationTests.java


示例7: testDeployingStateCalculationAndCancel

import org.springframework.cloud.deployer.spi.core.AppDefinition; //导入依赖的package包/类
/**
 * Tests that an app which takes a long time to deploy is correctly reported as deploying.
 * Test that such an app can be undeployed.
 */
@Test
public void testDeployingStateCalculationAndCancel() {
	Map<String, String> properties = new HashMap<>();
	properties.put("initDelay", "" + 1000 * 60 * 60); // 1hr
	AppDefinition definition = new AppDefinition(randomName(), properties);
	Resource resource = testApplication();
	AppDeploymentRequest request = new AppDeploymentRequest(definition, resource, properties);

	log.info("Deploying {}...", request.getDefinition().getName());

	String deploymentId = appDeployer().deploy(request);
	Timeout timeout = deploymentTimeout();
	assertThat(deploymentId, eventually(hasStatusThat(
			Matchers.<AppStatus>hasProperty("state", is(deploying))), timeout.maxAttempts, timeout.pause));

	log.info("Undeploying {}...", deploymentId);

	timeout = undeploymentTimeout();
	appDeployer().undeploy(deploymentId);
	assertThat(deploymentId, eventually(hasStatusThat(
			Matchers.<AppStatus>hasProperty("state", is(unknown))), timeout.maxAttempts, timeout.pause));

}
 
开发者ID:spring-cloud,项目名称:spring-cloud-deployer,代码行数:28,代码来源:AbstractAppDeployerIntegrationTests.java


示例8: testFailedDeployment

import org.springframework.cloud.deployer.spi.core.AppDefinition; //导入依赖的package包/类
@Test
public void testFailedDeployment() {
	Map<String, String> properties = new HashMap<>();
	properties.put("killDelay", "0");
	AppDefinition definition = new AppDefinition(randomName(), properties);
	Resource resource = testApplication();
	AppDeploymentRequest request = new AppDeploymentRequest(definition, resource, properties);

	log.info("Deploying {}...", request.getDefinition().getName());

	String deploymentId = appDeployer().deploy(request);
	Timeout timeout = deploymentTimeout();
	assertThat(deploymentId, eventually(hasStatusThat(
			Matchers.<AppStatus>hasProperty("state", is(failed))), timeout.maxAttempts, timeout.pause));

	log.info("Undeploying {}...", deploymentId);

	timeout = undeploymentTimeout();
	appDeployer().undeploy(deploymentId);
	assertThat(deploymentId, eventually(hasStatusThat(
			Matchers.<AppStatus>hasProperty("state", is(unknown))), timeout.maxAttempts, timeout.pause));
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-deployer,代码行数:23,代码来源:AbstractAppDeployerIntegrationTests.java


示例9: testSimpleLaunch

import org.springframework.cloud.deployer.spi.core.AppDefinition; //导入依赖的package包/类
@Test
public void testSimpleLaunch() throws InterruptedException {
	Map<String, String> appProperties = new HashMap<>();
	appProperties.put("killDelay", "0");
	appProperties.put("exitCode", "0");
	AppDefinition definition = new AppDefinition(randomName(), appProperties);
	Resource resource = testApplication();
	AppDeploymentRequest request = new AppDeploymentRequest(definition, resource);

	log.info("Launching {}...", request.getDefinition().getName());
	String launchId = taskLauncher().launch(request);

	Timeout timeout = deploymentTimeout();
	assertThat(launchId, eventually(hasStatusThat(
			Matchers.<TaskStatus>hasProperty("state", Matchers.is(LaunchState.complete))), timeout.maxAttempts, timeout.pause));

	taskLauncher().destroy(definition.getName());
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-deployer,代码行数:19,代码来源:AbstractTaskLauncherIntegrationTests.java


示例10: testErrorExit

import org.springframework.cloud.deployer.spi.core.AppDefinition; //导入依赖的package包/类
@Test
public void testErrorExit() throws InterruptedException {
	Map<String, String> appProperties = new HashMap<>();
	appProperties.put("killDelay", "0");
	appProperties.put("exitCode", "1");
	AppDefinition definition = new AppDefinition(randomName(), appProperties);
	Resource resource = testApplication();
	AppDeploymentRequest request = new AppDeploymentRequest(definition, resource);

	log.info("Launching {}...", request.getDefinition().getName());
	String launchId = taskLauncher().launch(request);

	Timeout timeout = deploymentTimeout();
	assertThat(launchId, eventually(hasStatusThat(
			Matchers.<TaskStatus>hasProperty("state", Matchers.is(LaunchState.failed))), timeout.maxAttempts, timeout.pause));

	taskLauncher().destroy(definition.getName());
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-deployer,代码行数:19,代码来源:AbstractTaskLauncherIntegrationTests.java


示例11: testSimpleCancel

import org.springframework.cloud.deployer.spi.core.AppDefinition; //导入依赖的package包/类
@Test
public void testSimpleCancel() throws InterruptedException {
	Map<String, String> appProperties = new HashMap<>();
	appProperties.put("killDelay", "-1");
	appProperties.put("exitCode", "0");
	AppDefinition definition = new AppDefinition(randomName(), appProperties);
	Resource resource = testApplication();
	AppDeploymentRequest request = new AppDeploymentRequest(definition, resource);

	log.info("Launching {}...", request.getDefinition().getName());
	String launchId = taskLauncher().launch(request);

	Timeout timeout = deploymentTimeout();
	assertThat(launchId, eventually(hasStatusThat(
			Matchers.<TaskStatus>hasProperty("state", Matchers.is(LaunchState.running))), timeout.maxAttempts, timeout.pause));

	log.info("Cancelling {}...", request.getDefinition().getName());
	taskLauncher().cancel(launchId);

	timeout = undeploymentTimeout();
	assertThat(launchId, eventually(hasStatusThat(
			Matchers.<TaskStatus>hasProperty("state", Matchers.is(LaunchState.cancelled))), timeout.maxAttempts, timeout.pause));

	taskLauncher().destroy(definition.getName());
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-deployer,代码行数:26,代码来源:AbstractTaskLauncherIntegrationTests.java


示例12: testCommandLineArgs

import org.springframework.cloud.deployer.spi.core.AppDefinition; //导入依赖的package包/类
/**
 * Tests that command line args can be passed in.
 */
@Test
public void testCommandLineArgs() {
	Map<String, String> properties = new HashMap<>();
	properties.put("killDelay", "1000");
	AppDefinition definition = new AppDefinition(randomName(), properties);
	Resource resource = testApplication();
	AppDeploymentRequest request = new AppDeploymentRequest(definition, resource, Collections.<String, String>emptyMap(),
			Collections.singletonList("--exitCode=0"));
	log.info("Launching {}...", request.getDefinition().getName());
	String deploymentId = taskLauncher().launch(request);

	Timeout timeout = deploymentTimeout();
	assertThat(deploymentId, eventually(hasStatusThat(
			Matchers.<TaskStatus>hasProperty("state", Matchers.is(complete))), timeout.maxAttempts, timeout.pause));
	taskLauncher().destroy(definition.getName());
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-deployer,代码行数:20,代码来源:AbstractTaskLauncherIntegrationTests.java


示例13: deploy

import org.springframework.cloud.deployer.spi.core.AppDefinition; //导入依赖的package包/类
public String deploy(String name, String path, String... args) {
	Resource resource = new FileSystemResource(
			ArchiveUtils.getArchiveRoot(ArchiveUtils.getArchive(path)));
	AppDefinition definition = new AppDefinition(resource.getFilename(),
			Collections.singletonMap(LiveBeansView.MBEAN_DOMAIN_PROPERTY_NAME,
					"functions." + name));
	AppDeploymentRequest request = new AppDeploymentRequest(definition, resource,
			Collections.singletonMap(AppDeployer.GROUP_PROPERTY_KEY, "functions"),
			Arrays.asList(args));
	String id = this.deployer.deploy(request);
	this.deployed.put(id, path);
	this.names.put(name, id);
	this.ids.put(id, name);
	register(name);
	return id;
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-function,代码行数:17,代码来源:FunctionExtractingFunctionCatalog.java


示例14: TaskDefinition

import org.springframework.cloud.deployer.spi.core.AppDefinition; //导入依赖的package包/类
public TaskDefinition(String name, String dsl) {
	this.dslText = dsl;
	Map<String, String> properties = new HashMap<>();
	TaskNode taskNode = new TaskParser(name, dsl, true, true).parse();
	if (taskNode.isComposed()) {
		setRegisteredAppName(name);
	}
	else {
		TaskAppNode singleTaskApp = taskNode.getTaskApp();
		setRegisteredAppName(singleTaskApp.getName());
		if (singleTaskApp.hasArguments()) {
			for (ArgumentNode argumentNode : singleTaskApp.getArguments()) {
				properties.put(argumentNode.getName(), argumentNode.getValue());
			}
		}
	}
	properties.put(SPRING_CLOUD_TASK_NAME, name);
	this.appDefinition = new AppDefinition(name, properties);
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-dataflow,代码行数:20,代码来源:TaskDefinition.java


示例15: createAppDeploymentRequest

import org.springframework.cloud.deployer.spi.core.AppDefinition; //导入依赖的package包/类
/**
 * Creates an {@link AppDeploymentRequest}.
 *
 * @param applicationSpec the Spring Cloud Deployer application spec
 * @param releaseName the release name
 * @param version the release version
 * @return a created AppDeploymentRequest
 */
public AppDeploymentRequest createAppDeploymentRequest(SpringCloudDeployerApplicationManifest applicationSpec, String releaseName,
		String version) {
	SpringCloudDeployerApplicationSpec spec = applicationSpec.getSpec();
	Map<String, String> applicationProperties = new TreeMap<>();
	if (spec.getApplicationProperties() != null) {
		applicationProperties.putAll(spec.getApplicationProperties());
	}
	// we need to keep group name same for consumer groups not getting broken, but
	// app name needs to differentiate as otherwise it may result same deployment id and
	// failure on a deployer.
	AppDefinition appDefinition = new AppDefinition(applicationSpec.getApplicationName() + "-v" + version,
			applicationProperties);
	Resource resource;
	try {
		resource = delegatingResourceLoader.getResource(getResourceLocation(spec.getResource(), spec.getVersion()));
	}
	catch (Exception e) {
		throw new SkipperException(
				"Could not load Resource " + spec.getResource() + ". Message = " + e.getMessage(), e);
	}

	Map<String, String> deploymentProperties = new TreeMap<>();
	if (spec.getDeploymentProperties() != null) {
		deploymentProperties.putAll(spec.getDeploymentProperties());
	}
	if (!deploymentProperties.containsKey(AppDeployer.GROUP_PROPERTY_KEY)) {
		logger.debug("Defaulting spring.cloud.deployer.group=" + releaseName);
		deploymentProperties.put(AppDeployer.GROUP_PROPERTY_KEY, releaseName);
	}
	AppDeploymentRequest appDeploymentRequest = new AppDeploymentRequest(appDefinition, resource,
			deploymentProperties);
	return appDeploymentRequest;
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-skipper,代码行数:42,代码来源:AppDeploymentRequestFactory.java


示例16: deployApplication

import org.springframework.cloud.deployer.spi.core.AppDefinition; //导入依赖的package包/类
private void deployApplication(ApplicationDefinition application, Map<String, String> applicationDeploymentProperties) {
	logger.info("Deploying application [" + application + "]");
	if (applicationDeploymentProperties == null) {
		applicationDeploymentProperties = Collections.emptyMap();
	}

	String type = eavRegistryRepository.findOne("spring-cloud-deployer-admin-app-" + application.getRegisteredAppName(), "type");

	AppRegistration registration = this.appRegistry.find(application.getRegisteredAppName(), type);

	Map<String, String> deployerDeploymentProperties = DeploymentPropertiesUtils
			.extractAndQualifyDeployerProperties(applicationDeploymentProperties, application.getRegisteredAppName());
	deployerDeploymentProperties.put(AppDeployer.GROUP_PROPERTY_KEY, application.getName());

	Resource resource = registration.getResource();

	AppDefinition revisedDefinition = mergeAndExpandAppProperties(application, resource, applicationDeploymentProperties);
	logger.info("Using AppDefinition [" + revisedDefinition + "]");
	AppDeploymentRequest request = new AppDeploymentRequest(revisedDefinition, resource, deployerDeploymentProperties);
	logger.info("Using AppDeploymentRequest [" + request + "]");

	try {
		String id = this.appDeployer.deploy(request);
		this.deploymentIdRepository.save(forApplicationDefinition(application), id);
	}
	// If the deployer implementation handles the deployment request synchronously, log error message if
	// any exception is thrown out of the deployment and proceed to the next deployment.
	catch (Exception e) {
		logger.error(String.format("Exception when deploying the app %s: %s", application, e.getMessage()), e);
	}

}
 
开发者ID:spring-cloud,项目名称:spring-cloud-dashboard,代码行数:33,代码来源:ApplicationDeploymentController.java


示例17: ApplicationDefinition

import org.springframework.cloud.deployer.spi.core.AppDefinition; //导入依赖的package包/类
public ApplicationDefinition(String name, String dslText) {
	super();
	this.name = name;
	this.dslText = dslText;
	// ApplicationParser
	AppNode applicationNode = new ApplicationParser(name, dslText).parse();
	Map<String, String> properties = new HashMap<>();
	if (applicationNode.hasArguments()) {
		for (ArgumentNode argumentNode : applicationNode.getArguments()) {
			properties.put(argumentNode.getName(), argumentNode.getValue());
		}
	}
	setRegisteredAppName(applicationNode.getName());
	this.appDefinition = new AppDefinition(name, properties);
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-dashboard,代码行数:16,代码来源:ApplicationDefinition.java


示例18: deployWithVolumesOnly

import org.springframework.cloud.deployer.spi.core.AppDefinition; //导入依赖的package包/类
@Test
public void deployWithVolumesOnly() throws Exception {
	AppDefinition definition = new AppDefinition("app-test", null);
	AppDeploymentRequest appDeploymentRequest = new AppDeploymentRequest(definition, getResource(),
		new HashMap<>());

	deployer = new KubernetesAppDeployer(bindDeployerProperties(), null);
	PodSpec podSpec = deployer.createPodSpec("1", appDeploymentRequest, 8080, false);

	assertThat(podSpec.getVolumes()).isEmpty();
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-deployer-kubernetes,代码行数:12,代码来源:KubernetesAppDeployerTests.java


示例19: deployWithNodeSelector

import org.springframework.cloud.deployer.spi.core.AppDefinition; //导入依赖的package包/类
@Test
public void deployWithNodeSelector() throws Exception {
	AppDefinition definition = new AppDefinition("app-test", null);
	Map<String, String> props = new HashMap<>();
	props.put("spring.cloud.deployer.kubernetes.deployment.nodeSelector", "disktype:ssd, os: linux");
	AppDeploymentRequest appDeploymentRequest = new AppDeploymentRequest(definition, getResource(), props);

	deployer = new KubernetesAppDeployer(bindDeployerProperties(), null);
	PodSpec podSpec = deployer.createPodSpec("1", appDeploymentRequest, 8080, false);

	assertThat(podSpec.getNodeSelector()).containsOnly(entry("disktype", "ssd"), entry("os", "linux"));

}
 
开发者ID:spring-cloud,项目名称:spring-cloud-deployer-kubernetes,代码行数:14,代码来源:KubernetesAppDeployerTests.java


示例20: createWithPortAndHostNetwork

import org.springframework.cloud.deployer.spi.core.AppDefinition; //导入依赖的package包/类
@Test
public void createWithPortAndHostNetwork() {
	KubernetesDeployerProperties kubernetesDeployerProperties = new KubernetesDeployerProperties();
	DefaultContainerFactory defaultContainerFactory = new DefaultContainerFactory(
			kubernetesDeployerProperties);

	AppDefinition definition = new AppDefinition("app-test", null);
	Resource resource = getResource();
	Map<String, String> props = new HashMap<>();
	props.put("spring.cloud.deployer.kubernetes.containerPorts",
			"8081, 8082, 65535");
	AppDeploymentRequest appDeploymentRequest = new AppDeploymentRequest(definition,
			resource, props);

	Container container = defaultContainerFactory.create("app-test",
			appDeploymentRequest, null, null, true);
	assertNotNull(container);
	List<ContainerPort> containerPorts = container.getPorts();
	assertNotNull(containerPorts);
	assertTrue("There should be three container ports set", containerPorts.size() == 3);
	assertTrue(8081 == containerPorts.get(0).getContainerPort());
	assertTrue(8081 == containerPorts.get(0).getHostPort());
	assertTrue(8082 == containerPorts.get(1).getContainerPort());
	assertTrue(8082 == containerPorts.get(1).getHostPort());
	assertTrue(65535 == containerPorts.get(2).getContainerPort());
	assertTrue(65535 == containerPorts.get(2).getHostPort());
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-deployer-kubernetes,代码行数:28,代码来源:DefaultContainerFactoryTests.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Java RedisCache类代码示例发布时间:2022-05-22
下一篇:
Java JobStartEvent类代码示例发布时间: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