public class ZkShardTerms extends Object implements AutoCloseable
{
"replicaNodeName1" : 1,
"replicaNodeName2" : 2,
..
}
The values correspond to replicas are called terms. Only replicas with highest term value are considered up to date and be able to become leader and serve queries.
Terms can only updated in two strict ways:
Watcher.Event.KeeperState.Expired
eventConstructor and Description |
---|
ZkShardTerms(String collection,
String shard,
SolrZkClient zkClient) |
Modifier and Type | Method and Description |
---|---|
boolean |
canBecomeLeader(String coreNodeName)
Can this replica become leader?
|
void |
close() |
void |
doneRecovering(String coreNodeName)
Mark
coreNodeName as finished recovering |
void |
ensureHighestTermsAreNotZero()
When first updates come in, all replicas have some data now,
so we must switch from term 0 (registered) to 1 (have some data)
|
void |
ensureTermsIsHigher(String leader,
Set<String> replicasNeedingRecovery)
Ensure that terms are higher than some replica's terms.
|
long |
getHighestTerm() |
ShardTerms |
getShardTerms() |
long |
getTerm(String coreNodeName) |
boolean |
isRecovering(String name) |
void |
refreshTerms()
Fetch latest terms from ZK
|
boolean |
registered(String coreNodeName)
Did this replica registered its term? This is a sign to check f
|
void |
setTermEqualsToLeader(String coreNodeName)
Set a replica's term equals to leader's term, and remove recovering flag of a replica.
|
void |
setTermToZero(String coreNodeName)
Set a replica's term to 0.
|
boolean |
skipSendingUpdatesTo(String coreNodeName)
Should leader skip sending updates to this replica?
|
void |
startRecovering(String coreNodeName)
Mark
coreNodeName as recovering |
public ZkShardTerms(String collection, String shard, SolrZkClient zkClient)
public void ensureTermsIsHigher(String leader, Set<String> replicasNeedingRecovery)
leader
- coreNodeName of leaderreplicasNeedingRecovery
- set of replicas in which their terms should be lower than leader's termpublic ShardTerms getShardTerms()
public boolean canBecomeLeader(String coreNodeName)
coreNodeName
- of the replicapublic boolean skipSendingUpdatesTo(String coreNodeName)
coreNodeName
- of the replicapublic boolean registered(String coreNodeName)
coreNodeName
- of the replicapublic void close()
close
in interface AutoCloseable
public void setTermEqualsToLeader(String coreNodeName)
CollectionParams.CollectionAction.FORCELEADER
coreNodeName
- of the replicapublic void setTermToZero(String coreNodeName)
coreNodeName
- of the replicapublic void startRecovering(String coreNodeName)
coreNodeName
as recoveringpublic void doneRecovering(String coreNodeName)
coreNodeName
as finished recoveringpublic boolean isRecovering(String name)
public void ensureHighestTermsAreNotZero()
public long getHighestTerm()
public long getTerm(String coreNodeName)
public void refreshTerms()
Copyright © 2000-2021 Apache Software Foundation. All Rights Reserved.