Ejemplo n.º 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();
  }
Ejemplo n.º 2
0
  @GET
  @Produces(MediaType.APPLICATION_JSON)
  public Response getClusterServers(
      @QueryParam("full") String full, @QueryParam("simple") String simple) {
    Response.ResponseBuilder builder = Response.status(Response.Status.OK);

    if (full != null) {
      return builder
          .entity(
              Lists.newArrayList(
                  Iterables.transform(
                      serverInventoryView.getInventory(),
                      new Function<DruidServer, Map<String, Object>>() {
                        @Override
                        public Map<String, Object> apply(DruidServer input) {
                          return makeFullServer(input);
                        }
                      })))
          .build();
    } else if (simple != null) {
      return builder
          .entity(
              Lists.newArrayList(
                  Iterables.transform(
                      serverInventoryView.getInventory(),
                      new Function<DruidServer, Map<String, Object>>() {
                        @Override
                        public Map<String, Object> apply(DruidServer input) {
                          return makeSimpleServer(input);
                        }
                      })))
          .build();
    }

    return builder
        .entity(
            Lists.newArrayList(
                Iterables.transform(
                    serverInventoryView.getInventory(),
                    new Function<DruidServer, String>() {
                      @Override
                      public String apply(DruidServer druidServer) {
                        return druidServer.getHost();
                      }
                    })))
        .build();
  }
Ejemplo n.º 3
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();
  }
Ejemplo n.º 4
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();
  }