コード例 #1
0
  @RequestMapping(method = RequestMethod.GET)
  public HttpEntity<Resources<AutoscaledAppResource>> getAutoscaledApps() throws Exception {

    List<String> autoscaledAppNames =
        autoscalingManager.getAppNames().get(10, TimeUnit.MILLISECONDS);
    List<AutoscaledAppResource> result =
        new ArrayList<AutoscaledAppResource>(autoscaledAppNames.size());
    Collection<Link> links = new ArrayList<Link>();
    links.add(linkTo(AutoscaledAppController.class).withSelfRel());

    for (String appName : autoscaledAppNames) {
      AutoscaledAppResource ar = new AutoscaledAppResource(appName);
      ar.add(linkTo(AutoscaledAppController.class).slash(appName).withSelfRel());
      ar.add(linkTo(AutoscaledAppController.class).slash(appName).slash("rules").withRel("rules"));
      links.add(linkTo(AutoscaledAppController.class).slash(appName).withRel("autoscaledApp"));
      result.add(ar);
    }
    return new HttpEntity<Resources<AutoscaledAppResource>>(
        new Resources<AutoscaledAppResource>(result, links));
  }
コード例 #2
0
 @RequestMapping(value = "/{appName}", method = RequestMethod.GET)
 public HttpEntity<AutoscaledAppResource> get(@PathVariable String appName)
     throws InterruptedException, ExecutionException {
   AppInfo app = autoscalingManager.getApp(appName).get();
   AutoscaledAppResource ar = new AutoscaledAppResource(appName);
   ar.setMetrics(app.getMetrics());
   ar.setInstanceCount(app.getInstanceCount());
   ar.setScalingEvents(app.getScalingEvents());
   ar.setActiveAlarms(app.getActiveAlarms());
   ar.add(linkTo(AutoscaledAppController.class).slash(appName).withSelfRel());
   ar.add(linkTo(AutoscaledAppController.class).slash(appName).slash("rules").withRel("rules"));
   return new HttpEntity<AutoscaledAppResource>(ar);
 }