Пример #1
0
 /**
  * update work site
  *
  * @param site
  * @return
  */
 public boolean update(Site site) {
   if (site == null || !site.isWork()) {
     return false;
   }
   SiteHost host = site.getHost();
   Logger.info("WorkPool.update, work site %s", host);
   remove(host, false);
   return add(site, true);
 }
Пример #2
0
  private boolean add(Site object, boolean notify) {
    if (object == null || !object.isWork()) {
      return false;
    }
    WorkSite site = (WorkSite) object;
    SiteHost host = site.getHost();

    Logger.info("WorkPool.add, work site %s", host);

    boolean success = false;
    this.lockSingle();
    try {
      if (mapSite.containsKey(host)) {
        return false;
      }
      // save site
      mapSite.put(host, site);
      mapTime.put(host, System.currentTimeMillis());
      for (Naming naming : site.list()) {
        SiteSet set = mapNaming.get(naming);
        if (set == null) {
          set = new SiteSet();
          mapNaming.put(naming, set);
        }
        set.add(host);
      }
      success = true;

      if (notify) {
        CallPool.getInstance().refreshWorkSite();
      }
    } catch (Throwable exp) {
      Logger.error(exp);
    } finally {
      this.unlockSingle();
    }
    return success;
  }