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
-
-
Constructor Summary
Constructors Constructor Description ZkClientClusterStateProvider(String zkHost)
ZkClientClusterStateProvider(Collection<String> zkHosts, String chroot)
ZkClientClusterStateProvider(ZkStateReader zkStateReader)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
void
connect()
void
downloadConfig(String configName, Path downloadPath)
Download a named config from Zookeeper to a location on the filesystemMap<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.Object
getClusterProperty(String propertyName)
Obtain a cluster property, or null if it doesn't exist.<T> T
getClusterProperty(String propertyName, T def)
Obtain a cluster property, or the default value if it doesn't exist.ClusterState
getClusterState()
Obtain the current cluster state.Set<String>
getLiveNodes()
Obtain set of live_nodes for the cluster.String
getPolicyNameByCollection(String coll)
Get the collection-specific policyClusterState.CollectionRef
getState(String collection)
Obtain the state of the collection (cluster status).ZkStateReader
getZkStateReader()
boolean
isClosed()
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.String
resolveSimpleAlias(String alias)
Given a collection alias, return a single collection it points to, or the original name if it's not an alias.String
toString()
void
uploadConfig(Path configPath, String configName)
Upload a set of config files to Zookeeper and give it a name NOTE: You should only allow trusted users to upload configs.-
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
-
getState
public ClusterState.CollectionRef getState(String collection)
Description copied from interface:ClusterStateProvider
Obtain the state of the collection (cluster status).- Specified by:
getState
in interfaceClusterStateProvider
- Returns:
- the collection state, or null is collection doesn't exist
-
getLiveNodes
public Set<String> getLiveNodes()
Description copied from interface:ClusterStateProvider
Obtain set of live_nodes for the cluster.- Specified by:
getLiveNodes
in interfaceClusterStateProvider
-
resolveAlias
public List<String> resolveAlias(String alias)
Description copied from interface:ClusterStateProvider
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.- Specified by:
resolveAlias
in interfaceClusterStateProvider
-
getAliasProperties
public Map<String,String> getAliasProperties(String alias)
Description copied from interface:ClusterStateProvider
Return alias properties, or an empty map if the alias has no properties.- Specified by:
getAliasProperties
in interfaceClusterStateProvider
-
resolveSimpleAlias
public String resolveSimpleAlias(String alias) throws IllegalArgumentException
Description copied from interface:ClusterStateProvider
Given a collection alias, return a single collection it points to, or the original name if it's not an alias.- Specified by:
resolveSimpleAlias
in 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:ClusterStateProvider
Obtain a cluster property, or null if it doesn't exist.- Specified by:
getClusterProperty
in interfaceClusterStateProvider
-
getClusterProperty
public <T> T getClusterProperty(String propertyName, T def)
Description copied from interface:ClusterStateProvider
Obtain a cluster property, or the default value if it doesn't exist.- Specified by:
getClusterProperty
in interfaceClusterStateProvider
-
getClusterState
public ClusterState getClusterState() throws IOException
Description copied from interface:ClusterStateProvider
Obtain the current cluster state.- Specified by:
getClusterState
in interfaceClusterStateProvider
- Throws:
IOException
-
getClusterProperties
public Map<String,Object> getClusterProperties()
Description copied from interface:ClusterStateProvider
Obtain cluster properties.- Specified by:
getClusterProperties
in interfaceClusterStateProvider
- Returns:
- configured cluster properties, or an empty map, never null.
-
getPolicyNameByCollection
public String getPolicyNameByCollection(String coll)
Description copied from interface:ClusterStateProvider
Get the collection-specific policy- Specified by:
getPolicyNameByCollection
in interfaceClusterStateProvider
-
downloadConfig
public void downloadConfig(String configName, Path downloadPath) throws IOException
Download a named config from Zookeeper to a location on the filesystem- Parameters:
configName
- the name of the configdownloadPath
- the path to write config files to- Throws:
IOException
- if an I/O exception occurs
-
uploadConfig
public void uploadConfig(Path configPath, String configName) throws IOException
Upload a set of config files to Zookeeper and give it a name NOTE: You should only allow trusted users to upload configs. If you are allowing client access to zookeeper, you should protect the /configs node against unauthorised write access.- Parameters:
configPath
-Path
to the config filesconfigName
- the name of the config- Throws:
IOException
- if an IO error occurs
-
connect
public void connect()
- Specified by:
connect
in interfaceClusterStateProvider
-
getZkStateReader
public ZkStateReader getZkStateReader()
-
close
public void close() throws IOException
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Throws:
IOException
-
isClosed
public boolean isClosed()
- Specified by:
isClosed
in interfaceSolrCloseable
-
-