Пример #1
0
  @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();
  }
Пример #2
0
  @GET
  @Path("/{serverName}/segments/{segmentId}")
  @Produces(MediaType.APPLICATION_JSON)
  public Response getServerSegment(
      @PathParam("serverName") String serverName, @PathParam("segmentId") String segmentId) {
    DruidServer server = serverInventoryView.getInventoryValue(serverName);
    if (server == null) {
      return Response.status(Response.Status.NOT_FOUND).build();
    }

    DataSegment segment = server.getSegment(segmentId);
    if (segment == null) {
      return Response.status(Response.Status.NOT_FOUND).build();
    }

    return Response.status(Response.Status.OK).entity(segment).build();
  }
Пример #3
0
  @GET
  @Path("/{serverName}")
  @Produces(MediaType.APPLICATION_JSON)
  public Response getServer(
      @PathParam("serverName") String serverName, @QueryParam("simple") String simple) {
    DruidServer server = serverInventoryView.getInventoryValue(serverName);
    if (server == null) {
      return Response.status(Response.Status.NOT_FOUND).build();
    }

    Response.ResponseBuilder builder = Response.status(Response.Status.OK);

    if (simple != null) {
      return builder.entity(makeSimpleServer(server)).build();
    }

    return builder.entity(makeFullServer(server)).build();
  }