创建Key为弱引用的ConcurrentMap，Key对象可被回收.

JDK没有WeakHashMap的并发实现, 由Guava提供
12279
public static <K, V> ConcurrentMap<K, V> createWeakKeyConcurrentMap(int initialCapacity, int concurrencyLevel) {
		return new MapMaker().weakKeys().initialCapacity(initialCapacity).concurrencyLevel(concurrencyLevel).makeMap();
	}
678001
@SuppressWarnings("unchecked") // worse case should be a ClassCastException
  /*
   * TODO(cpovirk): Consider requiring key to be a K here. But AtomicLongMapSubject isn't currently
   * parameterized, and if we're going to add a type parameter, I'd rather wait until after we
   * (hopefully) remove the other existing type parameters.
   */
  public void containsEntry(Object key, long value) {
    checkNotNull(key, "AtomicLongMap does not support null keys");
    long actualValue = ((AtomicLongMap<Object>) actual()).get(key);
    if (actualValue != value) {
      failWithActual("expected to contain entry", immutableEntry(key, value));
    }
  }
1114121
public S setParameter(String key, String value) {
        if (parameters == null) {
            parameters = new ConcurrentHashMap<String, String>();
        }
        if (value == null) {
            parameters.remove(key);
        } else {
            parameters.put(key, value);
        }
        return castThis();
    }
1356409
private static <K, V> Map<K, V> synchronizedCopyMap(Map<K, V> map) {

        if (map == null) {
            return new HashMap<K, V>();
        }

        synchronized (map) {

            return new HashMap<K, V>(map);
        }
    }
1283335
@Override
  public Map<K, ValueHolder<V>> bulkComputeIfAbsent(final Set<? extends K> keys, final Function<Iterable<? extends K>, Iterable<? extends Map.Entry<? extends K, ? extends V>>> mappingFunction)
      throws StoreAccessException {
    if(mappingFunction instanceof Ehcache.GetAllFunction) {
      Map<K, ValueHolder<V>> map  = new HashMap<>();
      for (K key : keys) {
        ValueHolder<V> value;
        try {
          value = getInternal(key);
        } catch (TimeoutException e) {
          // This timeout handling is safe **only** in the context of a get/read operation!
          value = null;
        }
        map.put(key, value);
      }
      return map;
    } else {
      throw new UnsupportedOperationException("This bulkComputeIfAbsent method is not yet capable of handling generic computation functions");
    }
  }
1212265
public void initializeCache(Object key) throws Exception {
		this.sortedWindows = cachedSortedWindows.get(key);
		if (sortedWindows == null) {
			this.sortedWindows = new TreeSet<>();
			Iterator<Map.Entry<W, W>> keyValues = mapping.iterator();
			if (keyValues != null) {
				while (keyValues.hasNext()) {
					Map.Entry<W, W> keyValue = keyValues.next();
					this.sortedWindows.add(keyValue.getKey());
				}
			}
			cachedSortedWindows.put(key, sortedWindows);
		}
	}
837
private static <E> SortedMap<PrefixKey, E> getPrefixSubMap(
      TreeMap<PrefixKey, E> map, PrefixKey lowerBound) {
    PrefixKey upperBound =
        new PrefixKey(lowerBound.getBucket(), lowerBound.getObjectName() + Character.MAX_VALUE);
    return map.subMap(lowerBound, upperBound);
  }
1139503
@Override
	public void cache(final Object key, final Object object) {
		this.logger.debug("@cache ");

		if (object == null) {
			if (!isAllowNullable()) {
				return;
			}
			this.logger.debug("logging key :", key, " with null");
			getCachableMap(JKAbstractCacheManager.NULLABLE_MAP_CLASS).put(key, null);
		} else {
			cache(key, object, object.getClass());
		}
	}
1099146
public final V get(K key) {
        if (key == null) {
            throw new NullPointerException("key == null");
        }

        V mapValue;
        synchronized (this) {
            mapValue = map.get(key);
            if (mapValue != null) {
                hitCount++;
                return mapValue;
            }
            missCount++;
        }

        /*
         * Attempt to create a value. This may take a long time, and the map
         * may be different when create() returns. If a conflicting value was
         * added to the map while create() was working, we leave that value in
         * the map and release the created value.
         */

        V createdValue = create(key);
        if (createdValue == null) {
            return null;
        }

        synchronized (this) {
            createCount++;
            mapValue = map.put(key, createdValue);

            if (mapValue != null) {
                // There was a conflict so undo that last put
                map.put(key, mapValue);
            } else {
                size += safeSizeOf(key, createdValue);
            }
        }

        if (mapValue != null) {
            entryRemoved(false, key, createdValue, mapValue);
            return mapValue;
        } else {
            trimToSize(maxSize);
            return createdValue;
        }
    }
936579
private <T> void storeInMap(MultiValueMap<T> map, T key, String[] values) {
        try {
            map.set(key, values);
        } catch (Exception e) {
            throw new IllegalArgumentException(e);
        }
    }
666853
public final Map<Tuple2<String, UUID>, Tuple2<Long, Long>> getWaitTimeouts() {
        return unmodifiableMap(waitTimeouts);
    }
1142949
public synchronized V lookup(final String key) {
        if (tmap == null) {
            throw new IllegalStateException("not open");
        }
        return tmap.get(key);
    }
564821
public alluxio.grpc.InconsistentProperties getErrorsOrThrow(
      java.lang.String key) {
    if (key == null) { throw new java.lang.NullPointerException(); }
    java.util.Map<java.lang.String, alluxio.grpc.InconsistentProperties> map =
        internalGetErrors().getMap();
    if (!map.containsKey(key)) {
      throw new java.lang.IllegalArgumentException();
    }
    return map.get(key);
  }
1083180
@Override
    public boolean containsKey(Object key) {
        if (fast) {
            return (map.containsKey(key));
        } else {
            synchronized (map) {
                return (map.containsKey(key));
            }
        }
    }
210582
public static <K, V> HashMap<K, V> newEmptyHashMap(Iterable<?> iterable) {
        if(iterable instanceof Collection<?>)
            return Maps.newHashMapWithExpectedSize(((Collection<?>) iterable).size());
        return Maps.newHashMap();
    }
1279921
@SuppressWarnings("unchecked")
  public static <K, V> MultiValueMap<K, V> unmodifiableMultiValueMap(
      final MultiValueMap<? extends K, ? extends V> map) {
    Assert.notNull(map, "'map' must not be null");
    final Map<K, List<V>> result = new LinkedHashMap<>(map.size());
    map.forEach((key, value) -> {
      final List<? extends V> values = Collections.unmodifiableList(value);
      result.put(key, (List<V>) values);
    });
    final Map<K, List<V>> unmodifiableMap = Collections.unmodifiableMap(result);
    return CollectionUtils.toMultiValueMap(unmodifiableMap);
  }
266717
public static void setCurrentPersistenceBroker(PBKey key, PersistenceBrokerInternal broker)
            throws PBFactoryException
    {
        HashMap map = (HashMap) currentBrokerMap.get();
        WeakHashMap set = null;
        if(map == null)
        {
            map = new HashMap();
            currentBrokerMap.set(map);

            synchronized(lock) {
                loadedHMs.add(map);
            }
        }
        else
        {
            set = (WeakHashMap) map.get(key);
        }

        if(set == null)
        {
            // We emulate weak HashSet using WeakHashMap
            set = new WeakHashMap();
            map.put(key, set);
        }
        set.put(broker, null);
    }