Java Code Examples for org.springframework.cloud.deployer.spi.app.AppDeployer

The following examples show how to use org.springframework.cloud.deployer.spi.app.AppDeployer. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: spring-cloud-skipper   Source File: DeployAppStep.java    License: Apache License 2.0 6 votes vote down vote up
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;
}
 
Example 2
public Release delete(Release release) {
	AppDeployer appDeployer = this.deployerRepository.findByNameRequired(release.getPlatformName())
			.getAppDeployer();
	AppDeployerData appDeployerData = this.appDeployerDataRepository
			.findByReleaseNameAndReleaseVersionRequired(release.getName(), release.getVersion());
	List<String> deploymentIds = (appDeployerData != null) ? appDeployerData.getDeploymentIds() : Collections.EMPTY_LIST;
	if (!deploymentIds.isEmpty()) {
		for (String deploymentId : deploymentIds) {
			try {
				appDeployer.undeploy(deploymentId);
			}
			catch (Exception e) {
				this.logger.error(String.format("Exception undeploying the application with the deploymentId %s. "
						+ "Exception message: %s", deploymentId, e.getMessage()));
			}
		}
		Status deletedStatus = new Status();
		deletedStatus.setStatusCode(StatusCode.DELETED);
		release.getInfo().setStatus(deletedStatus);
		release.getInfo().setDescription("Delete complete");
		this.releaseRepository.save(release);
	}
	return release;
}
 
Example 3
public ApplicationDeploymentController(ApplicationDefinitionRepository definitionRepository,
		DeploymentIdRepository deploymentIdRepository, EavRegistryRepository eavRegistryRepository,
		AppDeployer appDeployer, AppRegistry appRegistry,
		ApplicationConfigurationMetadataResolver metadataResolver, CommonApplicationProperties commonProperties) {
	Assert.notNull(definitionRepository, "ApplicationDefinitionRepository must not be null");
	Assert.notNull(deploymentIdRepository, "DeploymentIdRepository must not be null");
	Assert.notNull(eavRegistryRepository, "EavRegistryRepository must not be null");
	Assert.notNull(appDeployer, "AppDeployer must not be null");
	Assert.notNull(appRegistry, "AppRegistry must not be null");
	Assert.notNull(commonProperties, "CommonApplicationProperties must not be null");
	Assert.notNull(metadataResolver, "MetadataResolver must not be null");
	this.definitionRepository = definitionRepository;
	this.deploymentIdRepository = deploymentIdRepository;
	this.eavRegistryRepository = eavRegistryRepository;
	this.appDeployer = appDeployer;
	this.appRegistry = appRegistry;
	this.whitelistProperties = new WhitelistProperties(metadataResolver);
	this.commonApplicationProperties = commonProperties;
}
 
Example 4
Source Project: spring-cloud-consul   Source File: ConsulBinderTests.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Launch an application in a separate JVM.
 * @param clz the main class to launch
 * @param properties the properties to pass to the application
 * @param args the command line arguments for the application
 * @return a string identifier for the application
 */
private String launchApplication(Class<?> clz, Map<String, String> properties,
		List<String> args) {
	Resource resource = new UrlResource(
			clz.getProtectionDomain().getCodeSource().getLocation());

	properties.put(AppDeployer.GROUP_PROPERTY_KEY, "test-group");
	properties.put("main", clz.getName());
	properties.put("classpath", System.getProperty("java.class.path"));

	String appName = String.format("%s-%s", clz.getSimpleName(),
			properties.get("server.port"));
	AppDefinition definition = new AppDefinition(appName, properties);

	AppDeploymentRequest request = new AppDeploymentRequest(definition, resource,
			properties, args);
	return this.deployer.deploy(request);
}
 
