Merge branch 'master' of http://60.1.1.230/backend/jieling_server
commit
9b051399b6
|
@ -9,6 +9,7 @@ import java.lang.reflect.Field;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
|
||||||
public class LjsdMongoTemplate {
|
public class LjsdMongoTemplate {
|
||||||
|
@ -78,6 +79,10 @@ public class LjsdMongoTemplate {
|
||||||
MongoUpdateCacheThreadLocal.update(this);
|
MongoUpdateCacheThreadLocal.update(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void concurrentDataUpdate(Map<String, Map<String, MongoUpdateCache.UpdateRequest>> updateRequestMap) throws Exception {
|
||||||
|
MongoUpdateCacheThreadLocal.concurrentDataUpdate(this,updateRequestMap);
|
||||||
|
}
|
||||||
|
|
||||||
public int inc(String collectionName, String id, String key){
|
public int inc(String collectionName, String id, String key){
|
||||||
DBCollection collection = mongoTemplate.getCollection(collectionName);
|
DBCollection collection = mongoTemplate.getCollection(collectionName);
|
||||||
BasicDBObject searchQuery = new BasicDBObject();
|
BasicDBObject searchQuery = new BasicDBObject();
|
||||||
|
|
|
@ -1,13 +1,17 @@
|
||||||
package com.ljsd.common.mogodb;
|
package com.ljsd.common.mogodb;
|
||||||
|
|
||||||
import com.ljsd.common.mogodb.util.BlockingUniqueQueue;
|
import com.ljsd.common.mogodb.util.BlockingUniqueQueue;
|
||||||
|
import com.ljsd.common.mogodb.util.ConcurrentDataMessage;
|
||||||
|
import com.ljsd.common.mogodb.util.MongoKeys;
|
||||||
import com.mongodb.BasicDBObject;
|
import com.mongodb.BasicDBObject;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.concurrent.BlockingQueue;
|
import java.util.concurrent.BlockingQueue;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
public class MongoUpdateCache {
|
public class MongoUpdateCache {
|
||||||
static class UpdateRequest {
|
|
||||||
|
public static class UpdateRequest {
|
||||||
MongoBase mongoBase;
|
MongoBase mongoBase;
|
||||||
String fullKey;
|
String fullKey;
|
||||||
Object value;
|
Object value;
|
||||||
|
@ -23,29 +27,33 @@ public class MongoUpdateCache {
|
||||||
|
|
||||||
//key:String, collection + ":" + id
|
//key:String, collection + ":" + id
|
||||||
private final Map<String, Map<String, UpdateRequest>> requestMap = new HashMap<>();
|
private final Map<String, Map<String, UpdateRequest>> requestMap = new HashMap<>();
|
||||||
static final BlockingQueue<Map<String, Map<String, UpdateRequest>>> logQueue = new BlockingUniqueQueue<>();
|
private final Map<String, Map<String, UpdateRequest>> updateDataMap = new HashMap<>();
|
||||||
|
|
||||||
protected void addUpdateRequest(MongoBase mongoBase, String fullKey, Object value, int opCode) {
|
protected void addUpdateRequest(MongoBase mongoBase, String fullKey, Object value, int opCode) {
|
||||||
String key = mongoBase.getRootCollection() + ":" + mongoBase.getRootId();
|
String key = mongoBase.getRootCollection() + ":" + mongoBase.getRootId();
|
||||||
Map<String, UpdateRequest> listRequest = requestMap.get(key);
|
Map<String, Map<String, UpdateRequest>> dataMap = requestMap;
|
||||||
|
if (MongoKeys.mongoKeyMap.containsKey(fullKey.split("\\.")[0]) || MongoKeys.mongoKeyMap.containsKey(fullKey)) {
|
||||||
|
dataMap = updateDataMap;
|
||||||
|
}
|
||||||
|
Map<String, UpdateRequest> listRequest = dataMap.get(key);
|
||||||
if (listRequest == null) {
|
if (listRequest == null) {
|
||||||
listRequest = new HashMap<>();
|
listRequest = new HashMap<>();
|
||||||
requestMap.put(key, listRequest);
|
dataMap.put(key, listRequest);
|
||||||
} else {
|
} else {
|
||||||
Iterator<Map.Entry<String, UpdateRequest>> it = listRequest.entrySet().iterator();
|
Iterator<Map.Entry<String, UpdateRequest>> it = listRequest.entrySet().iterator();
|
||||||
while (it.hasNext()) {
|
while (it.hasNext()) {
|
||||||
Map.Entry<String, UpdateRequest> entry = it.next();
|
Map.Entry<String, UpdateRequest> entry = it.next();
|
||||||
String key1 = entry.getKey();
|
String key1 = entry.getKey();
|
||||||
if(!fullKey.equals(key1)){
|
if (!fullKey.equals(key1)) {
|
||||||
//解决类似 item.1 item.11 问题
|
//解决类似 item.1 item.11 问题
|
||||||
if (fullKey.contains(key1)) {
|
if (fullKey.contains(key1)) {
|
||||||
if(checkOverride(key1,fullKey)){
|
if (checkOverride(key1, fullKey)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (key1.contains(fullKey)) {
|
if (key1.contains(fullKey)) {
|
||||||
if(checkOverride(key1,fullKey)){
|
if (checkOverride(key1, fullKey)) {
|
||||||
it.remove();
|
it.remove();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -67,15 +75,25 @@ public class MongoUpdateCache {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
protected void update(LjsdMongoTemplate ljsdMongoTemplate) {
|
||||||
|
updateMongoData(ljsdMongoTemplate, requestMap);
|
||||||
|
requestMap.clear();
|
||||||
|
if (updateDataMap.size() !=0){
|
||||||
|
ConcurrentDataMessage.addLogQueue(updateDataMap);
|
||||||
|
updateDataMap.clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected void update(LjsdMongoTemplate ljsdMongoTemplate) throws IllegalAccessException {
|
public void concurrentDataUpdate(LjsdMongoTemplate ljsdMongoTemplate, Map<String, Map<String, UpdateRequest>> updateRequestMap) {
|
||||||
|
updateMongoData(ljsdMongoTemplate, updateRequestMap);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateMongoData(LjsdMongoTemplate ljsdMongoTemplate, Map<String, Map<String, UpdateRequest>> updateRequestMap) {
|
||||||
BasicDBObject searchQuery = new BasicDBObject();
|
BasicDBObject searchQuery = new BasicDBObject();
|
||||||
|
for (Map.Entry<String, Map<String, UpdateRequest>> entry : updateRequestMap.entrySet()) {
|
||||||
for (Map.Entry<String, Map<String, UpdateRequest>> entry : requestMap.entrySet()) {
|
|
||||||
String[] strs = entry.getKey().split(":");
|
String[] strs = entry.getKey().split(":");
|
||||||
String collection = strs[0];
|
String collection = strs[0];
|
||||||
String id = strs[1];
|
String id = strs[1];
|
||||||
|
|
||||||
searchQuery.put("_id", Integer.parseInt(id));
|
searchQuery.put("_id", Integer.parseInt(id));
|
||||||
BasicDBObject valueDBObj = new BasicDBObject();
|
BasicDBObject valueDBObj = new BasicDBObject();
|
||||||
BasicDBObject dbobj = new BasicDBObject();
|
BasicDBObject dbobj = new BasicDBObject();
|
||||||
|
@ -98,12 +116,10 @@ public class MongoUpdateCache {
|
||||||
dbobj.append("$unset", removedbobj);
|
dbobj.append("$unset", removedbobj);
|
||||||
flag = true;
|
flag = true;
|
||||||
}
|
}
|
||||||
if (flag){
|
if (flag) {
|
||||||
ljsdMongoTemplate.updateValue(collection, searchQuery, dbobj);
|
ljsdMongoTemplate.updateValue(collection, searchQuery, dbobj);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
requestMap.clear();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,12 +1,11 @@
|
||||||
package com.ljsd.common.mogodb;
|
package com.ljsd.common.mogodb;
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public class MongoUpdateCacheThreadLocal {
|
public class MongoUpdateCacheThreadLocal {
|
||||||
private final static ThreadLocal<MongoUpdateCache> mongoUpdateCacheThreadLocal = new ThreadLocal<>();
|
private final static ThreadLocal<MongoUpdateCache> mongoUpdateCacheThreadLocal = new ThreadLocal<>();
|
||||||
|
|
||||||
private static MongoUpdateCache getMongoUpdateCache() {
|
public static MongoUpdateCache getMongoUpdateCache() {
|
||||||
MongoUpdateCache mongoUpdateCache = mongoUpdateCacheThreadLocal.get();
|
MongoUpdateCache mongoUpdateCache = mongoUpdateCacheThreadLocal.get();
|
||||||
if (mongoUpdateCache == null) {
|
if (mongoUpdateCache == null) {
|
||||||
mongoUpdateCache = new MongoUpdateCache();
|
mongoUpdateCache = new MongoUpdateCache();
|
||||||
|
@ -29,4 +28,9 @@ public class MongoUpdateCacheThreadLocal {
|
||||||
MongoUpdateCache mongoUpdateCache = getMongoUpdateCache();
|
MongoUpdateCache mongoUpdateCache = getMongoUpdateCache();
|
||||||
mongoUpdateCache.update(ljsdMongoTemplate);
|
mongoUpdateCache.update(ljsdMongoTemplate);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void concurrentDataUpdate(LjsdMongoTemplate ljsdMongoTemplate,Map<String, Map<String, MongoUpdateCache.UpdateRequest>> updateRequestMap) {
|
||||||
|
MongoUpdateCache mongoUpdateCache = getMongoUpdateCache();
|
||||||
|
mongoUpdateCache.concurrentDataUpdate(ljsdMongoTemplate, updateRequestMap);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,21 @@
|
||||||
|
package com.ljsd.common.mogodb.util;
|
||||||
|
|
||||||
|
import com.ljsd.common.mogodb.LjsdMongoTemplate;
|
||||||
|
import com.ljsd.common.mogodb.MongoUpdateCache;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.concurrent.BlockingQueue;
|
||||||
|
|
||||||
|
public class ConcurrentDataMessage {
|
||||||
|
// public static final BlockingQueue<Object> dataQueue = new BlockingUniqueQueue<>();
|
||||||
|
static BlockingQueue<Map<String, Map<String, MongoUpdateCache.UpdateRequest>>> dataQueue = new BlockingUniqueQueue<>();
|
||||||
|
//入队列
|
||||||
|
public static void addLogQueue(Map<String, Map<String, MongoUpdateCache.UpdateRequest>> info){
|
||||||
|
dataQueue.offer(info);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void manageData(LjsdMongoTemplate myMongoTemplate) throws Exception {
|
||||||
|
Map<String, Map<String, MongoUpdateCache.UpdateRequest>> take = ConcurrentDataMessage.dataQueue.take();
|
||||||
|
myMongoTemplate.concurrentDataUpdate(take);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,13 @@
|
||||||
|
package com.ljsd.common.mogodb.util;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class MongoKeys {
|
||||||
|
|
||||||
|
public static Map<String, Integer> mongoKeyMap = new HashMap<>();
|
||||||
|
|
||||||
|
public static void initmongoKey() {
|
||||||
|
mongoKeyMap.put("friendManager",1);
|
||||||
|
}
|
||||||
|
}
|
|
@ -6,6 +6,7 @@
|
||||||
<!-- 定义日志文件 输入位置 -->
|
<!-- 定义日志文件 输入位置 -->
|
||||||
<property name="log_dir" value="/data/jl_logs"/>
|
<property name="log_dir" value="/data/jl_logs"/>
|
||||||
<property name="log_tdir" value="/data/jl_tlogs"/>
|
<property name="log_tdir" value="/data/jl_tlogs"/>
|
||||||
|
<property name="log_bdir" value="/data/jl_blogs"/>
|
||||||
<!-- 日志最大的历史 30天 -->
|
<!-- 日志最大的历史 30天 -->
|
||||||
<property name="maxHistory" value="30"/>
|
<property name="maxHistory" value="30"/>
|
||||||
|
|
||||||
|
@ -74,17 +75,28 @@
|
||||||
<maxHistory>${maxHistory}</maxHistory>
|
<maxHistory>${maxHistory}</maxHistory>
|
||||||
<maxFileSize>200MB</maxFileSize>
|
<maxFileSize>200MB</maxFileSize>
|
||||||
</rollingPolicy>
|
</rollingPolicy>
|
||||||
|
</appender>
|
||||||
|
|
||||||
<!-- 按照固定窗口模式生成日志文件,当文件大于20MB时,生成新的日志文件。窗口大小是1到3,当保存了3个归档文件后,将覆盖最早的日志。
|
<appender name="file_blog" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||||
<rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
|
<!--<Encoding>UTF-8</Encoding>-->
|
||||||
<fileNamePattern>${log_dir}/%d{yyyy-MM-dd}/.log.zip</fileNamePattern>
|
<!-- 过滤器,只记录WARN级别的日志 -->
|
||||||
<minIndex>1</minIndex>
|
<encoder charset="UTF-8">
|
||||||
<maxIndex>3</maxIndex>
|
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS}:%msg%n</pattern>
|
||||||
</rollingPolicy> -->
|
</encoder>
|
||||||
<!-- 查看当前活动文件的大小,如果超过指定大小会告知RollingFileAppender 触发当前活动文件滚动
|
<!-- <filter class="ch.qos.logback.classic.filter.LevelFilter">
|
||||||
<triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
|
<level>ERROR</level>
|
||||||
<maxFileSize>5KB</maxFileSize>
|
<onMatch>ACCEPT</onMatch>
|
||||||
</triggeringPolicy>-->
|
<onMismatch>DENY</onMismatch>
|
||||||
|
</filter>-->
|
||||||
|
<!-- 最常用的滚动策略,它根据时间来制定滚动策略.既负责滚动也负责出发滚动 -->
|
||||||
|
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
|
||||||
|
<!--日志输出位置 可相对、和绝对路径 -->
|
||||||
|
<fileNamePattern>${log_bdir}/%d{yyyy-MM-dd}/blog%i.log</fileNamePattern>
|
||||||
|
<!-- 可选节点,控制保留的归档文件的最大数量,超出数量就删除旧文件假设设置每个月滚动,且<maxHistory>是6,
|
||||||
|
则只保存最近6个月的文件,删除之前的旧文件。注意,删除旧文件是,那些为了归档而创建的目录也会被删除-->
|
||||||
|
<maxHistory>${maxHistory}</maxHistory>
|
||||||
|
<maxFileSize>200MB</maxFileSize>
|
||||||
|
</rollingPolicy>
|
||||||
</appender>
|
</appender>
|
||||||
|
|
||||||
|
|
||||||
|
@ -148,6 +160,10 @@
|
||||||
<appender-ref ref="file_tlog"/>
|
<appender-ref ref="file_tlog"/>
|
||||||
</logger>
|
</logger>
|
||||||
|
|
||||||
|
<logger name="BackErrorLog" additivity="false">
|
||||||
|
<appender-ref ref="file_blog"/>
|
||||||
|
</logger>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<root level="INFO">
|
<root level="INFO">
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package com.ljsd;
|
package com.ljsd;
|
||||||
|
|
||||||
|
import com.ljsd.common.mogodb.util.MongoKeys;
|
||||||
import com.ljsd.jieling.config.ServerConfig;
|
import com.ljsd.jieling.config.ServerConfig;
|
||||||
import com.ljsd.jieling.config.json.ServerConfiguration;
|
import com.ljsd.jieling.config.json.ServerConfiguration;
|
||||||
import com.ljsd.jieling.config.json.ServerProperties;
|
import com.ljsd.jieling.config.json.ServerProperties;
|
||||||
|
@ -19,6 +20,7 @@ import com.ljsd.jieling.network.NettyServerAutoConfiguration;
|
||||||
import com.ljsd.jieling.network.server.ProtocolsManager;
|
import com.ljsd.jieling.network.server.ProtocolsManager;
|
||||||
import com.ljsd.jieling.network.session.ISessionFactory;
|
import com.ljsd.jieling.network.session.ISessionFactory;
|
||||||
import com.ljsd.jieling.thread.ThreadManager;
|
import com.ljsd.jieling.thread.ThreadManager;
|
||||||
|
import com.ljsd.jieling.thread.task.MongoDataHandlerTask;
|
||||||
import com.ljsd.jieling.util.KeyGenUtils;
|
import com.ljsd.jieling.util.KeyGenUtils;
|
||||||
import com.ljsd.jieling.util.SensitivewordFilter;
|
import com.ljsd.jieling.util.SensitivewordFilter;
|
||||||
import com.ljsd.jieling.util.TimeUtils;
|
import com.ljsd.jieling.util.TimeUtils;
|
||||||
|
@ -82,12 +84,14 @@ public class GameApplication {
|
||||||
// HttpPool.init();
|
// HttpPool.init();
|
||||||
|
|
||||||
STableManager.initialize("com.ljsd.jieling.config");
|
STableManager.initialize("com.ljsd.jieling.config");
|
||||||
|
//mongo异步数据处理线程
|
||||||
|
MongoDataHandlerTask.init(configurableApplicationContext);
|
||||||
//初始化邮件
|
//初始化邮件
|
||||||
MailingSystemManager.init(configurableApplicationContext);
|
MailingSystemManager.init(configurableApplicationContext);
|
||||||
ThreadManager threadManager = ThreadManager.getInstance();
|
ThreadManager threadManager = ThreadManager.getInstance();
|
||||||
threadManager.init(configurableApplicationContext);
|
threadManager.init(configurableApplicationContext);
|
||||||
MapLogic.getInstance().init(configurableApplicationContext);
|
MapLogic.getInstance().init(configurableApplicationContext);
|
||||||
|
MongoKeys.initmongoKey();
|
||||||
SensitivewordFilter.init();
|
SensitivewordFilter.init();
|
||||||
HttpPool.init();
|
HttpPool.init();
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,6 @@ import com.ljsd.jieling.util.http.HttpPool;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.BlockingQueue;
|
import java.util.concurrent.BlockingQueue;
|
||||||
import java.util.concurrent.CopyOnWriteArrayList;
|
|
||||||
|
|
||||||
public class DataMessageUtils {
|
public class DataMessageUtils {
|
||||||
|
|
||||||
|
|
|
@ -107,7 +107,7 @@ public class HandlerLogicThread extends Thread{
|
||||||
return;
|
return;
|
||||||
}*/
|
}*/
|
||||||
}
|
}
|
||||||
|
long curTimeMillis = System.currentTimeMillis();
|
||||||
if(msgId != MessageTypeProto.MessageType.GET_CHAT_MESSAGE_REQUEST_VALUE){
|
if(msgId != MessageTypeProto.MessageType.GET_CHAT_MESSAGE_REQUEST_VALUE){
|
||||||
LOGGER.info("doWork->uid={},mType={};start", userId, MessageTypeProto.MessageType.valueOf(msgId));
|
LOGGER.info("doWork->uid={},mType={};start", userId, MessageTypeProto.MessageType.valueOf(msgId));
|
||||||
}
|
}
|
||||||
|
@ -115,11 +115,12 @@ public class HandlerLogicThread extends Thread{
|
||||||
MissionEventDistributor.requestStart();
|
MissionEventDistributor.requestStart();
|
||||||
baseHandler.execute(session, packetNetData);
|
baseHandler.execute(session, packetNetData);
|
||||||
MissionEventDistributor.requestEnd(session,true);
|
MissionEventDistributor.requestEnd(session,true);
|
||||||
if(msgId != MessageTypeProto.MessageType.GET_CHAT_MESSAGE_REQUEST_VALUE){
|
|
||||||
LOGGER.info("doWork->uid={},mType={};end", userId, MessageTypeProto.MessageType.valueOf(msgId));
|
|
||||||
}
|
|
||||||
|
|
||||||
MongoUtil.getInstence().lastUpdate();
|
MongoUtil.getInstence().lastUpdate();
|
||||||
|
if(msgId != MessageTypeProto.MessageType.GET_CHAT_MESSAGE_REQUEST_VALUE){
|
||||||
|
long useTime = System.currentTimeMillis() - curTimeMillis;
|
||||||
|
LOGGER.info("doWork->uid={},mType={},useTime={},;end", userId, MessageTypeProto.MessageType.valueOf(msgId),useTime);
|
||||||
|
}
|
||||||
|
|
||||||
}catch (Exception e){
|
}catch (Exception e){
|
||||||
LOGGER.error("",e);
|
LOGGER.error("",e);
|
||||||
|
|
|
@ -510,7 +510,7 @@ public class ArenaLogic {
|
||||||
.build());
|
.build());
|
||||||
}
|
}
|
||||||
User user = UserManager.getUser(uid);
|
User user = UserManager.getUser(uid);
|
||||||
user.getPlayerInfoManager().removeRed(GlobalsDef.SHARE_BOSS_RED_TYPE);
|
user.getPlayerInfoManager().removeRed(GlobalsDef.ARENA_CHALLENGE_TYPE);
|
||||||
ArenaInfoProto.ArenaRecordInfoResponse build = ArenaInfoProto.ArenaRecordInfoResponse.newBuilder().addAllArenaRecordInfo(arenaRecordInfos).build();
|
ArenaInfoProto.ArenaRecordInfoResponse build = ArenaInfoProto.ArenaRecordInfoResponse.newBuilder().addAllArenaRecordInfo(arenaRecordInfos).build();
|
||||||
MessageUtil.sendMessage(iSession,1, MessageTypeProto.MessageType.ARENA_DEFENSE_RESPONSE_VALUE,build,true);
|
MessageUtil.sendMessage(iSession,1, MessageTypeProto.MessageType.ARENA_DEFENSE_RESPONSE_VALUE,build,true);
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -26,8 +26,6 @@ import org.luaj.vm2.LuaValue;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.data.redis.core.ZSetOperations;
|
import org.springframework.data.redis.core.ZSetOperations;
|
||||||
import sun.misc.MessageUtils;
|
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
public class CombatLogic {
|
public class CombatLogic {
|
||||||
|
@ -534,7 +532,7 @@ public class CombatLogic {
|
||||||
RedisUtil.getInstence().removeMapEntrys(RedisKey.ADVENTRUEN_BOSS_OWN,"",removeAdventureBosseInfo.toArray());
|
RedisUtil.getInstence().removeMapEntrys(RedisKey.ADVENTRUEN_BOSS_OWN,"",removeAdventureBosseInfo.toArray());
|
||||||
}
|
}
|
||||||
User user = UserManager.getUser(uid);
|
User user = UserManager.getUser(uid);
|
||||||
user.getPlayerInfoManager().removeRed(GlobalsDef.ARENA_CHALLENGE_TYPE);
|
user.getPlayerInfoManager().removeRed(GlobalsDef.SHARE_BOSS_RED_TYPE);
|
||||||
}
|
}
|
||||||
MessageUtil.sendMessage(session,1, MessageTypeProto.MessageType.ADVENTURE_BOSSHURT_RESPONSE_VALUE,builder.build(),true);
|
MessageUtil.sendMessage(session,1, MessageTypeProto.MessageType.ADVENTURE_BOSSHURT_RESPONSE_VALUE,builder.build(),true);
|
||||||
}
|
}
|
||||||
|
@ -592,6 +590,7 @@ public class CombatLogic {
|
||||||
AdventureBoss adventureBoss = new AdventureBoss(bossId,bossGroupID,arenaID,levle,uid,now,totalHp,hps);
|
AdventureBoss adventureBoss = new AdventureBoss(bossId,bossGroupID,arenaID,levle,uid,now,totalHp,hps);
|
||||||
RedisUtil.getInstence().putMapEntry(RedisKey.ADVENTRUEN_BOSS_INFO,"",bossId,adventureBoss);
|
RedisUtil.getInstence().putMapEntry(RedisKey.ADVENTRUEN_BOSS_INFO,"",bossId,adventureBoss);
|
||||||
RedisUtil.getInstence().putMapEntry(RedisKey.ADVENTRUEN_BOSS_OWN,Integer.toString(uid),bossId,0);
|
RedisUtil.getInstence().putMapEntry(RedisKey.ADVENTRUEN_BOSS_OWN,Integer.toString(uid),bossId,0);
|
||||||
|
MessageUtil.sendRedIndication(uid,GlobalsDef.SHARE_BOSS_RED_TYPE);
|
||||||
}
|
}
|
||||||
adventureStateInfo.setBossId(bossId);
|
adventureStateInfo.setBossId(bossId);
|
||||||
adventureStateInfo.setBossGroupId(bossGroupID);
|
adventureStateInfo.setBossGroupId(bossGroupID);
|
||||||
|
|
|
@ -1,10 +1,7 @@
|
||||||
package com.ljsd.jieling.thread;
|
package com.ljsd.jieling.thread;
|
||||||
|
|
||||||
|
|
||||||
import com.ljsd.jieling.thread.task.DataReportTask;
|
import com.ljsd.jieling.thread.task.*;
|
||||||
import com.ljsd.jieling.thread.task.MinuteTask;
|
|
||||||
import com.ljsd.jieling.thread.task.PlatConfigureTask;
|
|
||||||
import com.ljsd.jieling.thread.task.RetrySendIndicationThread;
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.context.ConfigurableApplicationContext;
|
import org.springframework.context.ConfigurableApplicationContext;
|
||||||
|
@ -25,6 +22,7 @@ public class ThreadManager {
|
||||||
|
|
||||||
private static PlatConfigureTask platConfigureTask;
|
private static PlatConfigureTask platConfigureTask;
|
||||||
private static DataReportTask dataReportTask;
|
private static DataReportTask dataReportTask;
|
||||||
|
private static MongoDataHandlerTask mongoDataHandlerTask;
|
||||||
|
|
||||||
public static int SLEEP_INTEVAL_TIME = 60; //每1分钟检查一次
|
public static int SLEEP_INTEVAL_TIME = 60; //每1分钟检查一次
|
||||||
|
|
||||||
|
@ -37,8 +35,10 @@ public class ThreadManager {
|
||||||
public void init(ConfigurableApplicationContext configurableApplicationContext) {
|
public void init(ConfigurableApplicationContext configurableApplicationContext) {
|
||||||
|
|
||||||
platConfigureTask = configurableApplicationContext.getBean(PlatConfigureTask.class);
|
platConfigureTask = configurableApplicationContext.getBean(PlatConfigureTask.class);
|
||||||
DataReportTask dataReportTask = new DataReportTask();
|
mongoDataHandlerTask = configurableApplicationContext.getBean(MongoDataHandlerTask.class);
|
||||||
dataReportTask.start();
|
dataReportTask = configurableApplicationContext.getBean(DataReportTask.class);
|
||||||
|
// DataReportTask dataReportTask = new DataReportTask();
|
||||||
|
// dataReportTask.start();
|
||||||
go();
|
go();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -84,6 +84,8 @@ public class ThreadManager {
|
||||||
int delayForMinute = 60 - (now%60);
|
int delayForMinute = 60 - (now%60);
|
||||||
LOGGER.info("delayForMinute---->>>>{}" ,delayForMinute);
|
LOGGER.info("delayForMinute---->>>>{}" ,delayForMinute);
|
||||||
scheduledExecutor.scheduleAtFixedRate(platConfigureTask, 10, SLEEP_INTEVAL_TIME, TimeUnit.SECONDS);
|
scheduledExecutor.scheduleAtFixedRate(platConfigureTask, 10, SLEEP_INTEVAL_TIME, TimeUnit.SECONDS);
|
||||||
|
scheduledExecutor.scheduleAtFixedRate(dataReportTask, 10, SLEEP_INTEVAL_TIME, TimeUnit.SECONDS);
|
||||||
|
scheduledExecutor.scheduleAtFixedRate(mongoDataHandlerTask, 10, SLEEP_INTEVAL_TIME, TimeUnit.SECONDS);
|
||||||
scheduledExecutor.scheduleAtFixedRate(new MinuteTask(), delayForMinute, 60, TimeUnit.SECONDS);
|
scheduledExecutor.scheduleAtFixedRate(new MinuteTask(), delayForMinute, 60, TimeUnit.SECONDS);
|
||||||
scheduledExecutor.scheduleAtFixedRate(new Thread(){
|
scheduledExecutor.scheduleAtFixedRate(new Thread(){
|
||||||
public void run () {
|
public void run () {
|
||||||
|
|
|
@ -5,10 +5,11 @@ import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import java.util.concurrent.ExecutorService;
|
import java.util.concurrent.ExecutorService;
|
||||||
import java.util.concurrent.Executors;
|
import java.util.concurrent.Executors;
|
||||||
|
@Component
|
||||||
public class DataReportTask extends Thread {
|
public class DataReportTask extends Thread {
|
||||||
|
|
||||||
public DataReportTask(){
|
public DataReportTask(){
|
||||||
setName("DataReportTaskThread");
|
setName("DataReportTask");
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
|
|
@ -0,0 +1,38 @@
|
||||||
|
package com.ljsd.jieling.thread.task;
|
||||||
|
|
||||||
|
import com.ljsd.common.mogodb.LjsdMongoTemplate;
|
||||||
|
import com.ljsd.common.mogodb.util.ConcurrentDataMessage;
|
||||||
|
import org.springframework.context.ConfigurableApplicationContext;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.concurrent.ExecutorService;
|
||||||
|
import java.util.concurrent.Executors;
|
||||||
|
@Component
|
||||||
|
public class MongoDataHandlerTask extends Thread {
|
||||||
|
private static LjsdMongoTemplate myMongoTemplate;
|
||||||
|
public MongoDataHandlerTask(){
|
||||||
|
setName("MongoDataHandlerTask");
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
while (true) {
|
||||||
|
try {
|
||||||
|
ConcurrentDataMessage.manageData(myMongoTemplate);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public static void init(ConfigurableApplicationContext configurableApplicationContext){
|
||||||
|
myMongoTemplate =configurableApplicationContext.getBean(LjsdMongoTemplate.class);
|
||||||
|
// startTlogThread();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void startTlogThread(){
|
||||||
|
ExecutorService pool = Executors.newCachedThreadPool();
|
||||||
|
for (int i = 0; i < 1 ; i++){
|
||||||
|
MongoDataHandlerTask myThread = new MongoDataHandlerTask();
|
||||||
|
pool.execute(myThread);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,7 +1,6 @@
|
||||||
package com.ljsd.jieling.thread.task;
|
package com.ljsd.jieling.thread.task;
|
||||||
|
|
||||||
import com.ljsd.jieling.config.json.ConfMessage;
|
import com.ljsd.jieling.config.json.ConfMessage;
|
||||||
import com.ljsd.jieling.util.TimeUtils;
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
@ -10,9 +9,7 @@ import java.io.IOException;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
public class PlatConfigureTask implements Runnable {
|
public class PlatConfigureTask implements Runnable {
|
||||||
|
|
||||||
private static final Logger LOGGER = LoggerFactory.getLogger(PlatConfigureTask.class);
|
private static final Logger LOGGER = LoggerFactory.getLogger(PlatConfigureTask.class);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
doLogic();
|
doLogic();
|
||||||
|
|
|
@ -71,7 +71,7 @@ public class MessageUtil {
|
||||||
if(session!=null){
|
if(session!=null){
|
||||||
PlayerInfoProto.RedPointInfo redPointInfo = PlayerInfoProto.RedPointInfo.newBuilder().setType(redType).build();
|
PlayerInfoProto.RedPointInfo redPointInfo = PlayerInfoProto.RedPointInfo.newBuilder().setType(redType).build();
|
||||||
MessageUtil.sendIndicationMessage(session,1,MessageTypeProto.MessageType.SEND_RED_POINT_INDICATION_VALUE,redPointInfo,true);
|
MessageUtil.sendIndicationMessage(session,1,MessageTypeProto.MessageType.SEND_RED_POINT_INDICATION_VALUE,redPointInfo,true);
|
||||||
}else{
|
}
|
||||||
if(redType == GlobalsDef.MAIL_RED_TYPE){
|
if(redType == GlobalsDef.MAIL_RED_TYPE){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -80,7 +80,6 @@ public class MessageUtil {
|
||||||
reds.add(redType);
|
reds.add(redType);
|
||||||
user.getPlayerInfoManager().setReds(reds);
|
user.getPlayerInfoManager().setReds(reds);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public static void sendBagIndication(int sendUid,int type, List<CommonProto.Item> sendToFront) {
|
public static void sendBagIndication(int sendUid,int type, List<CommonProto.Item> sendToFront) {
|
||||||
ISession session = OnlineUserManager.sessionMap.get(sendUid);
|
ISession session = OnlineUserManager.sessionMap.get(sendUid);
|
||||||
|
|
|
@ -20,7 +20,8 @@ public class HttpPool {
|
||||||
private static PoolingHttpClientConnectionManager poolConnection = new PoolingHttpClientConnectionManager();
|
private static PoolingHttpClientConnectionManager poolConnection = new PoolingHttpClientConnectionManager();
|
||||||
private static CloseableHttpClient httpclient;
|
private static CloseableHttpClient httpclient;
|
||||||
private static final Logger LOGGER = LoggerFactory.getLogger(HttpPool.class);
|
private static final Logger LOGGER = LoggerFactory.getLogger(HttpPool.class);
|
||||||
private static int maxSendTimes = 2;
|
private static final Logger BackErrorLog = LoggerFactory.getLogger("BackErrorLog");
|
||||||
|
private static int maxSendTimes = 3;
|
||||||
private static int sendIntervalTime = 1000;
|
private static int sendIntervalTime = 1000;
|
||||||
private static String charset = "UTF-8";
|
private static String charset = "UTF-8";
|
||||||
|
|
||||||
|
@ -39,6 +40,7 @@ public class HttpPool {
|
||||||
HttpPost httpPost = new HttpPost(url);
|
HttpPost httpPost = new HttpPost(url);
|
||||||
HttpResponse httpResponse;
|
HttpResponse httpResponse;
|
||||||
int sendTimes = 0;
|
int sendTimes = 0;
|
||||||
|
boolean needBack = true;
|
||||||
do {
|
do {
|
||||||
try {
|
try {
|
||||||
StringEntity stringEntity = new StringEntity(info, charset);
|
StringEntity stringEntity = new StringEntity(info, charset);
|
||||||
|
@ -50,6 +52,7 @@ public class HttpPool {
|
||||||
EntityUtils.consume(responseEntity);
|
EntityUtils.consume(responseEntity);
|
||||||
int statusCode = httpResponse.getStatusLine().getStatusCode();
|
int statusCode = httpResponse.getStatusLine().getStatusCode();
|
||||||
if (statusCode >= 200 && statusCode < 300) {
|
if (statusCode >= 200 && statusCode < 300) {
|
||||||
|
needBack = false;
|
||||||
LOGGER.debug("Http Send,第" + (sendTimes + 1) + "次调用成功,返回码为:[" + statusCode + "]");
|
LOGGER.debug("Http Send,第" + (sendTimes + 1) + "次调用成功,返回码为:[" + statusCode + "]");
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
|
@ -66,11 +69,14 @@ public class HttpPool {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
LOGGER.error("Http Send error",e);
|
||||||
}finally {
|
}finally {
|
||||||
sendTimes ++ ;
|
sendTimes ++ ;
|
||||||
}
|
}
|
||||||
} while (sendTimes < maxSendTimes);
|
} while (sendTimes < maxSendTimes);
|
||||||
|
if(needBack){
|
||||||
|
BackErrorLog.info(info);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void main (String [] args){
|
public static void main (String [] args){
|
||||||
|
|
Loading…
Reference in New Issue