org.infinispan.query.backend.ReadIntensiveClusterRegistryWrapper Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of infinispan-embedded-query
Show all versions of infinispan-embedded-query
Infinispan Embedded Query All-in-One module
package org.infinispan.query.backend;
import net.jcip.annotations.ThreadSafe;
import org.infinispan.registry.ClusterRegistry;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.atomic.AtomicReference;
/**
* Local cache for the ClusterRegistry.
* Write operations are expected to happen only exceptionally, therefore this code
* is heavily optimized for reads (at cost of writes).
* Also we're assuming all entries are small: there is no size limit nor cleanup strategy.
*
* This is not caching the fact that some key is not defined: that would be tricky to
* get right and is not needed for our use case.
*
* @author Sanne Grinovero (C) 2013 Red Hat Inc.
*/
@ThreadSafe
final class ReadIntensiveClusterRegistryWrapper {
private final ClusterRegistry clusterRegistry;
private final S scope;
/**
* Not using a ConcurrentHashMap as this will degenerate into a read-only Map at runtime;
* in the Query specific case we're only adding new class types while they are being discovered,
* after this initial phase this is supposed to be a read-only immutable map.
*/
private final AtomicReference