コード例 #1
0
 @ModelAttribute("poolSettings")
 public PoolSettings getPoolSettings(
     /*@PathVariable("accountId") Long accountId,
     @PathVariable("poolId") Long poolId */ HttpServletRequest request) {
   //        return getAccountPool( accountId, poolId ).getPoolSettings();
   Map pathVariables =
       (Map)
           request.getAttribute(
               "org.springframework.web.servlet.HandlerMapping.uriTemplateVariables");
   if (pathVariables.containsKey("accountId") && pathVariables.containsKey("poolId")) {
     long accountId = Long.parseLong((String) pathVariables.get("accountId"));
     long poolId = Long.parseLong((String) pathVariables.get("poolId"));
     return poolDao.readPoolByIdAndAccountId(poolId, accountId).getPoolSettings();
   } else {
     return null;
   }
 }
コード例 #2
0
  /** @return poolConfigurationId => poolStatus map. */
  @RequestMapping(value = "/admin/pools/status", method = RequestMethod.GET)
  @ResponseBody
  public Map<Long, PoolStatus> getPoolsStatus() {
    Map<Long /* poolConfigurationId */, PoolStatus> resultMap = new HashMap<Long, PoolStatus>();
    // get pool status for all pools
    Collection<PoolStatus> poolStatuses = poolManagerApi.listStatuses();
    // map every status found to its pool configuration
    List<PoolConfigurationModel> poolConfigurationModels = poolDao.readPools();
    for (PoolConfigurationModel poolConfiguration : poolConfigurationModels) {
      Long poolConfigurationId = poolConfiguration.getId();

      for (PoolStatus poolStatus : poolStatuses) {
        if (poolStatus.getPoolId().equals(poolConfiguration.getPoolSettings().getUuid())) {
          resultMap.put(poolConfigurationId, poolStatus);
        }
      }
    }

    return resultMap;
  }