generated from root/miduo_server
合服修改
parent
4f50faaf6d
commit
8b4f5049ef
|
|
@ -2,6 +2,7 @@ package com.jmfy.dao.impl;
|
|||
|
||||
import com.jmfy.controller.UserInfoController;
|
||||
import com.jmfy.dao.MailDao;
|
||||
import com.jmfy.handler.HeFuManager;
|
||||
import com.jmfy.model.*;
|
||||
import com.jmfy.redisProperties.RedisUserKey;
|
||||
import com.jmfy.utils.Connect;
|
||||
|
|
@ -53,10 +54,12 @@ public class MailDaoImpl implements MailDao {
|
|||
|
||||
String[] split = mail.getServerId().split(comma);
|
||||
for (String serverId:split) {
|
||||
int hefuServerId = HeFuManager.getHefuServerId(Integer.parseInt(serverId));
|
||||
serverId = String.valueOf(hefuServerId);
|
||||
Query query = new Query();
|
||||
//_id区分引号 "1"和1
|
||||
query.addCriteria(Criteria.where("_id").is(Integer.parseInt(serverId)));
|
||||
String dbName = MongoName.getMongoDBName(Integer.valueOf(serverId));
|
||||
query.addCriteria(Criteria.where("_id").is(hefuServerId));
|
||||
String dbName = MongoName.getMongoDBName(hefuServerId);
|
||||
MongoTemplate mongoTemplate = connect.getMongoTemplete(dbName);
|
||||
//有则更新,没有则新增
|
||||
WriteResult result = mongoTemplate.upsert(query, update, "mailingSystem");
|
||||
|
|
|
|||
|
|
@ -7,17 +7,17 @@ import com.jmfy.model.ServerInfo;
|
|||
import com.jmfy.utils.RedisUtil;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.data.redis.core.ZSetOperations;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.annotation.Resource;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.InputStreamReader;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.Set;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @Author hj
|
||||
|
|
@ -29,11 +29,38 @@ import java.util.Set;
|
|||
public class HeFuManager {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(HeFuManager.class);
|
||||
|
||||
@Resource
|
||||
private CHefuDao hefuDao;
|
||||
private static CHefuDao hefuDao;
|
||||
@Resource
|
||||
private ServerInfoDao serverInfoDao;
|
||||
|
||||
@Autowired
|
||||
public HeFuManager(CHefuDao hefuDao) {
|
||||
HeFuManager.hefuDao = hefuDao;
|
||||
}
|
||||
|
||||
private static final Map<Integer, Integer> hefuMap = new HashMap<>();
|
||||
|
||||
public static int getHefuServerId(int serverId) {
|
||||
return hefuMap.getOrDefault(serverId, serverId);
|
||||
}
|
||||
|
||||
@PostConstruct
|
||||
public void init(){
|
||||
try {
|
||||
List<CHefuInfo> hefuList = hefuDao.findHefuList();
|
||||
if (hefuList == null || hefuList.isEmpty()){
|
||||
return;
|
||||
}
|
||||
for (CHefuInfo info : hefuList) {
|
||||
for (Integer slaveServerId : info.getSlaveServerIds()) {
|
||||
hefuMap.put(slaveServerId, info.getMasterServerId());
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* mongo数据库信息
|
||||
*/
|
||||
|
|
@ -199,7 +226,7 @@ public class HeFuManager {
|
|||
slaveServer.setCoreName(masterServer.getCoreName());
|
||||
slaveServer.setIsSlave(1);
|
||||
serverInfoDao.updateServerInfo(slaveServer);
|
||||
LOGGER.info("处理IP和端口完成:{}",slaveServer.toString());
|
||||
LOGGER.info("处理IP和端口完成:{}", slaveServer);
|
||||
}
|
||||
|
||||
public static final String colon = ":";
|
||||
|
|
@ -213,7 +240,7 @@ public class HeFuManager {
|
|||
public static final String GUILD_CHALLENGE_RANK = "GUILD_CHALLENGE_RANK";//公会副本排行榜
|
||||
public static final String ARENA_RANK = "ARENA_RANK";//竞技场排行榜
|
||||
|
||||
public boolean dealRedis(int masterSID, int slowSID){
|
||||
public void dealRedis(int masterSID, int slowSID){
|
||||
LOGGER.info("开始处理redis排行榜===========,a:{},b:{}",masterSID,slowSID);
|
||||
// 战力排行榜处理
|
||||
defaultRankOfRedis(FORCE_CURR_RANK,masterSID,slowSID);
|
||||
|
|
@ -234,7 +261,6 @@ public class HeFuManager {
|
|||
// 竞技场排行榜处理
|
||||
deleteRankOfRedis(ARENA_RANK,masterSID);
|
||||
LOGGER.info("处理redis排行榜完成");
|
||||
return true;
|
||||
}
|
||||
|
||||
public void defaultRankOfRedis(String key, int masterSID, int slowSID){
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package com.jmfy.utils;
|
||||
|
||||
import com.jmfy.handler.HeFuManager;
|
||||
import com.jmfy.redisProperties.RedisUserKey;
|
||||
import com.jmfy.thrift.idl.RPCRequestGMIFace;
|
||||
import com.jmfy.thrift.idl.Result;
|
||||
|
|
@ -54,7 +55,8 @@ public class RPCClient {
|
|||
}
|
||||
|
||||
public static int sendWithServerId(int serverId,String cmd) {
|
||||
Result result = sendCmd(serverId, cmd);
|
||||
int hefuServerId = HeFuManager.getHefuServerId(serverId);
|
||||
Result result = sendCmd(hefuServerId, cmd);
|
||||
if (result == null || result.getResultCode() != 0){
|
||||
return -1;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue