`
8821249
  • 浏览: 67457 次
  • 性别: Icon_minigender_1
  • 来自: 杭州
社区版块
存档分类
最新评论

关于容灾源码参考

    博客分类:
  • java
阅读更多
容灾、当tair挂了后,没5s自动尝试一次
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
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics