本文整理汇总了Java中org.springframework.cloud.deployer.spi.app.AppDeployer类的典型用法代码示例。如果您正苦于以下问题:Java AppDeployer类的具体用法?Java AppDeployer怎么用?Java AppDeployer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AppDeployer类属于org.springframework.cloud.deployer.spi.app包,在下文中一共展示了AppDeployer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: deploy
import org.springframework.cloud.deployer.spi.app.AppDeployer; //导入依赖的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: isHealthy
import org.springframework.cloud.deployer.spi.app.AppDeployer; //导入依赖的package包/类
public boolean isHealthy(Release replacingRelease) {
AppDeployerData replacingAppDeployerData = this.appDeployerDataRepository
.findByReleaseNameAndReleaseVersionRequired(
replacingRelease.getName(), replacingRelease.getVersion());
Map<String, String> appNamesAndDeploymentIds = replacingAppDeployerData.getDeploymentDataAsMap();
AppDeployer appDeployer = this.deployerRepository
.findByNameRequired(replacingRelease.getPlatformName())
.getAppDeployer();
logger.debug("Getting status for apps in replacing release {}-v{}", replacingRelease.getName(),
replacingRelease.getVersion());
for (Map.Entry<String, String> appNameAndDeploymentId : appNamesAndDeploymentIds.entrySet()) {
AppStatus status = appDeployer.status(appNameAndDeploymentId.getValue());
if (status.getState() == DeploymentState.deployed) {
return true;
}
}
return false;
}
示例3: delete
import org.springframework.cloud.deployer.spi.app.AppDeployer; //导入依赖的package包/类
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.getDeploymentIds();
if (!deploymentIds.isEmpty()) {
for (String deploymentId : deploymentIds) {
appDeployer.undeploy(deploymentId);
}
Status deletedStatus = new Status();
deletedStatus.setStatusCode(StatusCode.DELETED);
release.getInfo().setStatus(deletedStatus);
release.getInfo().setDescription("Delete complete");
this.releaseRepository.save(release);
}
return release;
}
示例4: ApplicationDeploymentController
import org.springframework.cloud.deployer.spi.app.AppDeployer; //导入依赖的package包/类
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;
}
示例5: environmentInfo
import org.springframework.cloud.deployer.spi.app.AppDeployer; //导入依赖的package包/类
@Override
public RuntimeEnvironmentInfo environmentInfo() {
String apiVersion = "v1";
String hostVersion = "unknown";
String frameworkId = "unknown";
String leader = "unknown";
try {
GetServerInfoResponse serverInfo = marathon.getServerInfo();
hostVersion = serverInfo.getVersion();
frameworkId = serverInfo.getFrameworkId();
leader = serverInfo.getLeader();
} catch (MarathonException ignore) {}
return new RuntimeEnvironmentInfo.Builder()
.spiClass(AppDeployer.class)
.implementationName(this.getClass().getSimpleName())
.implementationVersion(RuntimeVersionUtils.getVersion(this.getClass()))
.platformType("Mesos")
.platformApiVersion(apiVersion)
.platformClientVersion(RuntimeVersionUtils.getVersion(marathon.getClass()))
.platformHostVersion(hostVersion)
.addPlatformSpecificInfo("leader", leader)
.addPlatformSpecificInfo("frameworkId", frameworkId)
.build();
}
示例6: deploy
import org.springframework.cloud.deployer.spi.app.AppDeployer; //导入依赖的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;
}
示例7: testStreamWithShortformProperties
import org.springframework.cloud.deployer.spi.app.AppDeployer; //导入依赖的package包/类
@Test
public void testStreamWithShortformProperties() throws Exception {
repository.save(new StreamDefinition("myStream", "time --fixed-delay=2 | log --level=WARN"));
mockMvc.perform(post("/streams/deployments/myStream").accept(MediaType.APPLICATION_JSON)).andDo(print())
.andExpect(status().isCreated());
ArgumentCaptor<AppDeploymentRequest> captor = ArgumentCaptor.forClass(AppDeploymentRequest.class);
verify(appDeployer, times(2)).deploy(captor.capture());
List<AppDeploymentRequest> requests = captor.getAllValues();
assertEquals(2, requests.size());
AppDeploymentRequest logRequest = requests.get(0);
assertThat(logRequest.getDefinition().getName(), is("log"));
Map<String, String> logAppProps = logRequest.getDefinition().getProperties();
assertEquals("WARN", logAppProps.get("log.level"));
assertEquals("true", logRequest.getDeploymentProperties().get(AppDeployer.INDEXED_PROPERTY_KEY));
assertNull(logAppProps.get("level"));
AppDeploymentRequest timeRequest = requests.get(1);
assertThat(timeRequest.getDefinition().getName(), is("time"));
Map<String, String> timeAppProps = timeRequest.getDefinition().getProperties();
assertEquals("2", timeAppProps.get("trigger.fixed-delay"));
assertNull(timeAppProps.get("fixed-delay"));
}
示例8: testDeployWithAppPropertiesOverride
import org.springframework.cloud.deployer.spi.app.AppDeployer; //导入依赖的package包/类
@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");
mockMvc.perform(post("/streams/deployments/myStream").content(new ObjectMapper().writeValueAsBytes(properties))
.contentType(MediaType.APPLICATION_JSON)).andExpect(status().isCreated());
ArgumentCaptor<AppDeploymentRequest> captor = ArgumentCaptor.forClass(AppDeploymentRequest.class);
verify(appDeployer, times(2)).deploy(captor.capture());
List<AppDeploymentRequest> requests = captor.getAllValues();
assertEquals(2, requests.size());
AppDeploymentRequest logRequest = requests.get(0);
assertThat(logRequest.getDefinition().getName(), is("log"));
Map<String, String> logAppProps = logRequest.getDefinition().getProperties();
assertEquals("true", logRequest.getDeploymentProperties().get(AppDeployer.INDEXED_PROPERTY_KEY));
assertEquals("ERROR", logAppProps.get("log.level"));
AppDeploymentRequest timeRequest = requests.get(1);
assertThat(timeRequest.getDefinition().getName(), is("time"));
Map<String, String> timeAppProps = timeRequest.getDefinition().getProperties();
assertEquals("4", timeAppProps.get("trigger.fixed-delay"));
}
示例9: testDeployWithAppPropertiesOverrideWithLabel
import org.springframework.cloud.deployer.spi.app.AppDeployer; //导入依赖的package包/类
@Test
public void testDeployWithAppPropertiesOverrideWithLabel() throws Exception {
repository.save(new StreamDefinition("myStream", "a: time --fixed-delay=2 | b: log --level=WARN"));
Map<String, String> properties = new HashMap<>();
properties.put("app.a.fixed-delay", "4");
properties.put("app.b.level", "ERROR");
mockMvc.perform(post("/streams/deployments/myStream").content(new ObjectMapper().writeValueAsBytes(properties))
.contentType(MediaType.APPLICATION_JSON)).andExpect(status().isCreated());
ArgumentCaptor<AppDeploymentRequest> captor = ArgumentCaptor.forClass(AppDeploymentRequest.class);
verify(appDeployer, times(2)).deploy(captor.capture());
List<AppDeploymentRequest> requests = captor.getAllValues();
assertEquals(2, requests.size());
AppDeploymentRequest logRequest = requests.get(0);
assertThat(logRequest.getDefinition().getName(), is("b"));
assertEquals("true", logRequest.getDeploymentProperties().get(AppDeployer.INDEXED_PROPERTY_KEY));
Map<String, String> logAppProps = logRequest.getDefinition().getProperties();
assertEquals("ERROR", logAppProps.get("log.level"));
AppDeploymentRequest timeRequest = requests.get(1);
assertThat(timeRequest.getDefinition().getName(), is("a"));
Map<String, String> timeAppProps = timeRequest.getDefinition().getProperties();
assertEquals("4", timeAppProps.get("trigger.fixed-delay"));
}
示例10: createAppDeploymentRequest
import org.springframework.cloud.deployer.spi.app.AppDeployer; //导入依赖的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;
}
示例11: delete
import org.springframework.cloud.deployer.spi.app.AppDeployer; //导入依赖的package包/类
public Release delete(Release release, AppDeployerData existingAppDeployerData,
List<String> applicationNamesToDelete) {
AppDeployer appDeployer = this.deployerRepository.findByNameRequired(release.getPlatformName())
.getAppDeployer();
Map<String, String> appNamesAndDeploymentIds = existingAppDeployerData.getDeploymentDataAsMap();
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;
}
示例12: deployApplication
import org.springframework.cloud.deployer.spi.app.AppDeployer; //导入依赖的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);
}
}
示例13: RuntimeAppsController
import org.springframework.cloud.deployer.spi.app.AppDeployer; //导入依赖的package包/类
/**
* 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;
}
示例14: ApplicationDefinitionController
import org.springframework.cloud.deployer.spi.app.AppDeployer; //导入依赖的package包/类
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;
}
示例15: applicationDefinitionController
import org.springframework.cloud.deployer.spi.app.AppDeployer; //导入依赖的package包/类
@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);
}