Example #1
0
  @Get("json")
  public Collection<LBPool> retrieve() {
    ILoadBalancerService lbs =
        (ILoadBalancerService)
            getContext().getAttributes().get(ILoadBalancerService.class.getCanonicalName());

    String poolId = (String) getRequestAttributes().get("pool");
    if (poolId != null) return lbs.listPool(poolId);
    else return lbs.listPools();
  }
  @Get("json")
  public Collection<LBMonitor> retrieve() {
    ILoadBalancerService lbs =
        (ILoadBalancerService)
            getContext().getAttributes().get(ILoadBalancerService.class.getCanonicalName());

    String monitorId = (String) getRequestAttributes().get("monitor");
    if (monitorId != null) return lbs.listMonitor(monitorId);
    else return lbs.listMonitors();
  }
Example #3
0
  @Delete
  public int removePool() {

    String poolId = (String) getRequestAttributes().get("pool");

    ILoadBalancerService lbs =
        (ILoadBalancerService)
            getContext().getAttributes().get(ILoadBalancerService.class.getCanonicalName());

    return lbs.removePool(poolId);
  }
  @Delete
  public int removeMonitor() {

    String monitorId = (String) getRequestAttributes().get("monitor");

    ILoadBalancerService lbs =
        (ILoadBalancerService)
            getContext().getAttributes().get(ILoadBalancerService.class.getCanonicalName());

    return lbs.removeMonitor(monitorId);
  }
Example #5
0
  @Put
  @Post
  public LBPool createPool(String postData) {

    LBPool pool = null;
    try {
      pool = jsonToPool(postData);
    } catch (IOException e) {
      log.error("Could not parse JSON {}", e.getMessage());
    }

    ILoadBalancerService lbs =
        (ILoadBalancerService)
            getContext().getAttributes().get(ILoadBalancerService.class.getCanonicalName());

    String poolId = (String) getRequestAttributes().get("pool");
    if (poolId != null) return lbs.updatePool(pool);
    else return lbs.createPool(pool);
  }
  @Put
  @Post
  public LBMonitor createMonitor(String postData) {

    LBMonitor monitor = null;
    try {
      monitor = jsonToMonitor(postData);
    } catch (IOException e) {
      log.error("Could not parse JSON {}", e.getMessage());
    }

    ILoadBalancerService lbs =
        (ILoadBalancerService)
            getContext().getAttributes().get(ILoadBalancerService.class.getCanonicalName());

    String monitorId = (String) getRequestAttributes().get("monitor");
    if (monitorId != null) return lbs.updateMonitor(monitor);
    else return lbs.createMonitor(monitor);
  }