private static Collection<ServiceCluster> filter(Set<ServiceCluster> controllerClusters, ClusterId contentClusterId) { ClusterId clusterControllerClusterId = new ClusterId(contentClusterId.s() + "-controllers"); return controllerClusters.stream(). filter(cluster -> cluster.clusterId().equals(clusterControllerClusterId)). collect(Collectors.toList()); }
@GET @Path("/{instanceId}/serviceStatusInfo") @Produces(MediaType.APPLICATION_JSON) public ServiceStatusInfo getServiceStatus( @PathParam("instanceId") String instanceId, @QueryParam("clusterId") String clusterIdString, @QueryParam("serviceType") String serviceTypeString, @QueryParam("configId") String configIdString) { ApplicationInstanceReference reference = parseInstanceId(instanceId); ApplicationId applicationId = OrchestratorUtil.toApplicationId(reference); if (clusterIdString == null) { throwBadRequest("Missing clusterId query parameter"); } if (serviceTypeString == null) { throwBadRequest("Missing serviceType query parameter"); } if (configIdString == null) { throwBadRequest("Missing configId query parameter"); } ClusterId clusterId = new ClusterId(clusterIdString); ServiceType serviceType = new ServiceType(serviceTypeString); ConfigId configId = new ConfigId(configIdString); return rootManager.getStatus(applicationId, clusterId, serviceType, configId); }
@Override public Map<ApplicationInstanceReference, ApplicationInstance> getAllApplicationInstances() { // Convert apps information to the response payload to return Map<ApplicationInstanceReference, ApplicationInstance> status = new HashMap<>(); for (Map.Entry<ApplicationId, MockDeployer.ApplicationContext> app : apps.entrySet()) { Set<ServiceInstance> serviceInstances = new HashSet<>(); for (Node node : nodeRepository.getNodes(app.getValue().id(), Node.State.active)) { serviceInstances.add(new ServiceInstance(new ConfigId("configid"), new HostName(node.hostname()), getHostStatus(node.hostname()))); } Set<ServiceCluster> serviceClusters = new HashSet<>(); serviceClusters.add(new ServiceCluster(new ClusterId(app.getValue().clusterContexts().get(0).cluster().id().value()), new ServiceType("serviceType"), serviceInstances)); TenantId tenantId = new TenantId(app.getKey().tenant().value()); ApplicationInstanceId applicationInstanceId = new ApplicationInstanceId(app.getKey().application().value()); status.put(new ApplicationInstanceReference(tenantId, applicationInstanceId), new ApplicationInstance(tenantId, applicationInstanceId, serviceClusters)); } return status; }