本文整理汇总了Java中org.springframework.cloud.deployer.spi.app.AppInstanceStatus类的典型用法代码示例。如果您正苦于以下问题:Java AppInstanceStatus类的具体用法?Java AppInstanceStatus怎么用?Java AppInstanceStatus使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AppInstanceStatus类属于org.springframework.cloud.deployer.spi.app包,在下文中一共展示了AppInstanceStatus类的17个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: getPlatformStatusPrettyPrint
import org.springframework.cloud.deployer.spi.app.AppInstanceStatus; //导入依赖的package包/类
@JsonIgnore
public String getPlatformStatusPrettyPrint() {
List<AppStatus> appStatusList = getAppStatusList();
StringBuffer statusMsg = new StringBuffer();
for (AppStatus appStatus : appStatusList) {
statusMsg.append("[" + appStatus.getDeploymentId() + "]");
if (appStatus.getInstances().isEmpty()) {
statusMsg.append(", State = [" + appStatus.getState() + "]");
}
else {
statusMsg.append(", State = [");
for (AppInstanceStatus appInstanceStatus : appStatus.getInstances().values()) {
statusMsg.append(appInstanceStatus.getId() + "=" + appInstanceStatus.getState() + "\n");
}
statusMsg.setLength(statusMsg.length() - 1);
statusMsg.append("]\n");
}
}
return statusMsg.toString();
}
开发者ID:spring-cloud,项目名称:spring-cloud-skipper,代码行数:22,代码来源:Status.java
示例2: getAppStatusList
import org.springframework.cloud.deployer.spi.app.AppInstanceStatus; //导入依赖的package包/类
@JsonIgnore
public List<AppStatus> getAppStatusList() {
try {
ObjectMapper mapper = new ObjectMapper();
mapper.addMixIn(AppStatus.class, AppStatusMixin.class);
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
SimpleModule module = new SimpleModule("CustomModel", Version.unknownVersion());
SimpleAbstractTypeResolver resolver = new SimpleAbstractTypeResolver();
resolver.addMapping(AppInstanceStatus.class, AppInstanceStatusImpl.class);
module.setAbstractTypes(resolver);
mapper.registerModule(module);
TypeReference<List<AppStatus>> typeRef = new TypeReference<List<AppStatus>>() {
};
if (this.platformStatus != null) {
return mapper.readValue(this.platformStatus, typeRef);
}
return new ArrayList<AppStatus>();
}
catch (Exception e) {
throw new IllegalArgumentException("Could not parse Skipper Platfrom Status JSON:" + platformStatus, e);
}
}
开发者ID:spring-cloud,项目名称:spring-cloud-skipper,代码行数:23,代码来源:Status.java
示例3: buildInstanceStatus
import org.springframework.cloud.deployer.spi.app.AppInstanceStatus; //导入依赖的package包/类
private AppInstanceStatus buildInstanceStatus(String id) throws MarathonException {
App appInstance = marathon.getApp(id).getApp();
logger.debug("Deployment " + id + " has " + appInstance.getTasksRunning() + "/" + appInstance.getInstances() + " tasks running");
if (appInstance.getTasks() != null) {
// there should only be one task for this type of deployment
MarathonAppInstanceStatus status = null;
for (Task task : appInstance.getTasks()) {
if (status == null) {
status = MarathonAppInstanceStatus.up(appInstance, task);
}
}
if (status == null) {
status = MarathonAppInstanceStatus.down(appInstance);
}
return status;
}
else {
return MarathonAppInstanceStatus.down(appInstance);
}
}
开发者ID:spring-cloud,项目名称:spring-cloud-deployer-mesos,代码行数:21,代码来源:MarathonAppDeployer.java
示例4: deserializeAppStatus
import org.springframework.cloud.deployer.spi.app.AppInstanceStatus; //导入依赖的package包/类
public static List<AppStatus> deserializeAppStatus(String platformStatus) {
try {
ObjectMapper mapper = new ObjectMapper();
mapper.addMixIn(AppStatus.class, AppStatusMixin.class);
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
SimpleModule module = new SimpleModule("CustomModel", Version.unknownVersion());
SimpleAbstractTypeResolver resolver = new SimpleAbstractTypeResolver();
resolver.addMapping(AppInstanceStatus.class, AppInstanceStatusImpl.class);
module.setAbstractTypes(resolver);
mapper.registerModule(module);
TypeReference<List<AppStatus>> typeRef = new TypeReference<List<AppStatus>>() {
};
List<AppStatus> result = mapper.readValue(platformStatus, typeRef);
return result;
}
catch (Exception e) {
throw new IllegalArgumentException("Could not parse Skipper Platform Status JSON:" + platformStatus, e);
}
}
开发者ID:spring-cloud,项目名称:spring-cloud-dataflow,代码行数:20,代码来源:SkipperStreamDeployer.java
示例5: testDuplicateDeploy
import org.springframework.cloud.deployer.spi.app.AppInstanceStatus; //导入依赖的package包/类
@Test
public void testDuplicateDeploy() throws Exception {
repository.save(new StreamDefinition("myStream", "time | log"));
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());
when(appDeployer.status("testID")).thenReturn(AppStatus.of("testID").with(new AppInstanceStatus() {
@Override
public String getId() {
return "testID";
}
@Override
public DeploymentState getState() {
return DeploymentState.valueOf("deployed");
}
@Override
public Map<String, String> getAttributes() {
return null;
}
}).build());
mockMvc.perform(post("/streams/deployments/myStream").accept(MediaType.APPLICATION_JSON)).andDo(print())
.andExpect(status().isConflict());
}
开发者ID:spring-cloud,项目名称:spring-cloud-dataflow,代码行数:27,代码来源:StreamControllerTests.java
示例6: testDuplicateDeployWhenStreamIsBeingDeployed
import org.springframework.cloud.deployer.spi.app.AppInstanceStatus; //导入依赖的package包/类
@Test
public void testDuplicateDeployWhenStreamIsBeingDeployed() throws Exception {
repository.save(new StreamDefinition("myStream", "time | log"));
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());
when(appDeployer.status("testID")).thenReturn(AppStatus.of("testID").with(new AppInstanceStatus() {
@Override
public String getId() {
return "testID";
}
@Override
public DeploymentState getState() {
return DeploymentState.valueOf("deploying");
}
@Override
public Map<String, String> getAttributes() {
return null;
}
}).build());
mockMvc.perform(post("/streams/deployments/myStream").accept(MediaType.APPLICATION_JSON)).andDo(print())
.andExpect(status().isConflict());
}
开发者ID:spring-cloud,项目名称:spring-cloud-dataflow,代码行数:27,代码来源:StreamControllerTests.java
示例7: instantiateResource
import org.springframework.cloud.deployer.spi.app.AppInstanceStatus; //导入依赖的package包/类
@Override
protected AppStatusResource instantiateResource(AppStatus entity) {
AppStatusResource resource = new AppStatusResource(entity.getDeploymentId(), entity.getState().name());
List<AppInstanceStatusResource> instanceStatusResources = new ArrayList<>();
InstanceAssembler instanceAssembler = new InstanceAssembler(entity);
List<AppInstanceStatus> instanceStatuses = new ArrayList<>(entity.getInstances().values());
Collections.sort(instanceStatuses, INSTANCE_SORTER);
for (AppInstanceStatus appInstanceStatus : instanceStatuses) {
instanceStatusResources.add(instanceAssembler.toResource(appInstanceStatus));
}
resource.setInstances(new Resources<>(instanceStatusResources));
return resource;
}
开发者ID:spring-cloud,项目名称:spring-cloud-dashboard,代码行数:14,代码来源:RuntimeAppsController.java
示例8: list
import org.springframework.cloud.deployer.spi.app.AppInstanceStatus; //导入依赖的package包/类
@RequestMapping
public PagedResources<AppInstanceStatusResource> list(@PathVariable String appId,
PagedResourcesAssembler<AppInstanceStatus> assembler) {
AppStatus status = appDeployer.status(appId);
if (status != null) {
List<AppInstanceStatus> appInstanceStatuses = new ArrayList<>(status.getInstances().values());
Collections.sort(appInstanceStatuses, INSTANCE_SORTER);
return assembler.toResource(new PageImpl<>(appInstanceStatuses), new InstanceAssembler(status));
}
throw new ResourceNotFoundException();
}
开发者ID:spring-cloud,项目名称:spring-cloud-dashboard,代码行数:12,代码来源:RuntimeAppsController.java
示例9: display
import org.springframework.cloud.deployer.spi.app.AppInstanceStatus; //导入依赖的package包/类
@RequestMapping("/{instanceId}")
public AppInstanceStatusResource display(@PathVariable String appId, @PathVariable String instanceId) {
AppStatus status = appDeployer.status(appId);
if (status != null) {
AppInstanceStatus appInstanceStatus = status.getInstances().get(instanceId);
if (appInstanceStatus == null) {
throw new ResourceNotFoundException();
}
return new InstanceAssembler(status).toResource(appInstanceStatus);
}
throw new ResourceNotFoundException();
}
开发者ID:spring-cloud,项目名称:spring-cloud-dashboard,代码行数:13,代码来源:RuntimeAppsController.java
示例10: testMultipleInstancesDeploymentAndPartialState
import org.springframework.cloud.deployer.spi.app.AppInstanceStatus; //导入依赖的package包/类
/**
* 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));
}
开发者ID:spring-cloud,项目名称:spring-cloud-deployer,代码行数:43,代码来源:AbstractAppDeployerIntegrationTests.java
示例11: enrichWithMetrics
import org.springframework.cloud.deployer.spi.app.AppInstanceStatus; //导入依赖的package包/类
private void enrichWithMetrics(List<AppStatus> statuses) {
List<ApplicationsMetrics> metricsIn = metricStore.getMetrics();
Map<String, ApplicationsMetrics.Instance> metricsInstanceMap = new HashMap<>();
for (ApplicationsMetrics am : metricsIn) {
for (ApplicationsMetrics.Application a : am.getApplications()) {
for (ApplicationsMetrics.Instance i : a.getInstances()) {
metricsInstanceMap.put(i.getGuid(), i);
}
}
}
for (AppStatus appStatus : statuses) {
Map<String, AppInstanceStatus> appInstanceStatusMap = appStatus.getInstances();
appInstanceStatusMap.forEach((k, appInstanceStatus) -> {
Map<String, String> attributes = appInstanceStatus.getAttributes();
if (attributes != null && !attributes.isEmpty()) {
String trackingKey = attributes.get("guid");
if (metricsInstanceMap.containsKey(trackingKey)) {
ApplicationsMetrics.Instance metricsAppInstance = metricsInstanceMap.get(trackingKey);
List<ApplicationsMetrics.Metric> metrics = metricsAppInstance.getMetrics();
if (metrics != null) {
for (ApplicationsMetrics.Metric m : metrics) {
if (ObjectUtils.nullSafeEquals("integration.channel.input.send.mean", m.getName())) {
appInstanceStatus.getAttributes()
.put("metrics.integration.channel.input.receiveRate",
String.format(Locale.US, "%.2f", m.getValue()));
}
else if (ObjectUtils
.nullSafeEquals("integration.channel.output.send.mean", m.getName())) {
appInstanceStatus.getAttributes().put("metrics.integration.channel.output.sendRate",
String.format(Locale.US, "%.2f", m.getValue()));
}
}
}
}
}
});
}
}
开发者ID:spring-cloud,项目名称:spring-cloud-dataflow,代码行数:40,代码来源:RuntimeAppsController.java
示例12: instantiateResource
import org.springframework.cloud.deployer.spi.app.AppInstanceStatus; //导入依赖的package包/类
@Override
protected AppStatusResource instantiateResource(AppStatus entity) {
AppStatusResource resource = new AppStatusResource(entity.getDeploymentId(),
ControllerUtils.mapState(entity.getState()).getKey());
List<AppInstanceStatusResource> instanceStatusResources = new ArrayList<>();
InstanceAssembler instanceAssembler = new InstanceAssembler(entity);
List<AppInstanceStatus> instanceStatuses = new ArrayList<>(entity.getInstances().values());
Collections.sort(instanceStatuses, INSTANCE_SORTER);
for (AppInstanceStatus appInstanceStatus : instanceStatuses) {
instanceStatusResources.add(instanceAssembler.toResource(appInstanceStatus));
}
resource.setInstances(new Resources<>(instanceStatusResources));
return resource;
}
开发者ID:spring-cloud,项目名称:spring-cloud-dataflow,代码行数:15,代码来源:RuntimeAppsController.java
示例13: list
import org.springframework.cloud.deployer.spi.app.AppInstanceStatus; //导入依赖的package包/类
@RequestMapping
public PagedResources<AppInstanceStatusResource> list(Pageable pageable, @PathVariable String appId,
PagedResourcesAssembler<AppInstanceStatus> assembler) {
AppStatus status = streamDeployer.getAppStatus(appId);
if (status.getState().equals(DeploymentState.unknown)) {
throw new NoSuchAppException(appId);
}
List<AppInstanceStatus> appInstanceStatuses = new ArrayList<>(status.getInstances().values());
Collections.sort(appInstanceStatuses, INSTANCE_SORTER);
return assembler.toResource(new PageImpl<>(appInstanceStatuses, pageable,
appInstanceStatuses.size()), new InstanceAssembler(status));
}
开发者ID:spring-cloud,项目名称:spring-cloud-dataflow,代码行数:13,代码来源:RuntimeAppsController.java
示例14: display
import org.springframework.cloud.deployer.spi.app.AppInstanceStatus; //导入依赖的package包/类
@RequestMapping("/{instanceId}")
public AppInstanceStatusResource display(@PathVariable String appId, @PathVariable String instanceId) {
AppStatus status = streamDeployer.getAppStatus(appId);
if (status.getState().equals(DeploymentState.unknown)) {
throw new NoSuchAppException(appId);
}
AppInstanceStatus appInstanceStatus = status.getInstances().get(instanceId);
if (appInstanceStatus == null) {
throw new NoSuchAppInstanceException(instanceId);
}
return new InstanceAssembler(status).toResource(appInstanceStatus);
}
开发者ID:spring-cloud,项目名称:spring-cloud-dataflow,代码行数:13,代码来源:RuntimeAppsController.java
示例15: compare
import org.springframework.cloud.deployer.spi.app.AppInstanceStatus; //导入依赖的package包/类
@Override
public int compare(AppInstanceStatus i1, AppInstanceStatus i2) {
return i1.getId().compareTo(i2.getId());
}
开发者ID:spring-cloud,项目名称:spring-cloud-dashboard,代码行数:5,代码来源:RuntimeAppsController.java
示例16: toResource
import org.springframework.cloud.deployer.spi.app.AppInstanceStatus; //导入依赖的package包/类
@Override
public AppInstanceStatusResource toResource(AppInstanceStatus entity) {
return createResourceWithId("/" + entity.getId(), entity, owningApp.getDeploymentId().toString());
}
开发者ID:spring-cloud,项目名称:spring-cloud-dashboard,代码行数:5,代码来源:RuntimeAppsController.java
示例17: toResource
import org.springframework.cloud.deployer.spi.app.AppInstanceStatus; //导入依赖的package包/类
@Override
public AppInstanceStatusResource toResource(AppInstanceStatus entity) {
return createResourceWithId("/" + entity.getId(), entity, owningApp.getDeploymentId());
}
开发者ID:spring-cloud,项目名称:spring-cloud-dataflow,代码行数:5,代码来源:RuntimeAppsController.java
注:本文中的org.springframework.cloud.deployer.spi.app.AppInstanceStatus类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论