Class ZkClientClusterStateProvider
- java.lang.Object
-
- org.apache.solr.client.solrj.impl.ZkClientClusterStateProvider
-
- All Implemented Interfaces:
Closeable,AutoCloseable,ClusterStateProvider,SolrCloseable
public class ZkClientClusterStateProvider extends Object implements ClusterStateProvider
Retrieves cluster state from Zookeeper
-
-
Constructor Summary
Constructors Constructor Description ZkClientClusterStateProvider(String zkHost)ZkClientClusterStateProvider(Collection<String> zkHosts, String chroot)ZkClientClusterStateProvider(ZkStateReader zkStateReader)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()voidconnect()static ZkClientClusterStateProviderfrom(CloudSolrClient client)Extracts this from the client, or throws an exception if of the wrong type.Map<String,String>getAliasProperties(String alias)Return alias properties, or an empty map if the alias has no properties.Map<String,Object>getClusterProperties()Obtain cluster properties.ObjectgetClusterProperty(String propertyName)Obtain a cluster property, or null if it doesn't exist.<T> TgetClusterProperty(String propertyName, T def)Obtain a cluster property, or the default value if it doesn't exist.ClusterStategetClusterState()Obtain the current cluster state.Set<String>getLiveNodes()Obtain set of live_nodes for the cluster.StringgetPolicyNameByCollection(String coll)Get the collection-specific policyStringgetQuorumHosts()ClusterState.CollectionRefgetState(String collection)Obtain the state of the collection (cluster status).intgetZkClientTimeout()intgetZkConnectTimeout()StringgetZkHost()ZkStateReadergetZkStateReader()booleanisClosed()List<String>resolveAlias(String alias)Given a collection alias, returns a list of collections it points to, or returns a singleton list of the input if it's not an alias.StringresolveSimpleAlias(String alias)Given a collection alias, return a single collection it points to, or the original name if it's not an alias.voidsetZkClientTimeout(int zkClientTimeout)Set the timeout to the zookeeper ensemble in msvoidsetZkConnectTimeout(int zkConnectTimeout)Set the connect timeout to the zookeeper ensemble in msStringtoString()-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.apache.solr.client.solrj.impl.ClusterStateProvider
getCollection, isRoutedAlias
-
-
-
-
Constructor Detail
-
ZkClientClusterStateProvider
public ZkClientClusterStateProvider(ZkStateReader zkStateReader)
-
ZkClientClusterStateProvider
public ZkClientClusterStateProvider(Collection<String> zkHosts, String chroot)
-
ZkClientClusterStateProvider
public ZkClientClusterStateProvider(String zkHost)
-
-
Method Detail
-
from
public static ZkClientClusterStateProvider from(CloudSolrClient client)
Extracts this from the client, or throws an exception if of the wrong type.
-
getState
public ClusterState.CollectionRef getState(String collection)
Description copied from interface:ClusterStateProviderObtain the state of the collection (cluster status).- Specified by:
getStatein interfaceClusterStateProvider- Returns:
- the collection state, or null is collection doesn't exist
-
getLiveNodes
public Set<String> getLiveNodes()
Description copied from interface:ClusterStateProviderObtain set of live_nodes for the cluster.- Specified by:
getLiveNodesin interfaceClusterStateProvider
-
resolveAlias
public List<String> resolveAlias(String alias)
Description copied from interface:ClusterStateProviderGiven a collection alias, returns a list of collections it points to, or returns a singleton list of the input if it's not an alias.- Specified by:
resolveAliasin interfaceClusterStateProvider
-
getAliasProperties
public Map<String,String> getAliasProperties(String alias)
Description copied from interface:ClusterStateProviderReturn alias properties, or an empty map if the alias has no properties.- Specified by:
getAliasPropertiesin interfaceClusterStateProvider
-
resolveSimpleAlias
public String resolveSimpleAlias(String alias) throws IllegalArgumentException
Description copied from interface:ClusterStateProviderGiven a collection alias, return a single collection it points to, or the original name if it's not an alias.- Specified by:
resolveSimpleAliasin interfaceClusterStateProvider- Throws:
IllegalArgumentException- if an alias points to more than 1 collection, either directly or indirectly.
-
getClusterProperty
public Object getClusterProperty(String propertyName)
Description copied from interface:ClusterStateProviderObtain a cluster property, or null if it doesn't exist.- Specified by:
getClusterPropertyin interfaceClusterStateProvider
-
getClusterProperty
public <T> T getClusterProperty(String propertyName, T def)
Description copied from interface:ClusterStateProviderObtain a cluster property, or the default value if it doesn't exist.- Specified by:
getClusterPropertyin interfaceClusterStateProvider
-
getClusterState
public ClusterState getClusterState()
Description copied from interface:ClusterStateProviderObtain the current cluster state.- Specified by:
getClusterStatein interfaceClusterStateProvider
-
getClusterProperties
public Map<String,Object> getClusterProperties()
Description copied from interface:ClusterStateProviderObtain cluster properties.- Specified by:
getClusterPropertiesin interfaceClusterStateProvider- Returns:
- configured cluster properties, or an empty map, never null.
-
getPolicyNameByCollection
public String getPolicyNameByCollection(String coll)
Description copied from interface:ClusterStateProviderGet the collection-specific policy- Specified by:
getPolicyNameByCollectionin interfaceClusterStateProvider
-
connect
public void connect()
- Specified by:
connectin interfaceClusterStateProvider
-
getZkStateReader
public ZkStateReader getZkStateReader()
-
close
public void close() throws IOException- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException
-
getQuorumHosts
public String getQuorumHosts()
- Specified by:
getQuorumHostsin interfaceClusterStateProvider
-
isClosed
public boolean isClosed()
- Specified by:
isClosedin interfaceSolrCloseable
-
getZkHost
public String getZkHost()
- Returns:
- the zkHost value used to connect to zookeeper.
-
getZkConnectTimeout
public int getZkConnectTimeout()
-
setZkConnectTimeout
public void setZkConnectTimeout(int zkConnectTimeout)
Set the connect timeout to the zookeeper ensemble in ms
-
getZkClientTimeout
public int getZkClientTimeout()
-
setZkClientTimeout
public void setZkClientTimeout(int zkClientTimeout)
Set the timeout to the zookeeper ensemble in ms
-
-