Skip to content

Commit

Permalink
Move cache implementations to internal package (open-telemetry#4746)
Browse files Browse the repository at this point in the history
* Move cache implementations to internal package

* Fix import

* Fix import order
  • Loading branch information
iNikem authored and RashmiRam committed May 23, 2022
1 parent dc3649b commit d1cf603
Show file tree
Hide file tree
Showing 11 changed files with 31 additions and 27 deletions.
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.instrumentation.api.cache.internal.weaklockfree.WeakConcurrentMap;
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

0 comments on commit d1cf603

Please sign in to comment.