public class ZkController extends Object
notes: loads everything on init, creates what's not there - further updates are prompted with Watches.
TODO: exceptions during close on attempts to update cloud state
Modifier and Type | Class and Description |
---|---|
static class |
ZkController.NotInClusterStateException
Thrown during pre register process if the replica is not present in clusterstate
|
static class |
ZkController.NotLeaderException
Thrown during leader initiated recovery process if current node is not leader
|
static class |
ZkController.ResourceModifiedInZkException |
Modifier and Type | Field and Description |
---|---|
static String |
COLLECTION_PARAM_PREFIX |
static String |
CONFIGNAME_PROP |
protected Overseer |
overseer |
ZkStateReader |
zkStateReader |
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).
|
boolean |
checkIfCoreNodeNameAlreadyExists(CoreDescriptor dcore) |
void |
checkOverseerDesignate() |
boolean |
claimAsyncId(String asyncId)
When an operation needs to be performed in an asynchronous mode, the asyncId needs
to be claimed by calling this method to make sure it's not duplicate (hasn't been
claimed by other request).
|
boolean |
clearAsyncId(String asyncId)
Clears an asyncId previously claimed by calling
claimAsyncId(String) |
void |
clearZkCollectionTerms() |
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) |
boolean |
ensureReplicaInLeaderInitiatedRecovery(CoreContainer container,
String collection,
String shardId,
ZkCoreNodeProps replicaCoreProps,
CoreDescriptor leaderCd,
boolean forcePublishState)
Deprecated.
|
String |
getBaseUrl() |
int |
getClientTimeout() |
ClusterState |
getClusterState() |
OnReconnect |
getConfigDirListener() |
byte[] |
getConfigFileData(String zkConfigName,
String fileName)
Returns config file data (in bytes)
|
CoreContainer |
getCoreContainer() |
String |
getCoreNodeName(CoreDescriptor descriptor) |
String |
getHostName() |
int |
getHostPort() |
int |
getLeaderConflictResolveWait() |
Replica.State |
getLeaderInitiatedRecoveryState(String collection,
String shardId,
String coreNodeName)
Deprecated.
|
Map<String,Object> |
getLeaderInitiatedRecoveryStateObject(String collection,
String shardId,
String coreNodeName)
Deprecated.
|
static String |
getLeaderInitiatedRecoveryZnodePath(String collection,
String shardId)
Deprecated.
|
static String |
getLeaderInitiatedRecoveryZnodePath(String collection,
String shardId,
String coreNodeName)
Deprecated.
|
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.
|
int |
getLeaderVoteWait() |
String |
getNodeName() |
Overseer |
getOverseer() |
OverseerTaskQueue |
getOverseerCollectionQueue() |
DistributedMap |
getOverseerCompletedMap() |
OverseerTaskQueue |
getOverseerConfigSetQueue() |
LeaderElector |
getOverseerElector() |
DistributedMap |
getOverseerFailureMap() |
ZkDistributedQueue |
getOverseerJobQueue() |
DistributedMap |
getOverseerRunningMap() |
ZkShardTerms |
getShardTerms(String collection,
String shardId) |
SolrCloudManager |
getSolrCloudManager() |
SolrZkClient |
getZkClient() |
String |
getZkServerAddress() |
ZkStateReader |
getZkStateReader() |
boolean |
isConnected() |
boolean |
isReplicaInRecoveryHandling(String replicaUrl)
Deprecated.
|
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,
boolean publishState) |
void |
publish(CoreDescriptor cd,
Replica.State state) |
void |
publish(CoreDescriptor cd,
Replica.State state,
boolean updateLastState,
boolean forcePublish)
Publish core state to overseer.
|
void |
publishAndWaitForDownStates() |
void |
publishNodeAsDown(String nodeName)
Best effort to set DOWN state for all replicas on node.
|
String |
register(String coreName,
CoreDescriptor desc,
boolean skipRecovery)
Register shard with ZooKeeper.
|
String |
register(String coreName,
CoreDescriptor desc,
boolean recoverReloadedCores,
boolean afterExpiration,
boolean skipRecovery)
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 |
removeEphemeralLiveNode() |
void |
removeOnReconnectListener(OnReconnect listener)
Removed a previously registered OnReconnect listener, such as when a core is removed or reloaded.
|
void |
removeReplicaFromLeaderInitiatedRecoveryHandling(String replicaUrl)
Deprecated.
|
void |
startReplicationFromLeader(String coreName,
boolean switchTransactionLog) |
void |
stopReplicationFromLeader(String coreName) |
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) |
void |
unregister(String coreName,
CoreDescriptor cd,
boolean removeCoreFromZk) |
void |
updateLeaderInitiatedRecoveryState(String collection,
String shardId,
String coreNodeName,
Replica.State state,
CoreDescriptor leaderCd,
boolean retryOnConnLoss)
Deprecated.
|
public static final String COLLECTION_PARAM_PREFIX
public static final String CONFIGNAME_PROP
public final ZkStateReader zkStateReader
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 SolrCloudManager getSolrCloudManager()
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, IOException
zkClient
- a SolrZkClientorg.apache.zookeeper.KeeperException
- if there is a Zookeeper errorInterruptedException
- on interruptIOException
public 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 void removeEphemeralLiveNode() throws org.apache.zookeeper.KeeperException, InterruptedException
org.apache.zookeeper.KeeperException
InterruptedException
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, boolean skipRecovery) throws Exception
Exception
public String register(String coreName, CoreDescriptor desc, boolean recoverReloadedCores, boolean afterExpiration, boolean skipRecovery) throws Exception
Exception
public void startReplicationFromLeader(String coreName, boolean switchTransactionLog) throws InterruptedException
InterruptedException
public void stopReplicationFromLeader(String coreName)
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 Exception
Exception
public void publish(CoreDescriptor cd, Replica.State state, boolean updateLastState, boolean forcePublish) throws Exception
Exception
public ZkShardTerms getShardTerms(String collection, String shardId)
public void clearZkCollectionTerms()
public void unregister(String coreName, CoreDescriptor cd) throws Exception
Exception
public void unregister(String coreName, CoreDescriptor cd, boolean removeCoreFromZk) throws Exception
Exception
public ZkStateReader getZkStateReader()
public String getCoreNodeName(CoreDescriptor descriptor)
public void preRegister(CoreDescriptor cd, boolean publishState)
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 ZkDistributedQueue getOverseerJobQueue()
public OverseerTaskQueue getOverseerCollectionQueue()
public OverseerTaskQueue getOverseerConfigSetQueue()
public DistributedMap getOverseerRunningMap()
public DistributedMap getOverseerCompletedMap()
public DistributedMap getOverseerFailureMap()
public boolean claimAsyncId(String asyncId) throws org.apache.zookeeper.KeeperException
clearAsyncId(String)
.
If this method returns false, no reservation has been made, and this asyncId can't
be used, since it's being used by another operation (currently or in the past)asyncId
- A string representing the asyncId of an operation. Can't be null.org.apache.zookeeper.KeeperException
public boolean clearAsyncId(String asyncId) throws org.apache.zookeeper.KeeperException
claimAsyncId(String)
asyncId
- A string representing the asyncId of an operation. Can't be null.org.apache.zookeeper.KeeperException
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 CoreContainer getCoreContainer()
@Deprecated public boolean ensureReplicaInLeaderInitiatedRecovery(CoreContainer container, String collection, String shardId, ZkCoreNodeProps replicaCoreProps, CoreDescriptor leaderCd, boolean forcePublishState) throws org.apache.zookeeper.KeeperException, InterruptedException
returns true if the node hosting the replica is still considered "live" by ZooKeeper; false means the node is not live either, so no point in trying to send recovery commands to it.
org.apache.zookeeper.KeeperException
InterruptedException
@Deprecated public boolean isReplicaInRecoveryHandling(String replicaUrl)
@Deprecated public void removeReplicaFromLeaderInitiatedRecoveryHandling(String replicaUrl)
@Deprecated public Replica.State getLeaderInitiatedRecoveryState(String collection, String shardId, String coreNodeName)
@Deprecated public Map<String,Object> getLeaderInitiatedRecoveryStateObject(String collection, String shardId, String coreNodeName)
@Deprecated public void updateLeaderInitiatedRecoveryState(String collection, String shardId, String coreNodeName, Replica.State state, CoreDescriptor leaderCd, boolean retryOnConnLoss)
@Deprecated public static String getLeaderInitiatedRecoveryZnodePath(String collection, String shardId)
@Deprecated public static String getLeaderInitiatedRecoveryZnodePath(String collection, String shardId, String coreNodeName)
public void throwErrorIfReplicaReplaced(CoreDescriptor desc)
public void addOnReconnectListener(OnReconnect listener)
public void removeOnReconnectListener(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()
public boolean checkIfCoreNodeNameAlreadyExists(CoreDescriptor dcore)
public void publishNodeAsDown(String nodeName)
nodeName
- to operate onCopyright © 2000-2018 Apache Software Foundation. All Rights Reserved.