Example 5
Source Project: spring-cloud-deployer-local   Source File: TickTock.java    License: Apache License 2.0 6 votes vote down vote up
private static AppDeploymentRequest createAppDeploymentRequest(String app, String stream) {
	MavenResource resource = new MavenResource.Builder()
			.artifactId(app)
			.groupId("org.springframework.cloud.stream.app")
			.version("1.0.0.BUILD-SNAPSHOT")
			.build();
	Map<String, String> properties = new HashMap<>();
	properties.put("server.port", "0");
	if (app.contains("-source-")) {
		properties.put("spring.cloud.stream.bindings.output.destination", stream);
	}
	else {
		properties.put("spring.cloud.stream.bindings.input.destination", stream);
		properties.put("spring.cloud.stream.bindings.input.group", "default");
	}
	AppDefinition definition = new AppDefinition(app, properties);
	Map<String, String> deploymentProperties = new HashMap<>();
	deploymentProperties.put(AppDeployer.GROUP_PROPERTY_KEY, stream);
	/*
	 * This will allow output to be logged to the output of the process that started
	 * the application.
	 */
	deploymentProperties.put(LocalDeployerProperties.INHERIT_LOGGING, "true");
	AppDeploymentRequest request = new AppDeploymentRequest(definition, resource, deploymentProperties);
	return request;
}
 
Example 6
@Test
// was triggered by GH-50 and subsequently GH-55
public void testNoStdoutStderrOnInheritLoggingAndNoNPEOnGetAttributes() {
	Map<String, String> properties = new HashMap<>();
	AppDefinition definition = new AppDefinition(randomName(), properties);
	Resource resource = testApplication();
	AppDeploymentRequest request = new AppDeploymentRequest(definition, resource, Collections.singletonMap(LocalDeployerProperties.INHERIT_LOGGING, "true"));

	AppDeployer deployer = appDeployer();
	String deploymentId = deployer.deploy(request);
	AppStatus appStatus = deployer.status(deploymentId);
	assertTrue(appStatus.getInstances().size() > 0);
	for (Entry<String, AppInstanceStatus> instanceStatusEntry : appStatus.getInstances().entrySet()) {
		Map<String, String> attributes = instanceStatusEntry.getValue().getAttributes();
		assertFalse(attributes.containsKey("stdout"));
		assertFalse(attributes.containsKey("stderr"));
	}
	deployer.undeploy(deploymentId);
}
 
Example 7
@Test
// was triggered by GH-50 and subsequently GH-55
public void testNoStdoutStderrOnInheritLoggingAndNoNPEOnGetAttributes() {
	Map<String, String> properties = new HashMap<>();
	AppDefinition definition = new AppDefinition(randomName(), properties);
	Resource resource = testApplication();
	AppDeploymentRequest request = new AppDeploymentRequest(definition, resource, Collections.singletonMap(LocalDeployerProperties.INHERIT_LOGGING, "true"));

	AppDeployer deployer = appDeployer();
	String deploymentId = deployer.deploy(request);
	AppStatus appStatus = deployer.status(deploymentId);
	assertTrue(appStatus.getInstances().size() > 0);
	for (Entry<String, AppInstanceStatus> instanceStatusEntry : appStatus.getInstances().entrySet()) {
		Map<String, String> attributes = instanceStatusEntry.getValue().getAttributes();
		assertFalse(attributes.containsKey("stdout"));
		assertFalse(attributes.containsKey("stderr"));
	}
	deployer.undeploy(deploymentId);
}
 
