public class ZkClientClusterStateProvider extends Object implements ClusterStateProvider
Constructor and Description |
---|
ZkClientClusterStateProvider(Collection<String> zkHosts,
String chroot) |
ZkClientClusterStateProvider(String zkHost) |
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
|
String |
getAlias(String alias)
Given an alias, returns the collection name that this alias points to
|
Object |
getClusterProperty(String propertyName)
Obtain a cluster property, or null if it doesn't exist.
|
Object |
getClusterProperty(String propertyName,
String def)
Obtain a cluster property, or the default value if it doesn't exist.
|
String |
getCollectionName(String name)
Given a name, returns the collection name if an alias by that name exists, or
returns the name itself, if no alias exists.
|
ClusterState.CollectionRef |
getState(String collection)
Obtain the state of the collection (cluster status).
|
Set<String> |
liveNodes()
Obtain set of live_nodes for the cluster.
|
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.
|
public ZkClientClusterStateProvider(Collection<String> zkHosts, String chroot)
public ZkClientClusterStateProvider(String zkHost)
public ClusterState.CollectionRef getState(String collection)
ClusterStateProvider
getState
in interface ClusterStateProvider
public Set<String> liveNodes()
ClusterStateProvider
liveNodes
in interface ClusterStateProvider
public String getAlias(String alias)
ClusterStateProvider
getAlias
in interface ClusterStateProvider
public Object getClusterProperty(String propertyName)
ClusterStateProvider
getClusterProperty
in interface ClusterStateProvider
public Object getClusterProperty(String propertyName, String def)
ClusterStateProvider
getClusterProperty
in interface ClusterStateProvider
public String getCollectionName(String name)
ClusterStateProvider
getCollectionName
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-2018 Apache Software Foundation. All Rights Reserved.