예제 #1
0
  /**
   * @param host
   * @param notify
   * @return
   */
  private boolean remove(SiteHost host, boolean notify) {
    Logger.info("WorkPool.remove, work site %s", host);

    boolean success = false;
    this.lockSingle();
    try {
      mapTime.remove(host);
      WorkSite site = mapSite.remove(host);
      if (site != null) {
        for (Naming naming : site.list()) {
          SiteSet set = mapNaming.get(naming);
          if (set != null) {
            set.remove(host);
          }
          if (set == null || set.isEmpty()) {
            mapNaming.remove(naming);
          }
        }
        success = true;

        if (notify) {
          CallPool.getInstance().refreshWorkSite();
        }
      }
    } catch (Throwable exp) {
      Logger.error(exp);
    } finally {
      this.unlockSingle();
    }
    return success;
  }
예제 #2
0
  /*
   * (non-Javadoc)
   * @see com.lexst.db.view.View#remove(com.lexst.util.host.SiteHost)
   */
  @Override
  public int remove(SiteHost host) {
    int size = mapSet.size();
    if (size == 0) return size;

    int count = 0;
    ArrayList<ShortRange> a = new ArrayList<ShortRange>(size);
    for (ShortRange range : mapSet.keySet()) {
      IdentitySet set = mapSet.get(range);
      if (set != null) {
        count += set.remove(host);
        if (set.isEmpty()) a.add(range);
      } else {
        a.add(range);
      }
    }
    for (ShortRange range : a) {
      mapSet.remove(range);
    }
    return count;
  }
예제 #3
0
  /*
   * (non-Javadoc)
   * @see com.lexst.db.view.View#remove(com.lexst.util.host.SiteHost, long)
   */
  @Override
  public int remove(SiteHost host, long chunkId) {
    int size = mapSet.size();
    if (size == 0) return 0;

    int count = 0;
    ArrayList<ShortRange> a = new ArrayList<ShortRange>(size);
    for (ShortRange range : mapSet.keySet()) {
      IdentitySet set = mapSet.get(range);
      if (set != null) {
        boolean success = set.remove(host, chunkId);
        if (success) count++;
        if (set.isEmpty()) a.add(range);
      } else {
        a.add(range);
      }
    }
    for (ShortRange range : a) {
      mapSet.remove(range);
    }
    return count;
  }
예제 #4
0
  /*
   * (non-Javadoc)
   * @see com.lexst.db.view.View#delete(com.lexst.util.host.SiteHost)
   */
  @Override
  public List<Long> delete(SiteHost host) {
    int size = mapSet.size();
    if (size == 0) return null;

    ArrayList<Long> array = new ArrayList<Long>(256);

    ArrayList<ShortRange> a = new ArrayList<ShortRange>(size);
    for (ShortRange range : mapSet.keySet()) {
      IdentitySet set = mapSet.get(range);
      if (set != null) {
        set.remove(host, array);
        if (set.isEmpty()) a.add(range);
      } else {
        a.add(range);
      }
    }
    for (ShortRange range : a) {
      mapSet.remove(range);
    }
    return array;
  }