容灾、当tair挂了后,没5s自动尝试一次
新tair配置推送下来时,errorCount重新开始计数
读在第一次读的时候从tair中读,写在最后一次写的时候commit
private boolean readFromTair() {
if (errorCount>1000) { //tair down了
if (lastReadTairTime > 5) {
errorCount--; //这里-1主要是readFromTair可能会+1,为了保证计数准确
readFromTair();
}
return false;
} else {
boolean isTairReadSucess = 读tair核心逻辑;
if (isTairReadSucess) {
errorCount--; //decrementIfGreaterThenZero
} else {
errorCount++;
}
lastReadTairTime = now();
return isTairReadSucess;
}
}
新tair配置推送下来时,errorCount重新开始计数
private void writeToTair() {
if (oldVersion != newVersion) { //每次有tair新的推送信息下来,errorCount重新开始计数
errorCount = 0;
oldVersion = newVersion;
}
if (errorCount<1000) { //tair down了
boolean isTairReadSucess = 写tair核心逻辑;
if (isTairReadSucess) {
errorCount--; //decrementIfGreaterThenZero
} else {
errorCount++;
}
}
}
读在第一次读的时候从tair中读,写在最后一次写的时候commit