generated from root/miduo_server
非同一跨服服务器无法合服
parent
4e08c1a850
commit
7cbf3d5152
|
|
@ -1,5 +1,6 @@
|
|||
package com.jmfy.handler;
|
||||
|
||||
import com.jmfy.controller.ServerInfoController;
|
||||
import com.jmfy.dao.CHefuDao;
|
||||
import com.jmfy.dao.ServerInfoDao;
|
||||
import com.jmfy.model.CHefuInfo;
|
||||
|
|
@ -81,6 +82,13 @@ public class HeFuManager {
|
|||
// 从服列表
|
||||
Set<Integer> salveList = new HashSet<>();
|
||||
Arrays.stream(strings).forEach(v->salveList.add(Integer.parseInt(v)));
|
||||
|
||||
boolean verifyCross = verifyCross(masterId, salveList);
|
||||
if (!verifyCross){
|
||||
LOGGER.error("服务器列表非同一个跨服id,合服退出==>{}",cmd);
|
||||
return;
|
||||
}
|
||||
|
||||
// 处理数据库
|
||||
dealMongo(masterId, salveList);
|
||||
// 处理redis
|
||||
|
|
@ -99,8 +107,23 @@ public class HeFuManager {
|
|||
LOGGER.info("合服完成==============================/n");
|
||||
}
|
||||
|
||||
private static void addHeFuInfo(int masterId, Set<Integer> salveList) throws Exception {
|
||||
private static boolean verifyCross(int masterId, Set<Integer> salveList){
|
||||
int cross = RedisLogic.getGameServerGroupId(String.valueOf(masterId));
|
||||
for (Integer id : salveList) {
|
||||
int groupId = RedisLogic.getGameServerGroupId(String.valueOf(id));
|
||||
if (cross == 0){
|
||||
cross = groupId;
|
||||
continue;
|
||||
}
|
||||
if (cross != groupId){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private static void addHeFuInfo(int masterId, Set<Integer> salveList) throws Exception {
|
||||
HashSet<Integer> cloneSet = new HashSet<>(salveList);
|
||||
// 预防二次合服,删除之前得合服记录
|
||||
CHefuInfo hefu = hefuDao.findHefuByServerID(masterId);
|
||||
if (hefu != null){
|
||||
|
|
@ -109,7 +132,7 @@ public class HeFuManager {
|
|||
for (Integer id : salveList) {
|
||||
CHefuInfo hefu2 = hefuDao.findHefuByServerID(id);
|
||||
if (hefu2 != null){
|
||||
salveList.addAll(hefu2.getSlaveServerIds());
|
||||
cloneSet.addAll(hefu2.getSlaveServerIds());
|
||||
hefuDao.removeHefuInfo(hefu2);
|
||||
}
|
||||
}
|
||||
|
|
@ -120,7 +143,7 @@ public class HeFuManager {
|
|||
int hefuId = seqUtils.getSequence("hefu_id") + 10;
|
||||
hefuInfo.setId(hefuId);
|
||||
hefuInfo.setMasterServerId(masterId);
|
||||
hefuInfo.setSlaveServerIds(salveList);
|
||||
hefuInfo.setSlaveServerIds(cloneSet);
|
||||
hefuDao.upsertHefuInfo(hefuInfo);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue