Exemple #1
0
 /**
  * Displays the aggregate utilization for the entire cluster.
  *
  * @return HTML-formatted cluster utilization.
  */
 @GET
 @Produces(MediaType.TEXT_HTML)
 public Response aggregateCluster() {
   Iterable<DisplayMetric> metrics =
       FluentIterable.from(counter.computeConsumptionTotals()).transform(TO_DISPLAY).toList();
   return Response.ok(fillTemplate(metrics)).build();
 }
Exemple #2
0
  /**
   * Displays the aggregate utilization for jobs within a role.
   *
   * @param metric Metric id.
   * @param role Role for jobs to aggregate.
   * @return HTML-formatted utilization within the metric/role.
   */
  @GET
  @Path("/{metric}/{role}")
  @Produces(MediaType.TEXT_HTML)
  public Response aggregateJobs(
      @PathParam("metric") String metric, @PathParam("role") String role) {

    MetricType type = getTypeByName(metric);
    Function<ITaskConfig, Display> toKey =
        new Function<ITaskConfig, Display>() {
          @Override
          public Display apply(ITaskConfig task) {
            return new Display(task.getJobName(), null);
          }
        };
    Map<Display, Metric> byJob =
        counter.computeAggregates(Query.roleScoped(role).active(), type.filter, toKey);
    return Response.ok(fillTemplate(byJob)).build();
  }
Exemple #3
0
  /**
   * Displays the aggregate utilization for roles within a metric type.
   *
   * @param metric Metric id.
   * @return HTML-formatted utilization within the metric type.
   */
  @GET
  @Path("/{metric}")
  @Produces(MediaType.TEXT_HTML)
  public Response aggregateRoles(@PathParam("metric") final String metric) {
    final MetricType type = getTypeByName(metric);

    Function<ITaskConfig, Display> toKey =
        new Function<ITaskConfig, Display>() {
          @Override
          public Display apply(ITaskConfig task) {
            String role = task.getJob().getRole();
            return new Display(role, metric + "/" + role);
          }
        };
    Map<Display, Metric> byRole =
        counter.computeAggregates(Query.unscoped().active(), type.filter, toKey);
    return Response.ok(fillTemplate(byRole)).build();
  }