Example 8
/**
 * 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;
}
 
Example 9
Source Project: spring-cloud-skipper   Source File: DeleteStep.java    License: Apache License 2.0 5 votes vote down vote up
public Release delete(Release release, AppDeployerData existingAppDeployerData,
		List<String> applicationNamesToDelete) {
	AppDeployer appDeployer = this.deployerRepository.findByNameRequired(release.getPlatformName())
			.getAppDeployer();

	Map<String, String> appNamesAndDeploymentIds = (existingAppDeployerData!= null) ?
			existingAppDeployerData.getDeploymentDataAsMap() : Collections.EMPTY_MAP;

	for (Map.Entry<String, String> appNameAndDeploymentId : appNamesAndDeploymentIds.entrySet()) {
		if (applicationNamesToDelete.contains(appNameAndDeploymentId.getKey())) {
			AppStatus appStatus = appDeployer.status(appNameAndDeploymentId.getValue());
			if (appStatus.getState().equals(DeploymentState.deployed)) {
				appDeployer.undeploy(appNameAndDeploymentId.getValue());
			}
			else {
				logger.warn("For Release name {}, did not undeploy existing app {} as its status is not "
						+ "'deployed'.", release.getName(), appNameAndDeploymentId.getKey());
			}
		}
	}

	Status deletedStatus = new Status();
	deletedStatus.setStatusCode(StatusCode.DELETED);
	release.getInfo().setStatus(deletedStatus);
	release.getInfo().setDescription("Delete complete");
	this.releaseRepository.save(release);
	return release;
}
 
Example 10
@Override
public LogInfo getLog(Release release, String appName) {
	if (release.getInfo().getStatus().getStatusCode().equals(StatusCode.DELETED)) {
		return new LogInfo(Collections.EMPTY_MAP);
	}
	AppDeployerData appDeployerData = this.appDeployerDataRepository
			.findByReleaseNameAndReleaseVersion(release.getName(), release.getVersion());
	if (appDeployerData == null) {
		return new LogInfo(Collections.EMPTY_MAP);
	}
	AppDeployer appDeployer = this.deployerRepository.findByNameRequired(release.getPlatformName())
			.getAppDeployer();
	Map<String, String> logMap = new HashMap<>();
	Map<String, String> appNameDeploymentIdMap = appDeployerData.getDeploymentDataAsMap();
	Map<String, String> logApps = new HashMap<>();
	if (StringUtils.hasText(appName)) {
		for (Map.Entry<String, String> nameDeploymentId : appNameDeploymentIdMap.entrySet()) {
			if (appName.equalsIgnoreCase(nameDeploymentId.getValue())) {
				logApps.put(nameDeploymentId.getKey(), nameDeploymentId.getValue());
			}
		}
	}
	else {
		logApps = appNameDeploymentIdMap;
	}
	for (Map.Entry<String, String> deploymentIdEntry: logApps.entrySet()) {
		logMap.put(deploymentIdEntry.getValue(), appDeployer.getLog(deploymentIdEntry.getValue()));
	}
	return new LogInfo(logMap);
}
 
Example 11
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);
	}

}
 
Example 12
/**
 * Instantiates a new runtime apps controller.
 *
 * @param streamDefinitionRepository the repository this controller will use for stream CRUD operations
 * @param deploymentIdRepository the repository this controller will use for deployment IDs
 * @param appDeployer the deployer this controller will use to deploy stream apps
 */
public RuntimeAppsController(ApplicationDefinitionRepository applicationDefinitionRepository,
		DeploymentIdRepository deploymentIdRepository, AppDeployer appDeployer) {
	Assert.notNull(applicationDefinitionRepository, "ApplicationDefinitionRepository must not be null");
	Assert.notNull(deploymentIdRepository, "DeploymentIdRepository must not be null");
	Assert.notNull(appDeployer, "AppDeployer must not be null");
	this.applicationDefinitionRepository = applicationDefinitionRepository;
	this.deploymentIdRepository = deploymentIdRepository;
	this.appDeployer = appDeployer;
}
 
Example 13
public ApplicationDefinitionController(ApplicationDefinitionRepository definitionRepository,
		DeploymentIdRepository deploymentIdRepository, ApplicationDeploymentController deploymentController,
		AppDeployer appDeployer, AppRegistry appRegistry) {
	Assert.notNull(definitionRepository, "ApplicationDefinitionRepository must not be null");
	Assert.notNull(deploymentIdRepository, "DeploymentIdRepository must not be null");
	Assert.notNull(deploymentController, "ApplicationDeploymentController must not be null");
	Assert.notNull(appDeployer, "AppDeployer must not be null");
	Assert.notNull(appRegistry, "AppRegistry must not be null");
	this.definitionRepository = definitionRepository;
	this.deploymentIdRepository = deploymentIdRepository;
	this.deploymentController = deploymentController;
	this.appDeployer = appDeployer;
	this.appRegistry = appRegistry;
}
 
