public static DeploymentStateResource fromKey(String deploymentStateResourceKey) { Assert.hasText(deploymentStateResourceKey, "Parameter deploymentStateResourceKey must not be null or empty."); for (DeploymentStateResource deploymentStateResource : DeploymentStateResource.values()) { if (deploymentStateResource.getKey().equals(deploymentStateResourceKey)) { return deploymentStateResource; } } return null; }
/** * Maps the {@link DeploymentState} from the Deployer SPI to a * {@link DeploymentStateResource} which is used by the REST API. * * @param state Must not be null * @return a DeploymentStateResource, never null */ public static DeploymentStateResource mapState(DeploymentState state) { DeploymentStateResource result = DeploymentStateResource.fromKey(state.name()); Assert.notNull(result, "Trying to display a DeploymentState that should not appear here: " + state); return result; } }
/** * Request deployment of an existing stream definition. * @param name the name of an existing stream definition (required) * @return The stream deployment */ @RequestMapping(value = "/{name}", method = RequestMethod.GET) @ResponseStatus(HttpStatus.CREATED) public StreamDeploymentResource info(@PathVariable("name") String name) { StreamDefinition streamDefinition = this.repository.findById(name) .orElseThrow(() -> new NoSuchStreamDefinitionException(name)); StreamDeployment streamDeployment = this.streamService.info(name); Map<StreamDefinition, DeploymentState> streamDeploymentStates = this.streamService.state(Arrays.asList(streamDefinition)); DeploymentState deploymentState = streamDeploymentStates.get(streamDefinition); String status = ""; if (deploymentState != null) { final DeploymentStateResource deploymentStateResource = ControllerUtils.mapState(deploymentState); status = deploymentStateResource.getKey(); } return new Assembler(streamDefinition.getDslText(), status).toResource(streamDeployment); }
@Override public StreamDefinitionResource instantiateResource(StreamDefinition stream) { final StreamDefinitionResource resource = new StreamDefinitionResource(stream.getName(), new ArgumentSanitizer().sanitizeStream(stream)); DeploymentState deploymentState = streamDeploymentStates.get(stream); if (deploymentState != null) { final DeploymentStateResource deploymentStateResource = ControllerUtils .mapState(deploymentState); resource.setStatus(deploymentStateResource.getKey()); resource.setStatusDescription(deploymentStateResource.getDescription()); } return resource; }
@Override protected AppStatusResource instantiateResource(AppStatus entity) { AppStatusResource resource = new AppStatusResource(entity.getDeploymentId(), ControllerUtils.mapState(entity.getState()).getKey()); List<AppInstanceStatusResource> instanceStatusResources = new ArrayList<>(); RuntimeAppInstanceController.InstanceAssembler instanceAssembler = new RuntimeAppInstanceController.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; } }
@Override public StreamDefinitionResource instantiateResource(StreamDefinition stream) { final StreamDefinitionResource resource = new StreamDefinitionResource(stream.getName(), new ArgumentSanitizer().sanitizeStream(stream)); DeploymentState deploymentState = streamDeploymentStates.get(stream); if (deploymentState != null) { final DeploymentStateResource deploymentStateResource = ControllerUtils .mapState(deploymentState); resource.setStatus(deploymentStateResource.getKey()); resource.setStatusDescription(deploymentStateResource.getDescription()); } return resource; }
@Override protected AppStatusResource instantiateResource(AppStatus entity) { AppStatusResource resource = new AppStatusResource(entity.getDeploymentId(), ControllerUtils.mapState(entity.getState()).getKey()); List<AppInstanceStatusResource> instanceStatusResources = new ArrayList<>(); RuntimeAppInstanceController.InstanceAssembler instanceAssembler = new RuntimeAppInstanceController.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; } }
public static DeploymentStateResource fromKey(String deploymentStateResourceKey) { Assert.hasText(deploymentStateResourceKey, "Parameter deploymentStateResourceKey must not be null or empty."); for (DeploymentStateResource deploymentStateResource : DeploymentStateResource.values()) { if (deploymentStateResource.getKey().equals(deploymentStateResourceKey)) { return deploymentStateResource; } } return null; }
/** * Maps the {@link DeploymentState} from the Deployer SPI to a * {@link DeploymentStateResource} which is used by the REST API. * * @param state Must not be null * @return a DeploymentStateResource, never null */ public static DeploymentStateResource mapState(DeploymentState state) { DeploymentStateResource result = DeploymentStateResource.fromKey(state.name()); Assert.notNull(result, "Trying to display a DeploymentState that should not appear here: " + state); return result; } }
/** * Request deployment of an existing stream definition. * @param name the name of an existing stream definition (required) * @return The stream deployment */ @RequestMapping(value = "/{name}", method = RequestMethod.GET) @ResponseStatus(HttpStatus.CREATED) public StreamDeploymentResource info(@PathVariable("name") String name) { StreamDefinition streamDefinition = this.repository.findOne(name); if (streamDefinition == null) { throw new NoSuchStreamDefinitionException(name); } StreamDeployment streamDeployment = this.streamService.info(name); Map<StreamDefinition, DeploymentState> streamDeploymentStates = this.streamService.state(Arrays.asList(streamDefinition)); DeploymentState deploymentState = streamDeploymentStates.get(streamDefinition); String status = ""; if (deploymentState != null) { final DeploymentStateResource deploymentStateResource = ControllerUtils.mapState(deploymentState); status = deploymentStateResource.getKey(); } return new Assembler(streamDefinition.getDslText(), status).toResource(streamDeployment); }
@Override protected AppInstanceStatusResource instantiateResource(AppInstanceStatus entity) { return new AppInstanceStatusResource(entity.getId(), ControllerUtils.mapState(entity.getState()).getKey(), entity.getAttributes()); } }
@Override protected AppInstanceStatusResource instantiateResource(AppInstanceStatus entity) { return new AppInstanceStatusResource(entity.getId(), ControllerUtils.mapState(entity.getState()).getKey(), entity.getAttributes()); } }