public final class ZkController extends Object
Modifier and Type | Class and Description |
---|---|
static class |
ZkController.ResourceModifiedInZkException |
Modifier and Type | Field and Description |
---|---|
static String |
COLLECTION_PARAM_PREFIX |
static String |
CONFIGNAME_PROP |
protected Overseer |
overseer |
Constructor and Description |
---|
ZkController(CoreContainer cc,
String zkServerAddress,
int zkClientConnectTimeout,
CloudConfig cloudConfig,
CurrentCoreDescriptorProvider registerOnReconnect) |
Modifier and Type | Method and Description |
---|---|
void |
addOnReconnectListener(OnReconnect listener)
Add a listener to be notified once there is a new session created after a ZooKeeper session expiration occurs;
in most cases, listeners will be components that have watchers that need to be re-created.
|
static void |
bootstrapConf(SolrZkClient zkClient,
CoreContainer cc,
String solrHome)
If in SolrCloud mode, upload config sets for each SolrCore in solr.xml.
|
static boolean |
checkChrootPath(String zkHost,
boolean create)
Validates if the chroot exists in zk (or if it is successfully created).
|
void |
checkOverseerDesignate() |
void |
close()
Closes the underlying ZooKeeper client.
|
boolean |
configFileExists(String collection,
String fileName)
Returns true if config file exists
|
static void |
createClusterZkNodes(SolrZkClient zkClient)
Create the zknodes necessary for a cluster to operate
|
void |
createCollection(String collection) |
void |
createCollectionZkNode(CloudDescriptor cd) |
boolean |
ensureReplicaInLeaderInitiatedRecovery(String collection,
String shardId,
ZkCoreNodeProps replicaCoreProps,
String leaderCoreNodeName,
boolean forcePublishState,
boolean retryOnConnLoss)
When a leader receives a communication error when trying to send a request to a replica,
it calls this method to ensure the replica enters recovery when connectivity is restored.
|
String |
getBaseUrl() |
int |
getClientTimeout() |
ClusterState |
getClusterState() |
OnReconnect |
getConfigDirListener() |
byte[] |
getConfigFileData(String zkConfigName,
String fileName)
Returns config file data (in bytes)
|
String |
getCoreNodeName(CoreDescriptor descriptor) |
String |
getHostName() |
int |
getHostPort() |
int |
getLeaderConflictResolveWait() |
Replica.State |
getLeaderInitiatedRecoveryState(String collection,
String shardId,
String coreNodeName) |
Map<String,Object> |
getLeaderInitiatedRecoveryStateObject(String collection,
String shardId,
String coreNodeName) |
String |
getLeaderInitiatedRecoveryZnodePath(String collection,
String shardId) |
String |
getLeaderInitiatedRecoveryZnodePath(String collection,
String shardId,
String coreNodeName) |
ZkCoreNodeProps |
getLeaderProps(String collection,
String slice,
int timeoutms)
Get leader props directly from zk nodes.
|
ZkCoreNodeProps |
getLeaderProps(String collection,
String slice,
int timeoutms,
boolean failImmediatelyOnExpiration)
Get leader props directly from zk nodes.
|
String |
getLeaderSeqPath(String collection,
String coreNodeName) |
int |
getLeaderVoteWait() |
String |
getNodeName() |
Overseer |
getOverseer() |
DistributedQueue |
getOverseerCollectionQueue() |
DistributedMap |
getOverseerCompletedMap() |
LeaderElector |
getOverseerElector() |
DistributedMap |
getOverseerFailureMap() |
DistributedQueue |
getOverseerJobQueue() |
DistributedMap |
getOverseerRunningMap() |
SolrZkClient |
getZkClient() |
String |
getZkServerAddress() |
ZkStateReader |
getZkStateReader() |
boolean |
isConnected() |
boolean |
isReplicaInRecoveryHandling(String replicaUrl) |
static void |
linkConfSet(SolrZkClient zkClient,
String collection,
String confSetName) |
boolean |
pathExists(String path)
Returns true if the path exists
|
static int |
persistConfigResourceToZooKeeper(ZkSolrResourceLoader zkLoader,
int znodeVersion,
String resourceName,
byte[] content,
boolean createIfNotExists)
Persists a config file to ZooKeeper using optimistic concurrency.
|
void |
preRegister(CoreDescriptor cd) |
void |
publish(CoreDescriptor cd,
Replica.State state) |
void |
publish(CoreDescriptor cd,
Replica.State state,
boolean updateLastState) |
void |
publish(CoreDescriptor cd,
Replica.State state,
boolean updateLastState,
boolean forcePublish)
Publish core state to overseer.
|
void |
publishAndWaitForDownStates() |
String |
register(String coreName,
CoreDescriptor desc)
Register shard with ZooKeeper.
|
String |
register(String coreName,
CoreDescriptor desc,
boolean recoverReloadedCores,
boolean afterExpiration)
Register shard with ZooKeeper.
|
void |
registerConfListenerForCore(String confDir,
SolrCore core,
Runnable listener)
This will give a callback to the listener whenever a child is modified in the
conf directory.
|
void |
rejoinOverseerElection(String electionNode,
boolean joinAtHead) |
void |
rejoinShardLeaderElection(SolrParams params) |
void |
removeReplicaFromLeaderInitiatedRecoveryHandling(String replicaUrl) |
void |
throwErrorIfReplicaReplaced(CoreDescriptor desc) |
static void |
touchConfDir(ZkSolrResourceLoader zkLoader) |
static String |
trimLeadingAndTrailingSlashes(String in)
Utility method for trimming and leading and/or trailing slashes from
its input.
|
void |
unregister(String coreName,
CoreDescriptor cd) |
public static final String COLLECTION_PARAM_PREFIX
public static final String CONFIGNAME_PROP
protected volatile Overseer overseer
public ZkController(CoreContainer cc, String zkServerAddress, int zkClientConnectTimeout, CloudConfig cloudConfig, CurrentCoreDescriptorProvider registerOnReconnect) throws InterruptedException, TimeoutException, IOException
public int getLeaderVoteWait()
public int getLeaderConflictResolveWait()
public void close()
public boolean configFileExists(String collection, String fileName) throws org.apache.zookeeper.KeeperException, InterruptedException
org.apache.zookeeper.KeeperException
InterruptedException
public ClusterState getClusterState()
public byte[] getConfigFileData(String zkConfigName, String fileName) throws org.apache.zookeeper.KeeperException, InterruptedException
org.apache.zookeeper.KeeperException
InterruptedException
public String getHostName()
public int getHostPort()
public SolrZkClient getZkClient()
public String getZkServerAddress()
public static void createClusterZkNodes(SolrZkClient zkClient) throws org.apache.zookeeper.KeeperException, InterruptedException
zkClient
- a SolrZkClientorg.apache.zookeeper.KeeperException
- if there is a Zookeeper errorInterruptedException
- on interruptpublic void publishAndWaitForDownStates() throws org.apache.zookeeper.KeeperException, InterruptedException
org.apache.zookeeper.KeeperException
InterruptedException
public static boolean checkChrootPath(String zkHost, boolean create) throws org.apache.zookeeper.KeeperException, InterruptedException
org.apache.zookeeper.KeeperException
InterruptedException
public boolean isConnected()
public String getNodeName()
public boolean pathExists(String path) throws org.apache.zookeeper.KeeperException, InterruptedException
org.apache.zookeeper.KeeperException
InterruptedException
public String register(String coreName, CoreDescriptor desc) throws Exception
Exception
public String register(String coreName, CoreDescriptor desc, boolean recoverReloadedCores, boolean afterExpiration) throws Exception
Exception
public ZkCoreNodeProps getLeaderProps(String collection, String slice, int timeoutms) throws InterruptedException
InterruptedException
public ZkCoreNodeProps getLeaderProps(String collection, String slice, int timeoutms, boolean failImmediatelyOnExpiration) throws InterruptedException
InterruptedException
public String getBaseUrl()
public void publish(CoreDescriptor cd, Replica.State state) throws org.apache.zookeeper.KeeperException, InterruptedException
org.apache.zookeeper.KeeperException
InterruptedException
public void publish(CoreDescriptor cd, Replica.State state, boolean updateLastState) throws org.apache.zookeeper.KeeperException, InterruptedException
org.apache.zookeeper.KeeperException
InterruptedException
public void publish(CoreDescriptor cd, Replica.State state, boolean updateLastState, boolean forcePublish) throws org.apache.zookeeper.KeeperException, InterruptedException
org.apache.zookeeper.KeeperException
InterruptedException
public void unregister(String coreName, CoreDescriptor cd) throws InterruptedException, org.apache.zookeeper.KeeperException
InterruptedException
org.apache.zookeeper.KeeperException
public void createCollection(String collection) throws org.apache.zookeeper.KeeperException, InterruptedException
org.apache.zookeeper.KeeperException
InterruptedException
public void createCollectionZkNode(CloudDescriptor cd)
public ZkStateReader getZkStateReader()
public String getCoreNodeName(CoreDescriptor descriptor)
public void preRegister(CoreDescriptor cd)
public static void linkConfSet(SolrZkClient zkClient, String collection, String confSetName) throws org.apache.zookeeper.KeeperException, InterruptedException
org.apache.zookeeper.KeeperException
InterruptedException
public static void bootstrapConf(SolrZkClient zkClient, CoreContainer cc, String solrHome) throws IOException
IOException
public DistributedQueue getOverseerJobQueue()
public DistributedQueue getOverseerCollectionQueue()
public DistributedMap getOverseerRunningMap()
public DistributedMap getOverseerCompletedMap()
public DistributedMap getOverseerFailureMap()
public int getClientTimeout()
public Overseer getOverseer()
public LeaderElector getOverseerElector()
public static String trimLeadingAndTrailingSlashes(String in)
public void rejoinOverseerElection(String electionNode, boolean joinAtHead)
public void rejoinShardLeaderElection(SolrParams params)
public void checkOverseerDesignate()
public boolean ensureReplicaInLeaderInitiatedRecovery(String collection, String shardId, ZkCoreNodeProps replicaCoreProps, String leaderCoreNodeName, boolean forcePublishState, boolean retryOnConnLoss) throws org.apache.zookeeper.KeeperException, InterruptedException
org.apache.zookeeper.KeeperException
InterruptedException
public boolean isReplicaInRecoveryHandling(String replicaUrl)
public void removeReplicaFromLeaderInitiatedRecoveryHandling(String replicaUrl)
public Replica.State getLeaderInitiatedRecoveryState(String collection, String shardId, String coreNodeName)
public Map<String,Object> getLeaderInitiatedRecoveryStateObject(String collection, String shardId, String coreNodeName)
public String getLeaderInitiatedRecoveryZnodePath(String collection, String shardId)
public String getLeaderInitiatedRecoveryZnodePath(String collection, String shardId, String coreNodeName)
public void throwErrorIfReplicaReplaced(CoreDescriptor desc)
public void addOnReconnectListener(OnReconnect listener)
public static int persistConfigResourceToZooKeeper(ZkSolrResourceLoader zkLoader, int znodeVersion, String resourceName, byte[] content, boolean createIfNotExists)
public static void touchConfDir(ZkSolrResourceLoader zkLoader)
public void registerConfListenerForCore(String confDir, SolrCore core, Runnable listener)
public OnReconnect getConfigDirListener()
Copyright © 2000-2015 Apache Software Foundation. All Rights Reserved.