Example 14
Source Project: spring-cloud-cli   Source File: Deployer.java    License: Apache License 2.0 5 votes vote down vote up
private Map<String, String> getThinProperties(
		Map<String, String> properties) {
	Map<String, String> map = new HashMap<>();
	for (String key : properties.keySet()) {
		if (key.startsWith(AppDeployer.PREFIX + "thin.")) {
			map.put(key, properties.get(key));
		}
	}
	return map ;
}
 
Example 15
@Bean
@ConditionalOnBean(ApplicationDefinitionRepository.class)
public ApplicationDefinitionController applicationDefinitionController(ApplicationDefinitionRepository repository,
		DeploymentIdRepository deploymentIdRepository, ApplicationDeploymentController deploymentController,
		AppDeployer deployer, AppRegistry appRegistry) {
	return new ApplicationDefinitionController(repository, deploymentIdRepository, deploymentController, deployer, appRegistry);
}
 
Example 16
@Bean
@ConditionalOnBean(ApplicationDefinitionRepository.class)
public ApplicationDeploymentController applicationDeploymentController(ApplicationDefinitionRepository repository,
		DeploymentIdRepository deploymentIdRepository, EavRegistryRepository eavRegistryRepository,
		AppDeployer deployer, AppRegistry appRegistry, ApplicationConfigurationMetadataResolver metadataResolver,
		CommonApplicationProperties appsProperties) {
	return new ApplicationDeploymentController(repository, deploymentIdRepository, eavRegistryRepository, deployer,
			appRegistry, metadataResolver, appsProperties);
}
 
Example 17
/**
 * Creates a map of labels for a given application ID.
 *
 * @param appId the application id
 * @param request The {@link AppDeploymentRequest}
 * @return the built id map of labels
 */
Map<String, String> createIdMap(String appId, AppDeploymentRequest request) {
	Map<String, String> map = new HashMap<>();
	map.put(SPRING_APP_KEY, appId);
	String groupId = request.getDeploymentProperties().get(AppDeployer.GROUP_PROPERTY_KEY);
	if (groupId != null) {
		map.put(SPRING_GROUP_KEY, groupId);
	}
	map.put(SPRING_DEPLOYMENT_KEY, appId);
	return map;
}
 
Example 18
String createDeploymentId(AppDeploymentRequest request) {
	String groupId = request.getDeploymentProperties().get(AppDeployer.GROUP_PROPERTY_KEY);
	String deploymentId;
	if (groupId == null) {
		deploymentId = String.format("%s", request.getDefinition().getName());
	}
	else {
		deploymentId = String.format("%s-%s", groupId, request.getDefinition().getName());
	}
	// Kubernetes does not allow . in the name and does not allow uppercase in the name
	return deploymentId.replace('.', '-').toLowerCase();
}
 
