@Path("/{appname}/list") @GET @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) public Response getApps(@PathParam("appname") String appname) throws Exception { logger.info("Getting nodes list for app: "+appname+", default Port used: "+ request.getServerPort()); try { return sendJson(clusterManager.getEndpoints(appname, request.getServerPort())); } catch (Exception e) { logger.error("Error getting Host list from ClusterManager for app: "+appname, e); return sendErrorResponse("get cluster host list failed!"); } }
@Path("/list") @GET @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) public Response getApps() throws Exception { logger.info("Getting cluster list"); try { return sendJson(clusterManager.getApps()); } catch (Exception e) { logger.error("Error getting Apps list from ClusterManager", e); return sendErrorResponse("get cluster/list failed!"); } } @Path("/{appname}/list")
@Path("/{appname}/list") @GET @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) public Response getApps(@PathParam("appname") String appname) throws Exception { logger.info("Getting nodes list for app: "+appname+", default Port used: "+ request.getServerPort()); try { return sendJson(clusterManager.getEndpoints(appname, request.getServerPort())); } catch (Exception e) { logger.error("Error getting Host list from ClusterManager for app: "+appname, e); return sendErrorResponse("get cluster host list failed!"); } }
@Path("/list") @GET @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) public Response getApps() throws Exception { logger.info("Getting cluster list"); try { return sendJson(clusterManager.getApps()); } catch (Exception e) { logger.error("Error getting Apps list from ClusterManager", e); return sendErrorResponse("get cluster/list failed!"); } } @Path("/{appname}/list")
private List<HttpHost> getEndpoints(IClusterDiscovery discoverer, IEsConfig config) { String hostname = config.getHostName(); List<HttpHost> retval; if (StringUtils.isNotBlank(hostname)) { retval = ImmutableList.of(new HttpHost(hostname, config.getRestClientPort(), getScheme())); } else { ArrayList<HttpHost> hosts = new ArrayList<>(); logger.debug("discovering endpoints of cluster: {}", config.getCluster()); for (String endpoint : discoverer.getEndpoints(config.getCluster(), config.getRestClientPort())) { String[] hostPort = endpoint.split(":"); hosts.add(new HttpHost(hostPort[0], Integer.parseInt(hostPort[1]), getScheme())); } if (hosts.isEmpty()) { throw new IllegalArgumentException( "failed to discover any endpoints of cluster: " + config.getCluster() + ". Are you sure it is valid? Maybe check Spinnaker?"); } retval = hosts; } return retval; } }