public class ZkStateReader extends Object implements Closeable
Modifier and Type | Class and Description |
---|---|
static class |
ZkStateReader.ConfigData |
Constructor and Description |
---|
ZkStateReader(SolrZkClient zkClient) |
ZkStateReader(SolrZkClient zkClient,
Runnable securityNodeListener) |
ZkStateReader(String zkServerAddress,
int zkClientTimeout,
int zkClientConnectTimeout) |
Modifier and Type | Method and Description |
---|---|
void |
close() |
Integer |
compareStateVersions(String coll,
int version) |
void |
createClusterStateWatchersAndUpdate() |
void |
forceUpdateCollection(String collection)
Forcibly refresh a collection's internal state from ZK.
|
Aliases |
getAliases() |
String |
getBaseUrlForNodeName(String nodeName)
Returns the baseURL corresponding to a given node's nodeName --
NOTE: does not (currently) imply that the nodeName (or resulting
baseURL) exists in the cluster.
|
static String |
getBaseUrlForNodeName(String nodeName,
String urlScheme) |
Map<String,Object> |
getClusterProperties()
Get all cluster properties for this cluster
N.B.
|
<T> T |
getClusterProperty(String key,
T defaultValue)
Get a cluster property
N.B.
|
ClusterState |
getClusterState() |
static DocCollection |
getCollectionLive(ZkStateReader zkStateReader,
String coll) |
static String |
getCollectionPath(String coll) |
static String |
getCollectionPathRoot(String coll) |
ZkConfigManager |
getConfigManager() |
Replica |
getLeader(String collection,
String shard) |
Replica |
getLeaderRetry(String collection,
String shard)
Get shard leader properties, with retry if none exist.
|
Replica |
getLeaderRetry(String collection,
String shard,
int timeout)
Get shard leader properties, with retry if none exist.
|
String |
getLeaderUrl(String collection,
String shard,
int timeout) |
List<ZkCoreNodeProps> |
getReplicaProps(String collection,
String shardId,
String thisCoreNodeName) |
List<ZkCoreNodeProps> |
getReplicaProps(String collection,
String shardId,
String thisCoreNodeName,
Replica.State mustMatchStateFilter) |
List<ZkCoreNodeProps> |
getReplicaProps(String collection,
String shardId,
String thisCoreNodeName,
Replica.State mustMatchStateFilter,
Replica.State mustNotMatchStateFilter) |
ZkStateReader.ConfigData |
getSecurityProps(boolean getFresh)
Returns the content of /security.json from ZooKeeper as a Map
If the files doesn't exist, it returns null.
|
static String |
getShardLeadersElectPath(String collection,
String shardId)
Get path where shard leader elections ephemeral nodes are.
|
static String |
getShardLeadersPath(String collection,
String shardId)
Get path where shard leader properties live in zookeeper.
|
Object |
getUpdateLock() |
SolrZkClient |
getZkClient() |
String |
readConfigName(String collection)
Returns config set name for collection.
|
void |
registerCollectionStateWatcher(String collection,
CollectionStateWatcher stateWatcher)
Register a CollectionStateWatcher to be called when the state of a collection changes
|
void |
registerCore(String collection)
Notify this reader that a local Core is a member of a collection, and so that collection
state should be watched.
|
void |
removeCollectionStateWatcher(String collection,
CollectionStateWatcher watcher)
Remove a watcher from a collection's watch list.
|
void |
unregisterCore(String collection)
Notify this reader that a local core that is a member of a collection has been closed.
|
void |
updateAliases() |
void |
updateClusterState()
Deprecated.
Don't call this, call
forceUpdateCollection(String) on a single collection if you must. |
void |
updateLiveNodes()
Refresh the set of live nodes.
|
void |
waitForState(String collection,
long wait,
TimeUnit unit,
CollectionStatePredicate predicate)
Block until a CollectionStatePredicate returns true, or the wait times out
Note that the predicate may be called again even after it has returned true, so
implementors should avoid changing state within the predicate call itself.
|
public static final String BASE_URL_PROP
public static final String NODE_NAME_PROP
public static final String CORE_NODE_NAME_PROP
public static final String ROLES_PROP
public static final String STATE_PROP
public static final String CORE_NAME_PROP
public static final String COLLECTION_PROP
public static final String ELECTION_NODE_PROP
public static final String SHARD_ID_PROP
public static final String REPLICA_PROP
public static final String SHARD_RANGE_PROP
public static final String SHARD_STATE_PROP
public static final String SHARD_PARENT_PROP
public static final String NUM_SHARDS_PROP
public static final String LEADER_PROP
public static final String PROPERTY_PROP
public static final String PROPERTY_VALUE_PROP
public static final String MAX_AT_ONCE_PROP
public static final String MAX_WAIT_SECONDS_PROP
public static final String COLLECTIONS_ZKNODE
public static final String LIVE_NODES_ZKNODE
public static final String ALIASES
public static final String CLUSTER_STATE
public static final String CLUSTER_PROPS
public static final String REJOIN_AT_HEAD_PROP
public static final String SOLR_SECURITY_CONF_PATH
public static final String REPLICATION_FACTOR
public static final String MAX_SHARDS_PER_NODE
public static final String AUTO_ADD_REPLICAS
public static final String MAX_CORES_PER_NODE
public static final String ROLES
public static final String CONFIGS_ZKNODE
public static final String CONFIGNAME_PROP
public static final String LEGACY_CLOUD
public static final String URL_SCHEME
protected volatile ClusterState clusterState
public static final String LEADER_ELECT_ZKNODE
public static final String SHARD_LEADERS_ZKNODE
public static final String ELECTION_NODE
public ZkStateReader(SolrZkClient zkClient)
public ZkStateReader(SolrZkClient zkClient, Runnable securityNodeListener)
public ZkStateReader(String zkServerAddress, int zkClientTimeout, int zkClientConnectTimeout)
public String readConfigName(String collection)
collection
- to return config set name forpublic ZkConfigManager getConfigManager()
@Deprecated public void updateClusterState() throws org.apache.zookeeper.KeeperException, InterruptedException
forceUpdateCollection(String)
on a single collection if you must.org.apache.zookeeper.KeeperException
InterruptedException
public void forceUpdateCollection(String collection) throws org.apache.zookeeper.KeeperException, InterruptedException
org.apache.zookeeper.KeeperException
InterruptedException
public void updateLiveNodes() throws org.apache.zookeeper.KeeperException, InterruptedException
org.apache.zookeeper.KeeperException
InterruptedException
public Aliases getAliases()
public void createClusterStateWatchersAndUpdate() throws org.apache.zookeeper.KeeperException, InterruptedException
org.apache.zookeeper.KeeperException
InterruptedException
public ClusterState getClusterState()
public Object getUpdateLock()
public void close()
close
in interface Closeable
close
in interface AutoCloseable
public String getLeaderUrl(String collection, String shard, int timeout) throws InterruptedException
InterruptedException
public Replica getLeaderRetry(String collection, String shard) throws InterruptedException
InterruptedException
public Replica getLeaderRetry(String collection, String shard, int timeout) throws InterruptedException
InterruptedException
public static String getShardLeadersPath(String collection, String shardId)
public static String getShardLeadersElectPath(String collection, String shardId)
public List<ZkCoreNodeProps> getReplicaProps(String collection, String shardId, String thisCoreNodeName)
public List<ZkCoreNodeProps> getReplicaProps(String collection, String shardId, String thisCoreNodeName, Replica.State mustMatchStateFilter)
public List<ZkCoreNodeProps> getReplicaProps(String collection, String shardId, String thisCoreNodeName, Replica.State mustMatchStateFilter, Replica.State mustNotMatchStateFilter)
public SolrZkClient getZkClient()
public void updateAliases() throws org.apache.zookeeper.KeeperException, InterruptedException
org.apache.zookeeper.KeeperException
InterruptedException
public <T> T getClusterProperty(String key, T defaultValue)
ClusterProperties
instance.T
- the type of the propertykey
- the property to readdefaultValue
- a default value to use if no such property existspublic Map<String,Object> getClusterProperties()
ClusterProperties
instance.public ZkStateReader.ConfigData getSecurityProps(boolean getFresh)
public String getBaseUrlForNodeName(String nodeName)
public static DocCollection getCollectionLive(ZkStateReader zkStateReader, String coll)
public void registerCore(String collection)
collection
- the collection that the core is a member ofunregisterCore(String)
public void unregisterCore(String collection)
CollectionStateWatcher
s
for that collection either, the collection watch will be removed.collection
- the collection that the core belongs topublic void registerCollectionStateWatcher(String collection, CollectionStateWatcher stateWatcher)
public void waitForState(String collection, long wait, TimeUnit unit, CollectionStatePredicate predicate) throws InterruptedException, TimeoutException
collection
- the collection to watchwait
- how long to waitunit
- the units of the wait parameterpredicate
- the predicate to call on state changesInterruptedException
- on interruptTimeoutException
- on timeoutpublic void removeCollectionStateWatcher(String collection, CollectionStateWatcher watcher)
collection
- the collectionwatcher
- the watcherCopyright © 2000-2017 Apache Software Foundation. All Rights Reserved.