back_recharge
zhangshanxue 2020-08-17 15:30:25 +08:00
parent 29f85c959b
commit d9bd59ea26
6 changed files with 20 additions and 12 deletions

View File

@ -49,9 +49,8 @@ public class GameApplication {
serverProperties = serverConfiguration.getServerProperties();
serverId = serverProperties.getId();
CoreSettings coreSettings = ConfigurableApplicationContextManager.getBean(CoreSettings.class);
GameApplication.areaId = coreSettings.getArea();
// GameApplication.areaId = coreSettings.getArea();
LOGGER.info("ServerProperties ->{},coreIp=>{}", serverProperties.toString());
MongoUtil.getInstence().init();

View File

@ -171,7 +171,6 @@ public class AreaManager {
if (System.currentTimeMillis() > execDate) {
serverArenaInfoManagerCache = serverArenaInfoManager;
int tmpAreaId = areaId;
//处理天才站结算
boolean isSuccess = RedisUtil.getInstence().tryGetDistributedLock(RedisKey.ServerArenaJob, "", Integer.toString(newAreaId), 500);
if (isSuccess) {
LOGGER.info(" serverArenaInfoManager get redis lock,the serverid={},the oldArea={},the newArea={}", GameApplication.serverId, areaId, newAreaId);
@ -236,7 +235,7 @@ public class AreaManager {
//查找本服所有排行榜
Set<String> keys =new HashSet<>();
Cursor<String> cursor =RedisUtil.getInstence().scan( GameApplication.serverId+ "*" + "RANK*", 200);
Cursor<String> cursor =RedisUtil.getInstence().scan( areaId+ "*" + "RANK*", 200);
while (cursor.hasNext()){
//找到一次就添加一次
keys.add(cursor.next());
@ -247,9 +246,9 @@ public class AreaManager {
Set<ZSetOperations.TypedTuple<String>> set= RedisUtil.getInstence().getAllZsetRange(k);
String newKey = k;
if(k.startsWith(String.valueOf(GameApplication.serverId))){
if(k.startsWith(String.valueOf(areaId))){
int length =k.length();
newKey = newAreaId+k.substring(String.valueOf(GameApplication.serverId).length(),length);
newKey = newAreaId+k.substring(String.valueOf(areaId).length(),length);
}
if(null != set){
for(ZSetOperations.TypedTuple<String> item : set){
@ -272,7 +271,7 @@ public class AreaManager {
//查找本服所有名称
Set<String> keys =new HashSet<>();
Cursor<String> cursor2 =RedisUtil.getInstence().scan( GameApplication.serverId+ ":" + RedisKey.C_User_Name_Key+"*", 200);
Cursor<String> cursor2 =RedisUtil.getInstence().scan( areaId+ ":" + RedisKey.C_User_Name_Key+"*", 200);
while (cursor2.hasNext()){
keys.add(cursor2.next());
}
@ -287,9 +286,9 @@ public class AreaManager {
int oldUid = Integer.parseInt(oldUserId.toString());
String newKey = k;
if(k.startsWith(String.valueOf(GameApplication.serverId))){
if(k.startsWith(String.valueOf(areaId))){
int length =k.length();
newKey = newAreaId+k.substring(String.valueOf(GameApplication.serverId).length(),length);
newKey = newAreaId+k.substring(String.valueOf(areaId).length(),length);
}
Object extUserId = RedisUtil.getInstence().get(newKey);
String tempName = newKey;

View File

@ -5,6 +5,7 @@ import com.ljsd.common.mogodb.MongoUpdateCache;
import com.ljsd.common.mogodb.MongoUpdateCacheThreadLocal;
import com.ljsd.common.mogodb.MongoUpdateImp;
import com.ljsd.jieling.db.mongo.core.ServerAreaInfoManager;
import com.ljsd.jieling.logic.dao.root.GlobalSystemControl;
import com.mongodb.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -116,7 +117,13 @@ public class LjsdMongoTemplate implements MongoUpdateImp {
public <T> T findById(int id, Class<T> clazz) throws Exception {
int serverIdByUid = AreaManager.getInstance().getServerIdByUid(id, GameApplication.serverId);
int serverIdByUid ;
if(clazz.equals(GlobalSystemControl.class)){
serverIdByUid = id;
}else {
serverIdByUid = AreaManager.getInstance().getServerIdByUid(id, GameApplication.serverId);
}
MongoTemplate otherMonogTemplate = getMongoTemplate(serverIdByUid);
return otherMonogTemplate.findById(id,clazz);
}

View File

@ -367,7 +367,7 @@ public class RedisKey {
}
if (withoutServerId) {
return GameApplication.areaId + Delimiter_colon + type + Delimiter_colon + String.valueOf(key);
return AreaManager.areaId + Delimiter_colon + type + Delimiter_colon + String.valueOf(key);
} else {
return GameApplication.serverId + Delimiter_colon + type + Delimiter_colon + String.valueOf(key);
}

View File

@ -4,6 +4,7 @@ import com.google.gson.Gson;
import com.ljsd.GameApplication;
import com.ljsd.jieling.bloody.UserBloodySnpInfo;
import com.ljsd.jieling.core.GlobalsDef;
import com.ljsd.jieling.db.mongo.AreaManager;
import com.ljsd.jieling.db.redis.RedisKey;
import com.ljsd.jieling.db.redis.RedisUtil;
import com.ljsd.jieling.exception.ErrorCode;
@ -74,7 +75,7 @@ public class RoomMatchRequestHandler extends BaseHandler{
}
snapUserFightInfo(user);
RedisUtil.getInstence().set(RedisKey.MATCH_UID_KEY + ":" + uid,gson.toJson("1"));
List<String> matchAddressInfos = RedisUtil.getInstence().getAllSetToList(RedisKey.MATCH_SERVER_INFO + ":" + GameApplication.areaId, String.class);
List<String> matchAddressInfos = RedisUtil.getInstence().getAllSetToList(RedisKey.MATCH_SERVER_INFO + ":" + AreaManager.areaId, String.class);
if(matchAddressInfos == null || matchAddressInfos.isEmpty()){
LOGGER.error("没有匹配服务器");
throw new ErrorCodeException(ErrorCode.newDefineCode("没有匹配服务器"));

View File

@ -69,7 +69,9 @@ public class QuestionLogic {
//按开启时间排序 获取最近开启的问卷
//删除过期的问卷
GlobalSystemControl globalSystemControl = MongoUtil.getInstence().getMyMongoTemplate().findById(GameApplication.serverId, GlobalSystemControl.class);
if (globalSystemControl == null) {
globalSystemControl = new GlobalSystemControl(GameApplication.serverId);
}