private Map<String, Integer> countNodeInstance(Topology topology) { return TopologyUtils.estimateWorkflowStepInstanceCount(topology); }
/** * Get the active deployment monitoring data. * * @param applicationId id of the topology * @return the active deployment */ @ApiOperation(value = "Get active deployment for the given application on the given cloud.", notes = "Application role required [ APPLICATION_MANAGER | APPLICATION_DEVOPS ] and Application environment role required [ DEPLOYMENT_MANAGER ]") @RequestMapping(value = "/{applicationId:.+}/environments/{applicationEnvironmentId}/active-deployment-monitored", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) @PreAuthorize("isAuthenticated()") public RestResponse<MonitoredDeploymentDTO> getActiveDeploymentMonitored(@PathVariable String applicationId, @PathVariable String applicationEnvironmentId) { Application application = applicationService.checkAndGetApplication(applicationId); // get the topology from the version and the cloud from the environment ApplicationEnvironment environment = applicationEnvironmentService.getEnvironmentByIdOrDefault(application.getId(), applicationEnvironmentId); AuthorizationUtil.checkAuthorizationForEnvironment(application, environment, ApplicationEnvironmentRole.APPLICATION_USER); Deployment deployment = deploymentService.getActiveDeployment(environment.getId()); ApplicationTopologyVersion topologyVersion = applicationVersionService .getOrFail(Csar.createId(environment.getApplicationId(), environment.getVersion()), environment.getTopologyVersion()); Topology topology = topologyServiceCore.getOrFail(topologyVersion.getArchiveId()); MonitoredDeploymentDTO monitoredDeploymentDTO = new MonitoredDeploymentDTO(); monitoredDeploymentDTO.setDeployment(deployment); Map<String, Integer> stepInstanceCount = toscaContextualAspect.execInToscaContext(() -> TopologyUtils.estimateWorkflowStepInstanceCount(topology), true, topology); monitoredDeploymentDTO.setWorkflowExpectedStepInstanceCount(stepInstanceCount); return RestResponseBuilder.<MonitoredDeploymentDTO> builder().data(monitoredDeploymentDTO).build(); }