mirror of https://github.com/tikv/client-java.git
update kvproto version (#128)
Signed-off-by: birdstorm <samuelwyf@hotmail.com>
This commit is contained in:
parent
7dfa1df52c
commit
10d8efbbc4
|
@ -18,7 +18,7 @@ CURRENT_DIR=`pwd`
|
|||
TIKV_CLIENT_HOME="$(cd "`dirname "$0"`"/..; pwd)"
|
||||
cd $TIKV_CLIENT_HOME
|
||||
|
||||
kvproto_hash=2cf9a243b8d589f345de1dbaa9eeffec6afbdc06
|
||||
kvproto_hash=b2375dcc80adc9c9423bd010592c045241f29d5a
|
||||
|
||||
raft_rs_hash=b9891b673573fad77ebcf9bbe0969cf945841926
|
||||
|
||||
|
|
|
@ -118,23 +118,26 @@ public class TiRegion implements Serializable {
|
|||
return meta.getPeers(followerIdx);
|
||||
}
|
||||
|
||||
private boolean isValidFollower(Peer peer) {
|
||||
return Metapb.PeerRole.valueOf(peer.getRole().getValueDescriptor()) == Metapb.PeerRole.Voter;
|
||||
}
|
||||
|
||||
private void chooseRandomFollower() {
|
||||
int cnt = meta.getPeersCount();
|
||||
followerIdx = new Random().nextInt(cnt);
|
||||
for (int retry = cnt - 1; retry > 0; retry--) {
|
||||
followerIdx = (followerIdx + 1) % cnt;
|
||||
Peer cur = meta.getPeers(followerIdx);
|
||||
if (cur.getIsLearner()) {
|
||||
continue;
|
||||
if (isValidFollower(cur)) {
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
public List<Peer> getLearnerList() {
|
||||
List<Peer> peers = new ArrayList<>();
|
||||
for (Peer peer : getMeta().getPeersList()) {
|
||||
if (peer.getIsLearner()) {
|
||||
if (isValidFollower(peer)) {
|
||||
peers.add(peer);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue