public class ZkClientClusterStateProvider extends Object implements ClusterStateProvider
Constructor and Description |
---|
ZkClientClusterStateProvider(Collection<String> zkHosts,
String chroot) |
ZkClientClusterStateProvider(String zkHost) |
ZkClientClusterStateProvider(ZkStateReader zkStateReader) |
Modifier and Type | Method and Description |
---|---|
void |
close() |
void |
connect() |
void |
downloadConfig(String configName,
Path downloadPath)
Download a named config from Zookeeper to a location on the filesystem
|
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 policy
|
ClusterState.CollectionRef |
getState(String collection)
Obtain the state of the collection (cluster status).
|
ZkStateReader |
getZkStateReader() |
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 |
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.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getCollection
isClosed
public ZkClientClusterStateProvider(ZkStateReader zkStateReader)
public ZkClientClusterStateProvider(Collection<String> zkHosts, String chroot)
public ZkClientClusterStateProvider(String zkHost)
public ClusterState.CollectionRef getState(String collection)
ClusterStateProvider
getState
in interface ClusterStateProvider
public ZkStateReader getZkStateReader()
public Set<String> getLiveNodes()
ClusterStateProvider
getLiveNodes
in interface ClusterStateProvider
public List<String> resolveAlias(String alias)
ClusterStateProvider
resolveAlias
in interface ClusterStateProvider
public Object getClusterProperty(String propertyName)
ClusterStateProvider
getClusterProperty
in interface ClusterStateProvider
public <T> T getClusterProperty(String propertyName, T def)
ClusterStateProvider
getClusterProperty
in interface ClusterStateProvider
public ClusterState getClusterState() throws IOException
ClusterStateProvider
getClusterState
in interface ClusterStateProvider
IOException
public Map<String,Object> getClusterProperties()
ClusterStateProvider
getClusterProperties
in interface ClusterStateProvider
public String getPolicyNameByCollection(String coll)
ClusterStateProvider
getPolicyNameByCollection
in interface ClusterStateProvider
public void downloadConfig(String configName, Path downloadPath) throws IOException
configName
- the name of the configdownloadPath
- the path to write config files toIOException
- if an I/O exception occurspublic void uploadConfig(Path configPath, String configName) throws IOException
configPath
- Path
to the config filesconfigName
- the name of the configIOException
- if an IO error occurspublic void connect()
connect
in interface ClusterStateProvider
public void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
IOException
Copyright © 2000-2019 Apache Software Foundation. All Rights Reserved.