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


Java AppDefinition类代码示例

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


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


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