@ -20,6 +20,11 @@ public class OnlineUpdater extends BaseUpdater {
@Autowired
@Qualifier("jt_rw")
privateJdbcTemplatejdbcTemplate;
@Autowired
@Qualifier("jt_ro")
privateJdbcTemplatejdbcTemplate_ro;
privatefinalstaticintsleep_time=30*1000;
@Autowired
@ -45,6 +50,12 @@ public class OnlineUpdater extends BaseUpdater {
returntrue;
}
publiclonggetDifferentReplica(){
Longrw=jdbcTemplate.query("SELECT COUNT(*) FROM `servers_online`",(rs,n)->rs.getLong(1)).get(0);
Longro=jdbcTemplate.query("SELECT COUNT(*) FROM `servers_online`",(rs,n)->rs.getLong(1)).get(0);
returnMath.abs(rw-ro);
}
//CREATE TABLE `tf2.facti13`.`servers_online` (`id` INT NOT NULL AUTO_INCREMENT , `utime` INT NOT NULL , `player_count` INT NOT NULL , `max_players` INT NOT NULL , `server_id` VARCHAR(32) NOT NULL , PRIMARY KEY (`id`)) ENGINE = InnoDB;