Code example for AtomicInteger

Methods: addAndGet

0
   * @param mapId The taskID of this map. 
   */ 
  public void removeMap(String mapId) {
    IndexInformation info = cache.remove(mapId);
    if (info != null) {
      totalMemoryUsed.addAndGet(-info.getSize());
      if (!queue.remove(mapId)) {
        LOG.warn("Map ID" + mapId + " not found in queue!!");
      } 
    } else { 
      LOG.info("Map ID " + mapId + " not found in cache");
    } 
  } 
 
  /** 
   * Bring memory usage below totalMemoryAllowed. 
   */ 
  private synchronized void freeIndexInformation() { 
    while (totalMemoryUsed.get() > totalMemoryAllowed) {
      String s = queue.remove();
      IndexInformation info = cache.remove(s);