Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move cache implementations to internal package #4746

Merged
merged 5 commits into from
Dec 1, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

package io.opentelemetry.instrumentation.api.cache;

import io.opentelemetry.instrumentation.api.cache.concurrentlinkedhashmap.ConcurrentLinkedHashMap;
import io.opentelemetry.instrumentation.api.cache.internal.concurrentlinkedhashmap.ConcurrentLinkedHashMap;
import java.util.function.Function;
import javax.annotation.Nullable;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

package io.opentelemetry.instrumentation.api.cache;

import io.opentelemetry.instrumentation.api.cache.weaklockfree.WeakConcurrentMap;
import io.opentelemetry.context.internal.shaded.WeakConcurrentMap;
iNikem marked this conversation as resolved.
Show resolved Hide resolved
import java.util.function.Function;

final class WeakLockFreeCache<K, V> implements Cache<K, V> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@
* limitations under the License.
*/

package io.opentelemetry.instrumentation.api.cache.concurrentlinkedhashmap;
package io.opentelemetry.instrumentation.api.cache.internal.concurrentlinkedhashmap;

import static io.opentelemetry.instrumentation.api.cache.concurrentlinkedhashmap.ConcurrentLinkedHashMap.DrainStatus.IDLE;
import static io.opentelemetry.instrumentation.api.cache.concurrentlinkedhashmap.ConcurrentLinkedHashMap.DrainStatus.PROCESSING;
import static io.opentelemetry.instrumentation.api.cache.concurrentlinkedhashmap.ConcurrentLinkedHashMap.DrainStatus.REQUIRED;
import static io.opentelemetry.instrumentation.api.cache.internal.concurrentlinkedhashmap.ConcurrentLinkedHashMap.DrainStatus.IDLE;
import static io.opentelemetry.instrumentation.api.cache.internal.concurrentlinkedhashmap.ConcurrentLinkedHashMap.DrainStatus.PROCESSING;
import static io.opentelemetry.instrumentation.api.cache.internal.concurrentlinkedhashmap.ConcurrentLinkedHashMap.DrainStatus.REQUIRED;
import static java.util.Collections.emptyList;
import static java.util.Collections.unmodifiableMap;
import static java.util.Collections.unmodifiableSet;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
* limitations under the License.
*/

package io.opentelemetry.instrumentation.api.cache.concurrentlinkedhashmap;
package io.opentelemetry.instrumentation.api.cache.internal.concurrentlinkedhashmap;

import javax.annotation.concurrent.ThreadSafe;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
* limitations under the License.
*/

package io.opentelemetry.instrumentation.api.cache.concurrentlinkedhashmap;
package io.opentelemetry.instrumentation.api.cache.internal.concurrentlinkedhashmap;

import javax.annotation.concurrent.ThreadSafe;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
* limitations under the License.
*/

package io.opentelemetry.instrumentation.api.cache.concurrentlinkedhashmap;
package io.opentelemetry.instrumentation.api.cache.internal.concurrentlinkedhashmap;

import java.util.AbstractCollection;
import java.util.Collection;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
* limitations under the License.
*/

package io.opentelemetry.instrumentation.api.cache.concurrentlinkedhashmap;
package io.opentelemetry.instrumentation.api.cache.internal.concurrentlinkedhashmap;

import javax.annotation.concurrent.ThreadSafe;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
* limitations under the License.
*/

package io.opentelemetry.instrumentation.api.cache.concurrentlinkedhashmap;
package io.opentelemetry.instrumentation.api.cache.internal.concurrentlinkedhashmap;

import static io.opentelemetry.instrumentation.api.cache.concurrentlinkedhashmap.ConcurrentLinkedHashMap.checkNotNull;
import static io.opentelemetry.instrumentation.api.cache.internal.concurrentlinkedhashmap.ConcurrentLinkedHashMap.checkNotNull;