Example 19
@Test
public void testDeployWithAppPropertiesOverride() throws Exception {
	repository.save(new StreamDefinition("myStream", "time --fixed-delay=2 | log --level=WARN"));
	Map<String, String> properties = new HashMap<>();
	properties.put("app.time.fixed-delay", "4");
	properties.put("app.log.level", "ERROR");
	properties.put("app.time.producer.partitionKeyExpression", "payload");
	mockMvc.perform(post("/streams/deployments/myStream").content(new ObjectMapper().writeValueAsBytes(properties))
			.contentType(MediaType.APPLICATION_JSON)).andExpect(status().isCreated());

	ArgumentCaptor<UploadRequest> uploadRequestCaptor = ArgumentCaptor.forClass(UploadRequest.class);
	verify(skipperClient, times(1)).upload(uploadRequestCaptor.capture());
	ArgumentCaptor<InstallRequest> installRequestCaptor = ArgumentCaptor.forClass(InstallRequest.class);
	verify(skipperClient, times(1)).install(installRequestCaptor.capture());

	List<UploadRequest> updateRequests = uploadRequestCaptor.getAllValues();
	assertEquals(1, updateRequests.size());

	Package pkg = SkipperPackageUtils.loadPackageFromBytes(uploadRequestCaptor);

	Package logPackage = findChildPackageByName(pkg, "log");
	assertNotNull(logPackage);
	Package timePackage = findChildPackageByName(pkg, "time");
	assertNotNull(timePackage);

	SpringCloudDeployerApplicationSpec logSpec = parseSpec(logPackage.getConfigValues().getRaw());
	assertEquals("ERROR", logSpec.getApplicationProperties().get("log.level"));
	assertEquals("true", logSpec.getDeploymentProperties().get(AppDeployer.INDEXED_PROPERTY_KEY));

	SpringCloudDeployerApplicationSpec timeSpec = parseSpec(timePackage.getConfigValues().getRaw());
	assertEquals("4", timeSpec.getApplicationProperties().get("trigger.fixed-delay"));
}
 
Example 20
Source Project: spring-cloud-cli   Source File: Deployer.java    License: Apache License 2.0 5 votes vote down vote up
public Deployer(AppDeployer deployer, ResourceLoader resourceLoader,
		DeployerProperties properties, ConfigurableEnvironment environment) {
	this.deployer = deployer;
	this.resourceLoader = resourceLoader;
	this.properties = properties;
	this.environment = environment;
}
 
Example 21
/**
 * Tests support for instance count support and individual instance status report.
 */
@Test
public void testMultipleInstancesDeploymentAndPartialState() {
	Map<String, String> appProperties = new HashMap<>();
	appProperties.put("matchInstances", "1"); // Only instance n°1 will kill itself
	appProperties.put("killDelay", "0");
	AppDefinition definition = new AppDefinition(randomName(), appProperties);
	Resource resource = testApplication();

	Map<String, String> deploymentProperties = new HashMap<>();
	deploymentProperties.put(AppDeployer.COUNT_PROPERTY_KEY, "3");
	deploymentProperties.put(AppDeployer.INDEXED_PROPERTY_KEY, "true");
	AppDeploymentRequest request = new AppDeploymentRequest(definition, resource, deploymentProperties);

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

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

	// Assert individual instance state
	// Note we can't rely on instances order, neither on their id indicating their ordinal number
	List<DeploymentState> individualStates = new ArrayList<>();
	for (AppInstanceStatus status : appDeployer().status(deploymentId).getInstances().values()) {
		individualStates.add(status.getState());
	}
	assertThat(individualStates, containsInAnyOrder(
			is(deployed),
			is(deployed),
			is(failed)
	));

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

	timeout = undeploymentTimeout();
	appDeployer().undeploy(deploymentId);
	assertThat(deploymentId, eventually(hasStatusThat(
			Matchers.<AppStatus>hasProperty("state", is(unknown))), timeout.maxAttempts, timeout.pause));
}
 
Example 22
@Override
public RuntimeEnvironmentInfo environmentInfo() {
	String apiVersion = "v1";
	String hostVersion = "unknown";
	return new RuntimeEnvironmentInfo.Builder()
			.spiClass(AppDeployer.class)
			.implementationName(this.getClass().getSimpleName())
			.implementationVersion(RuntimeVersionUtils.getVersion(this.getClass()))
			.platformType("Mesos")
			.platformApiVersion(apiVersion)
			.platformClientVersion(RuntimeVersionUtils.getVersion(chronos.getClass()))
			.platformHostVersion(hostVersion)
			.build();
}
 
