服务器数据互通
parent
88142c8fcd
commit
808ebea12f
|
@ -24,6 +24,9 @@ public abstract class MongoBase implements Serializable {
|
|||
}
|
||||
|
||||
public void updateString(String fieldName, Object value) {
|
||||
if (rootId == 0) {
|
||||
return;
|
||||
}
|
||||
if(null == value){
|
||||
if("".equals(mongoKey)){
|
||||
MongoUpdateCacheThreadLocal.removeRequest(this, fieldName);
|
||||
|
|
|
@ -3,9 +3,12 @@ package com.ljsd.jieling.core;
|
|||
import com.ljsd.jieling.db.mongo.MongoUtil;
|
||||
import com.ljsd.jieling.db.mongo.core.ServerAreaInfoManager;
|
||||
import com.ljsd.jieling.logic.dao.SCdkInfo;
|
||||
import com.ljsd.jieling.logic.dao.root.UserInfo;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.data.mongodb.core.MongoTemplate;
|
||||
import org.springframework.data.mongodb.core.query.Criteria;
|
||||
import org.springframework.data.mongodb.core.query.Query;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
@ -34,6 +37,16 @@ public class CoreLogic {
|
|||
return coreMongoTemplate.findById(1,ServerAreaInfoManager.class);
|
||||
}
|
||||
|
||||
public int findServerIdFromMongo(int uid) {
|
||||
MongoTemplate coreMongoTemplate = MongoUtil.getCoreMongoTemplate();
|
||||
Query query = new Query(Criteria.where("_id").is(uid));
|
||||
UserInfo userInfo = coreMongoTemplate.findOne(query, UserInfo.class);
|
||||
if (userInfo != null) {
|
||||
return Integer.parseInt(userInfo.getServerId());
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public void checkCoreCdk() throws Exception{
|
||||
try {
|
||||
List<SCdkInfo> all = MongoUtil.getCoreMongoTemplate().findAll(SCdkInfo.class);
|
||||
|
|
|
@ -422,11 +422,19 @@ public class AreaManager {
|
|||
}
|
||||
|
||||
public int getServerIdByUid(int uid, int defaultServerId) {
|
||||
Integer serverIdByUid = RedisUtil.getInstence().getMapEntry(RedisKey.CUser_ServerId_Key,"",Integer.toString(uid),Integer.class);
|
||||
if (serverIdByUid == null){
|
||||
RedisUtil.getInstence().putMapEntry(RedisKey.CUser_ServerId_Key, "", Integer.toString(uid), defaultServerId);
|
||||
serverIdByUid = defaultServerId;
|
||||
// Integer serverIdByUid = RedisUtil.getInstence().getMapEntry(RedisKey.CUser_ServerId_Key,"",Integer.toString(uid),Integer.class);
|
||||
if (serverIds.contains(uid)) {
|
||||
return uid;
|
||||
}
|
||||
return serverIdByUid;
|
||||
Integer serverIdByUid = RedisUtil.getInstence().getObject(RedisKey.CUser_ServerId_Key, Integer.toString(uid), Integer.class, GlobalsDef.REDIS_OVER_TIME_DAY * 10);
|
||||
if (serverIdByUid != null) {
|
||||
return serverIdByUid;
|
||||
}
|
||||
int serverIdFromMongo = CoreLogic.getInstance().findServerIdFromMongo(uid);
|
||||
if (serverIdFromMongo > 0) {
|
||||
String key = RedisKey.CUser_ServerId_Key + RedisKey.Delimiter_colon + uid;
|
||||
RedisUtil.getInstence().setObject(key, Integer.toString(serverIdFromMongo), GlobalsDef.REDIS_OVER_TIME_DAY * 10);
|
||||
}
|
||||
return serverIdFromMongo;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -43,6 +43,9 @@ public class LjsdMongoTemplate implements MongoUpdateImp {
|
|||
// root.setBsave(true);
|
||||
int serverIdByUid = AreaManager.getInstance().getServerIdByUid(uid, GameApplication.serverId);
|
||||
MongoTemplate otherMonogTemplate = getMongoTemplate(serverIdByUid);
|
||||
if (otherMonogTemplate == null) {
|
||||
return;
|
||||
}
|
||||
otherMonogTemplate.save(obj);
|
||||
}
|
||||
|
||||
|
@ -157,6 +160,9 @@ public class LjsdMongoTemplate implements MongoUpdateImp {
|
|||
}
|
||||
|
||||
MongoTemplate otherMonogTemplate = getMongoTemplate(serverIdByUid);
|
||||
if (otherMonogTemplate == null) {
|
||||
return null;
|
||||
}
|
||||
return otherMonogTemplate.findById(id,clazz);
|
||||
}
|
||||
|
||||
|
|
|
@ -113,7 +113,7 @@ public class MongoUtil {
|
|||
return this.myMongoTemplate.findAllByCondition(query, User.class);
|
||||
}
|
||||
|
||||
public static MongoTemplate getCoreMongoTemplate() throws UnknownHostException {
|
||||
public static MongoTemplate getCoreMongoTemplate() {
|
||||
return MongoUtil.getInstence().coreMongoTemplate;
|
||||
}
|
||||
|
||||
|
|
|
@ -1410,7 +1410,7 @@ public class RedisUtil {
|
|||
if (key.length() == 8) {
|
||||
Integer serverId = RedisUtil.getInstence().getObject(RedisKey.CUser_ServerId_Key, key, Integer.class, -1);
|
||||
if (serverId != null && !AreaManager.getInstance().checkServerIdAllowPermit(serverId)) {
|
||||
result = -1 + RedisKey.Delimiter_colon + type + RedisKey.Delimiter_colon + key;
|
||||
result = serverId + RedisKey.Delimiter_colon + type + RedisKey.Delimiter_colon + key;
|
||||
}
|
||||
else if (serverId != null){
|
||||
result = serverId + RedisKey.Delimiter_colon + type + RedisKey.Delimiter_colon + key;
|
||||
|
|
|
@ -61,15 +61,11 @@ public class CrossServiceLogic {
|
|||
* 服务器初始化
|
||||
*/
|
||||
public static void serverInit() {
|
||||
try {
|
||||
MongoTemplate core = MongoUtil.getCoreMongoTemplate();
|
||||
List<CServerInfo> cServerInfos = core.findAll(CServerInfo.class);
|
||||
Map<Integer, CServerInfo> serverInfoMap = new HashMap<>(cServerInfos.size());
|
||||
cServerInfos.forEach(n -> serverInfoMap.put(n.getServerId(), n));
|
||||
cServerInfoMap = serverInfoMap;
|
||||
} catch (UnknownHostException e) {
|
||||
LOGGER.error("=========跨服服务器列表获取失败=======:{}", e.getMessage());
|
||||
}
|
||||
MongoTemplate core = MongoUtil.getCoreMongoTemplate();
|
||||
List<CServerInfo> cServerInfos = core.findAll(CServerInfo.class);
|
||||
Map<Integer, CServerInfo> serverInfoMap = new HashMap<>(cServerInfos.size());
|
||||
cServerInfos.forEach(n -> serverInfoMap.put(n.getServerId(), n));
|
||||
cServerInfoMap = serverInfoMap;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -28,12 +28,10 @@ import com.ljsd.jieling.logic.activity.eventhandler.PokemonFiveStarGetEventHandl
|
|||
import com.ljsd.jieling.logic.activity.fourChallenge.FourChallengeLogic;
|
||||
import com.ljsd.jieling.logic.dao.*;
|
||||
import com.ljsd.jieling.logic.dao.cross.CSPlayer;
|
||||
import com.ljsd.jieling.logic.dao.gm.ArenaOfHero;
|
||||
import com.ljsd.jieling.logic.dao.gm.ArenaOfUser;
|
||||
import com.ljsd.jieling.logic.dao.root.User;
|
||||
import com.ljsd.jieling.logic.expedition.ExpeditionLogic;
|
||||
import com.ljsd.jieling.logic.fight.CombatLogic;
|
||||
import com.ljsd.jieling.logic.fight.eventhandler.IFightEventProcesor;
|
||||
import com.ljsd.jieling.logic.fight.passiveSkillCal.PassiveskillCalEnum;
|
||||
import com.ljsd.jieling.logic.help.HelpHero;
|
||||
import com.ljsd.jieling.logic.help.HelpHeroLogic;
|
||||
|
@ -47,7 +45,6 @@ import com.ljsd.jieling.logic.store.BuyGoodsNewLogic;
|
|||
import com.ljsd.jieling.logic.store.newRechargeInfo.PushRechargeType;
|
||||
import com.ljsd.jieling.network.session.ISession;
|
||||
import com.ljsd.jieling.thrift.idl.CrossArenaManager;
|
||||
import com.ljsd.jieling.tools.Utils;
|
||||
import com.ljsd.jieling.util.CBean2Proto;
|
||||
import com.ljsd.jieling.util.ItemUtil;
|
||||
import com.ljsd.jieling.util.MessageUtil;
|
||||
|
@ -56,20 +53,15 @@ import config.*;
|
|||
import manager.STableManager;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.data.mongodb.core.aggregation.ArithmeticOperators;
|
||||
import rpc.protocols.*;
|
||||
import sun.security.ssl.Debug;
|
||||
import util.MathUtils;
|
||||
import util.StringUtil;
|
||||
import util.TimeUtils;
|
||||
|
||||
import java.awt.event.ItemEvent;
|
||||
import java.lang.reflect.Array;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.function.IntToDoubleFunction;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class HeroLogic {
|
||||
|
@ -3959,7 +3951,6 @@ public class HeroLogic {
|
|||
}
|
||||
hero.setIsLock(lockState);
|
||||
MessageUtil.sendMessage(session, 1, responseMsgId, null, true);
|
||||
LOGGER.info("the force={}", calHeoForce(user, hero, 0));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue