コード例 #1
0
 /**
  * Get the next house keeper that needs to be run
  *
  * @return the house keeper to run, or null if there is nothing to do.
  */
 protected static HouseKeeper getHouseKeeperToRun() {
   HouseKeeper houseKeeper = null;
   synchronized (LOCK) {
     for (int i = 0; i < houseKeeperList.size(); i++) {
       HouseKeeper hk = null;
       try {
         hk = (HouseKeeper) houseKeeperList.get(houseKeeperIndex);
         if (hk.isSweepDue()) {
           houseKeeper = hk;
           break;
         }
         houseKeeperIndex++;
       } catch (IndexOutOfBoundsException e) {
         houseKeeperIndex = 0;
       }
     }
   }
   return houseKeeper;
 }
コード例 #2
0
  public void run() {

    while (!stop) {
      HouseKeeper hk = HouseKeeperController.getHouseKeeperToRun();
      while (hk != null && !stop) {
        try {
          //                    if (LOG.isDebugEnabled()) {
          //                        LOG.debug("About to sweep " + hk.getAlias());
          //                    }
          hk.sweep();
        } catch (ProxoolException e) {
          LOG.error("Couldn't sweep " + hk.getAlias(), e);
        }
        hk = HouseKeeperController.getHouseKeeperToRun();
      }
      try {
        Thread.sleep(5000);
      } catch (InterruptedException e) {
        LOG.error("Interrupted", e);
      }
    }
  }