mirror of https://github.com/tikv/client-java.git
Signed-off-by: shiyuhang <1136742008@qq.com>
This commit is contained in:
parent
91b143988b
commit
e8feb23344
2
pom.xml
2
pom.xml
|
@ -3,7 +3,7 @@
|
|||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>org.tikv</groupId>
|
||||
<artifactId>tikv-client-java</artifactId>
|
||||
<version>3.3.0-SNAPSHOT</version>
|
||||
<version>3.3.4-SNAPSHOT</version>
|
||||
<packaging>jar</packaging>
|
||||
<name>TiKV Java Client</name>
|
||||
<description>A Java Client for TiKV</description>
|
||||
|
|
|
@ -228,12 +228,25 @@ public class RegionManager {
|
|||
|
||||
TiStore store = null;
|
||||
if (storeType == TiStoreType.TiKV) {
|
||||
Peer peer = region.getCurrentReplica();
|
||||
store = getStoreById(peer.getStoreId(), backOffer);
|
||||
// check from the first replica in case it recovers
|
||||
List<Peer> replicaList = region.getReplicaList();
|
||||
for (int i = 0; i < replicaList.size(); i++) {
|
||||
Peer peer = replicaList.get(i);
|
||||
store = getStoreById(peer.getStoreId(), backOffer);
|
||||
if (store.isReachable()) {
|
||||
// update replica's index
|
||||
region.setReplicaIdx(i);
|
||||
break;
|
||||
}
|
||||
logger.info("Store {} is unreachable, try to get the next replica", peer.getStoreId());
|
||||
}
|
||||
} else {
|
||||
List<TiStore> tiflashStores = new ArrayList<>();
|
||||
for (Peer peer : region.getLearnerList()) {
|
||||
TiStore s = getStoreById(peer.getStoreId(), backOffer);
|
||||
if (!s.isReachable()) {
|
||||
continue;
|
||||
}
|
||||
for (Metapb.StoreLabel label : s.getStore().getLabelsList()) {
|
||||
if (label.getKey().equals(storeType.getLabelKey())
|
||||
&& label.getValue().equals(storeType.getLabelValue())) {
|
||||
|
|
|
@ -126,6 +126,14 @@ public class TiRegion implements Serializable {
|
|||
return getCurrentReplica();
|
||||
}
|
||||
|
||||
public void setReplicaIdx(int idx) {
|
||||
replicaIdx = idx;
|
||||
}
|
||||
|
||||
public List<Peer> getReplicaList() {
|
||||
return replicaList;
|
||||
}
|
||||
|
||||
private boolean isLeader(Peer peer) {
|
||||
return getLeader().equals(peer);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue