Esempio n. 1
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;
  }
Esempio n. 2
0
  /*
   * (non-Javadoc)
   * @see com.lexst.db.view.View#add(com.lexst.util.host.SiteHost, com.lexst.db.sign.range.SignRange)
   */
  @Override
  public boolean add(SiteHost host, IndexRange index) {
    if (index.getClass() != ShortIndexRange.class) {
      throw new ClassCastException("not small index");
    }
    ShortIndexRange idx = (ShortIndexRange) index;
    short begin = idx.getBegin();
    short end = idx.getEnd();
    ShortRange range = new ShortRange(begin, end);
    long chunkId = idx.getChunkId();

    IdentitySet set = mapSet.get(range);
    if (set == null) {
      set = new IdentitySet();
      mapSet.put(range, set);
    }
    return set.add(host, chunkId);
  }
Esempio n. 3
0
 /**
  * refresh work site
  *
  * @param host
  * @return
  */
 public short refresh(SiteHost host) {
   short code = Response.SERVER_ERROR;
   this.lockSingle();
   try {
     WorkSite site = mapSite.get(host);
     if (site != null) {
       mapTime.put(host, System.currentTimeMillis());
       code = Response.ISEE;
     } else {
       code = Response.NOTLOGIN;
     }
   } catch (Throwable exp) {
     Logger.error(exp);
   } finally {
     this.unlockSingle();
   }
   Logger.debug("WorkPool.refresh, site %s refresh status %d", host, code);
   return code;
 }