@GET @Path("/{serverName}/segments") @Produces(MediaType.APPLICATION_JSON) public Response getServerSegments( @PathParam("serverName") String serverName, @QueryParam("full") String full) { Response.ResponseBuilder builder = Response.status(Response.Status.OK); DruidServer server = serverInventoryView.getInventoryValue(serverName); if (server == null) { return Response.status(Response.Status.NOT_FOUND).build(); } if (full != null) { return builder.entity(server.getSegments().values()).build(); } return builder .entity( Collections2.transform( server.getSegments().values(), new Function<DataSegment, String>() { @Override public String apply(DataSegment segment) { return segment.getIdentifier(); } })) .build(); }
private static Map<String, Object> makeFullServer(DruidServer input) { return new ImmutableMap.Builder<String, Object>() .put("host", input.getHost()) .put("maxSize", input.getMaxSize()) .put("type", input.getType()) .put("tier", input.getTier()) .put("priority", input.getPriority()) .put("segments", input.getSegments()) .put("currSize", input.getCurrSize()) .build(); }