Example 23
@Before
public void setupMocks() {
	this.mockMvc = MockMvcBuilders.webAppContextSetup(wac)
			.defaultRequest(get("/").accept(MediaType.APPLICATION_JSON)).build();

	streamStatusInfo = new Info();
	streamStatusInfo.setStatus(new Status());
	streamStatusInfo.getStatus().setStatusCode(StatusCode.UNKNOWN);
	when(skipperClient.status(anyString())).thenReturn(streamStatusInfo);

	Deployer deployer = new Deployer("default", "local", mock(AppDeployer.class));
	when(skipperClient.listDeployers()).thenReturn(Arrays.asList(deployer));

	when(skipperClient.search(anyString(), eq(false))).thenReturn(new ArrayList<PackageMetadata>());
}
 
Example 24
int memory(AppScaleRequest request) {
	if (request.getProperties().isPresent() && request.getProperties().get() != null) {
		return (int) ByteSizeUtils.parseToMebibytes(request.getProperties().get().getOrDefault(AppDeployer.MEMORY_PROPERTY_KEY,
				this.deploymentProperties.getMemory()));
	}
	return (int) ByteSizeUtils.parseToMebibytes(this.deploymentProperties.getMemory());
}
 
Example 25
int diskQuota(AppScaleRequest request) {
	if (request.getProperties().isPresent() && request.getProperties().get() != null) {
		return (int) ByteSizeUtils.parseToMebibytes(request.getProperties().get().getOrDefault(AppDeployer.DISK_PROPERTY_KEY,
				this.deploymentProperties.getDisk()));
	}
	return (int) ByteSizeUtils.parseToMebibytes(this.deploymentProperties.getDisk());
}
 
Example 26
@Bean
@ConditionalOnMissingBean(AppDeployer.class)
public AppDeployer appDeployer(CloudFoundryOperations operations,
	AppNameGenerator applicationNameGenerator) {
	return new CloudFoundryAppDeployer(
		applicationNameGenerator,
		connectionConfiguration.appDeploymentProperties(),
		operations,
		runtimeEnvironmentInfo(AppDeployer.class, CloudFoundryAppDeployer.class)
	);
}
 
Example 27
@Override
protected Map<String, String> getEnvironmentVariables(String deploymentId, AppDeploymentRequest request) {
	Map<String, String> envVariables = super.getEnvironmentVariables(deploymentId, request);
	envVariables.putAll(getCommandLineArguments(request));
	String group = request.getDeploymentProperties().get(AppDeployer.GROUP_PROPERTY_KEY);
	if (StringUtils.hasText(group)) {
		envVariables.put("SPRING_CLOUD_APPLICATION_GROUP", group);
	}
	envVariables.put("SPRING_CLOUD_APPLICATION_GUID", "${vcap.application.name}:${vcap.application.instance_index}");
	envVariables.put("SPRING_APPLICATION_INDEX", "${vcap.application.instance_index}");
	return envVariables;
}
 
Example 28
@Test
public void testDirectJavaMemoryOption() {
    deploymentProperties.put(AppDeployer.MEMORY_PROPERTY_KEY, "1024m");
    commandBuilder.addJavaOptions(args, deploymentProperties, localDeployerProperties);
    assertThat(args.size(), is(1));
    assertThat(args.get(0), is("-Xmx1024m"));
}
 
Example 29
@Test
public void testDirectJavaMemoryOptionWithG() {
    deploymentProperties.put(AppDeployer.MEMORY_PROPERTY_KEY, "1g");
    commandBuilder.addJavaOptions(args, deploymentProperties, localDeployerProperties);
    assertThat(args.size(), is(1));
    assertThat(args.get(0), is("-Xmx1024m"));
}
 
Example 30
@Test
public void testOverrideMemoryOptions() {
    deploymentProperties.put(AppDeployer.MEMORY_PROPERTY_KEY, "1024m");
    deploymentProperties.put(PREFIX + ".javaOpts", "-Xmx2048m");
    commandBuilder.addJavaOptions(args, deploymentProperties, localDeployerProperties);
    assertThat(args.size(), is(1));
    assertThat(args.get(0), is("-Xmx2048m"));
}