本文整理汇总了Java中org.springframework.cloud.deployer.spi.core.AppDeploymentRequest类的典型用法代码示例。如果您正苦于以下问题:Java AppDeploymentRequest类的具体用法?Java AppDeploymentRequest怎么用?Java AppDeploymentRequest使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
AppDeploymentRequest类属于org.springframework.cloud.deployer.spi.core包,在下文中一共展示了AppDeploymentRequest类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: deploy
import org.springframework.cloud.deployer.spi.core.AppDeploymentRequest; //导入依赖的package包/类
private Map<String, String> deploy(Release replacingRelease, List<String> applicationNamesToUpgrade,
AppDeployer appDeployer) {
List<? extends SpringCloudDeployerApplicationManifest> applicationSpecList = this.applicationManifestReader
.read(replacingRelease
.getManifest().getData());
Map<String, String> appNameDeploymentIdMap = new HashMap<>();
for (SpringCloudDeployerApplicationManifest applicationManifest : applicationSpecList) {
if (applicationNamesToUpgrade.contains(applicationManifest.getApplicationName())) {
AppDeploymentRequest appDeploymentRequest = appDeploymentRequestFactory.createAppDeploymentRequest(
applicationManifest, replacingRelease.getName(),
String.valueOf(replacingRelease.getVersion()));
// =============
// DEPLOY DEPLOY
// =============
String deploymentId = appDeployer.deploy(appDeploymentRequest);
appNameDeploymentIdMap.put(applicationManifest.getApplicationName(), deploymentId);
}
}
return appNameDeploymentIdMap;
}
示例2: launch
import org.springframework.cloud.deployer.spi.core.AppDeploymentRequest; //导入依赖的package包/类
@Override
public String launch(AppDeploymentRequest request) {
String appId = createDeploymentId(request);
TaskStatus status = status(appId);
if (!status.getState().equals(LaunchState.unknown)) {
throw new IllegalStateException("Task " + appId + " already exists with a state of " + status);
}
Map<String, String> idMap = createIdMap(appId, request);
logger.debug(String.format("Launching pod for task: %s", appId));
try {
createPod(appId, request, idMap);
return appId;
} catch (RuntimeException e) {
logger.error(e.getMessage(), e);
throw e;
}
}
示例3: deduceImagePullPolicy
import org.springframework.cloud.deployer.spi.core.AppDeploymentRequest; //导入依赖的package包/类
/**
* Get the image pull policy for the deployment request. If it is not present use the server default. If an override
* for the deployment is present but not parseable, fall back to a default value.
*
* @param request The deployment request.
* @return The image pull policy to use for the container in the request.
*/
protected ImagePullPolicy deduceImagePullPolicy(AppDeploymentRequest request) {
String pullPolicyOverride =
request.getDeploymentProperties().get("spring.cloud.deployer.kubernetes.imagePullPolicy");
ImagePullPolicy pullPolicy;
if (pullPolicyOverride == null) {
pullPolicy = properties.getImagePullPolicy();
} else {
pullPolicy = ImagePullPolicy.relaxedValueOf(pullPolicyOverride);
if (pullPolicy == null) {
logger.warn("Parsing of pull policy " + pullPolicyOverride + " failed, using default \"Always\".");
pullPolicy = ImagePullPolicy.Always;
}
}
logger.debug("Using imagePullPolicy " + pullPolicy);
return pullPolicy;
}
开发者ID:spring-cloud,项目名称:spring-cloud-deployer-kubernetes,代码行数:25,代码来源:AbstractKubernetesDeployer.java
示例4: determineEntryPointStyle
import org.springframework.cloud.deployer.spi.core.AppDeploymentRequest; //导入依赖的package包/类
private EntryPointStyle determineEntryPointStyle(KubernetesDeployerProperties properties,
AppDeploymentRequest request) {
EntryPointStyle entryPointStyle = null;
String deployProperty = request.getDeploymentProperties()
.get("spring.cloud.deployer.kubernetes.entryPointStyle");
if (deployProperty != null) {
try {
entryPointStyle = EntryPointStyle.valueOf(deployProperty.toLowerCase());
}
catch (IllegalArgumentException ignore) {
}
}
if (entryPointStyle == null) {
entryPointStyle = properties.getEntryPointStyle();
}
return entryPointStyle;
}
示例5: deployWithEnvironmentWithCommaDelimitedValue
import org.springframework.cloud.deployer.spi.core.AppDeploymentRequest; //导入依赖的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
示例6: create
import org.springframework.cloud.deployer.spi.core.AppDeploymentRequest; //导入依赖的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
示例7: createWithContainerCommand
import org.springframework.cloud.deployer.spi.core.AppDeploymentRequest; //导入依赖的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
示例8: createWithPorts
import org.springframework.cloud.deployer.spi.core.AppDeploymentRequest; //导入依赖的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
示例9: createWithInvalidPort
import org.springframework.cloud.deployer.spi.core.AppDeploymentRequest; //导入依赖的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
示例10: testGoodDeploymentWithLoadBalancer
import org.springframework.cloud.deployer.spi.core.AppDeploymentRequest; //导入依赖的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
示例11: testDeployingStateCalculationAndCancel
import org.springframework.cloud.deployer.spi.core.AppDeploymentRequest; //导入依赖的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));
}
示例12: testErrorExit
import org.springframework.cloud.deployer.spi.core.AppDeploymentRequest; //导入依赖的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
示例13: testSimpleCancel
import org.springframework.cloud.deployer.spi.core.AppDeploymentRequest; //导入依赖的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
示例14: testCommandLineArgs
import org.springframework.cloud.deployer.spi.core.AppDeploymentRequest; //导入依赖的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
示例15: createContainer
import org.springframework.cloud.deployer.spi.core.AppDeploymentRequest; //导入依赖的package包/类
private Container createContainer(AppDeploymentRequest request) {
Container container = new Container();
Docker docker = new Docker();
String image = null;
try {
image = request.getResource().getURI().getSchemeSpecificPart();
} catch (IOException e) {
throw new IllegalArgumentException("Unable to get URI for " + request.getResource(), e);
}
logger.info("Using Docker image: " + image);
docker.setImage(image);
Port port = new Port(8080);
port.setHostPort(0);
docker.setPortMappings(Arrays.asList(port));
docker.setNetwork("BRIDGE");
container.setDocker(docker);
return container;
}