import java.io.Serializable;
import java.util.Collection;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,24 +30,26 @@
* This package contains an implementation of a bounded {@link java.util.concurrent.ConcurrentMap}
* data structure.
*
* <p>{@link io.opentelemetry.instrumentation.api.cache.concurrentlinkedhashmap.Weigher} is a simple
* interface for determining how many units of capacity an entry consumes. Depending on which
* concrete Weigher class is used, an entry may consume a different amount of space within the
* cache. The {@link io.opentelemetry.instrumentation.api.cache.concurrentlinkedhashmap.Weighers}
* class provides utility methods for obtaining the most common kinds of implementations.
*
* <p>{@link io.opentelemetry.instrumentation.api.cache.concurrentlinkedhashmap.EvictionListener}
* <p>{@link io.opentelemetry.instrumentation.api.cache.internal.concurrentlinkedhashmap.Weigher} is
* a simple interface for determining how many units of capacity an entry consumes. Depending on
* which concrete Weigher class is used, an entry may consume a different amount of space within the
* cache. The {@link
* io.opentelemetry.instrumentation.api.cache.internal.concurrentlinkedhashmap.Weighers} class
* provides utility methods for obtaining the most common kinds of implementations.
*
* <p>{@link
* io.opentelemetry.instrumentation.api.cache.internal.concurrentlinkedhashmap.EvictionListener}
* provides the ability to be notified when an entry is evicted from the map. An eviction occurs
* when the entry was automatically removed due to the map exceeding a capacity threshold. It is not
* called when an entry was explicitly removed.
*
* <p>The {@link
* io.opentelemetry.instrumentation.api.cache.concurrentlinkedhashmap.ConcurrentLinkedHashMap} class
* supplies an efficient, scalable, thread-safe, bounded map. As with the <tt>Java Collections
* io.opentelemetry.instrumentation.api.cache.internal.concurrentlinkedhashmap.ConcurrentLinkedHashMap}
* class supplies an efficient, scalable, thread-safe, bounded map. As with the <tt>Java Collections
* Framework</tt> the "Concurrent" prefix is used to indicate that the map is not governed by a
* single exclusion lock.
*
* @see <a href="http://code.google.com/p/concurrentlinkedhashmap/">
* http://code.google.com/p/concurrentlinkedhashmap/</a>
*/
package io.opentelemetry.instrumentation.api.cache.concurrentlinkedhashmap;
package io.opentelemetry.instrumentation.api.cache.internal.concurrentlinkedhashmap;
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
// Suppress warnings since this is vendored as-is.
// CHECKSTYLE:OFF

package io.opentelemetry.instrumentation.api.cache.weaklockfree;
package io.opentelemetry.instrumentation.api.cache.internal.weaklockfree;

import java.lang.ref.Reference;
import java.lang.ref.ReferenceQueue;
Expand Down Expand Up @@ -278,7 +278,7 @@ public String toString() {
* The weak key invokes the latent key's equality method upon evaluation.
*/

public static final class WeakKey<K> extends WeakReference<K> {
static final class WeakKey<K> extends WeakReference<K> {

private final int hashCode;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
// Suppress warnings since this is vendored as-is.
// CHECKSTYLE:OFF

package io.opentelemetry.instrumentation.api.cache.weaklockfree;
package io.opentelemetry.instrumentation.api.cache.internal.weaklockfree;

import java.util.Iterator;
import java.util.Map;
Expand Down Expand Up @@ -115,7 +115,9 @@ public WeakConcurrentMap(boolean cleanerThread, boolean reuseKeys) {
* @param target ConcurrentMap implementation that this class wraps.
*/
public WeakConcurrentMap(
boolean cleanerThread, boolean reuseKeys, ConcurrentMap<WeakKey<K>, V> target) {
boolean cleanerThread,
boolean reuseKeys,
ConcurrentMap<AbstractWeakConcurrentMap.WeakKey<K>, V> target) {
super(target);
this.reuseKeys = reuseKeys;
if (cleanerThread) {
Expand Down Expand Up @@ -180,7 +182,7 @@ public boolean equals(Object other) {
if (other instanceof WeakConcurrentMap.LookupKey<?>) {
return ((LookupKey<?>) other).key == key;
} else {
return ((WeakKey<?>) other).get() == key;
return ((AbstractWeakConcurrentMap.WeakKey<?>) other).get() == key;
}
}

Expand Down