public class DefaultSolrIndexQueueProvider extends Object implements SolrIndexQueueProvider
Queue and a Lock to access the command queue.
The queue should only be accessed by a single thread at a time, and so accessors must first
obtain a lock. This is to prevent two threads, even across nodes, from issuing commands to Solr that might interfere with
one another (e.g. re-aliasing or committing).
This default implementation evaluates the SolrClient to determine whether to use a local Queue
and Lock, or whether to use a distributed Queue and Lock. If the SolrClient is an
instance of CloudSolrClient then this will use the associated Zookeeper to manage the lock and the queue.
Otherwise, it will use a local (non-distributed) lock and queue.
This can be extended to provide different queue and lock implementations. If you override them, then they both need
to be distributed or local. Having a local lock and a distributed queue or vice versa will not work.| Modifier and Type | Field and Description |
|---|---|
static String |
LOCK_PATH |
protected static Map<String,Lock> |
LOCK_REGISTRY |
static int |
MAX_QUEUE_SIZE |
static String |
QUEUE_PATH |
protected static Map<String,BlockingQueue<? super SolrUpdateCommand>> |
QUEUE_REGISTRY |
COMMAND_LOCK_NAME, COMMAND_QUEUE_NAME| Constructor and Description |
|---|
DefaultSolrIndexQueueProvider() |
DefaultSolrIndexQueueProvider(org.apache.solr.client.solrj.SolrClient solrClient,
org.springframework.core.env.Environment env) |
DefaultSolrIndexQueueProvider(org.apache.zookeeper.ZooKeeper zookeeper,
org.springframework.core.env.Environment env) |
| Modifier and Type | Method and Description |
|---|---|
protected Lock |
createDistributedLock(String lockName) |
protected BlockingQueue<? super SolrUpdateCommand> |
createDistributedQueue(String queueName) |
protected Lock |
createLocalLock(String lockName) |
protected BlockingQueue<? super SolrUpdateCommand> |
createLocalQueue(String queueName) |
Lock |
createOrRetrieveCommandLock(String lockName) |
BlockingQueue<? super SolrUpdateCommand> |
createOrRetrieveCommandQueue(String queueName) |
protected org.springframework.core.env.Environment |
getEnvironment()
Returns the
Environment object, which is used in a distributed situation to determine if the current node or application
can obtain a lock. |
protected org.apache.zookeeper.ZooKeeper |
getZookeeper()
Returns the
ZooKeeper instance that distributes the Lock and the Queue. |
boolean |
isDistributed()
Indicates if this is a distributed environment (e.g.
|
protected static final Map<String,BlockingQueue<? super SolrUpdateCommand>> QUEUE_REGISTRY
public static final int MAX_QUEUE_SIZE
public static final String LOCK_PATH
public static final String QUEUE_PATH
public DefaultSolrIndexQueueProvider()
public DefaultSolrIndexQueueProvider(org.apache.solr.client.solrj.SolrClient solrClient,
org.springframework.core.env.Environment env)
public DefaultSolrIndexQueueProvider(org.apache.zookeeper.ZooKeeper zookeeper,
org.springframework.core.env.Environment env)
public BlockingQueue<? super SolrUpdateCommand> createOrRetrieveCommandQueue(String queueName)
createOrRetrieveCommandQueue in interface SolrIndexQueueProviderpublic Lock createOrRetrieveCommandLock(String lockName)
createOrRetrieveCommandLock in interface SolrIndexQueueProviderpublic boolean isDistributed()
isDistributed in interface SolrIndexQueueProviderprotected org.springframework.core.env.Environment getEnvironment()
Environment object, which is used in a distributed situation to determine if the current node or application
can obtain a lock. This may return null.protected org.apache.zookeeper.ZooKeeper getZookeeper()
ZooKeeper instance that distributes the Lock and the Queue. This may return null in non-distributed situation.protected BlockingQueue<? super SolrUpdateCommand> createLocalQueue(String queueName)
protected BlockingQueue<? super SolrUpdateCommand> createDistributedQueue(String queueName)
Copyright © 2024. All rights reserved.