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.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
public class LjsdMongoTemplate {
|
||||
|
@ -78,6 +79,10 @@ public class LjsdMongoTemplate {
|
|||
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){
|
||||
DBCollection collection = mongoTemplate.getCollection(collectionName);
|
||||
BasicDBObject searchQuery = new BasicDBObject();
|
||||
|
|
|
@ -1,13 +1,17 @@
|
|||
package com.ljsd.common.mogodb;
|
||||
|
||||
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 java.util.*;
|
||||
import java.util.concurrent.BlockingQueue;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
public class MongoUpdateCache {
|
||||
static class UpdateRequest {
|
||||
|
||||
public static class UpdateRequest {
|
||||
MongoBase mongoBase;
|
||||
String fullKey;
|
||||
Object value;
|
||||
|
@ -23,38 +27,42 @@ public class MongoUpdateCache {
|
|||
|
||||
//key:String, collection + ":" + id
|
||||
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) {
|
||||
String key = mongoBase.getRootCollection() + ":" + mongoBase.getRootId();
|
||||
Map<String, UpdateRequest> listRequest = requestMap.get(key);
|
||||
if (listRequest == null) {
|
||||
listRequest = new HashMap<>();
|
||||
requestMap.put(key, listRequest);
|
||||
} else {
|
||||
Iterator<Map.Entry<String, UpdateRequest>> it = listRequest.entrySet().iterator();
|
||||
while (it.hasNext()) {
|
||||
Map.Entry<String, UpdateRequest> entry = it.next();
|
||||
String key1 = entry.getKey();
|
||||
if(!fullKey.equals(key1)){
|
||||
//解决类似 item.1 item.11 问题
|
||||
if (fullKey.contains(key1)) {
|
||||
if(checkOverride(key1,fullKey)){
|
||||
return;
|
||||
}
|
||||
continue;
|
||||
String key = mongoBase.getRootCollection() + ":" + mongoBase.getRootId();
|
||||
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) {
|
||||
listRequest = new HashMap<>();
|
||||
dataMap.put(key, listRequest);
|
||||
} else {
|
||||
Iterator<Map.Entry<String, UpdateRequest>> it = listRequest.entrySet().iterator();
|
||||
while (it.hasNext()) {
|
||||
Map.Entry<String, UpdateRequest> entry = it.next();
|
||||
String key1 = entry.getKey();
|
||||
if (!fullKey.equals(key1)) {
|
||||
//解决类似 item.1 item.11 问题
|
||||
if (fullKey.contains(key1)) {
|
||||
if (checkOverride(key1, fullKey)) {
|
||||
return;
|
||||
}
|
||||
if (key1.contains(fullKey)) {
|
||||
if(checkOverride(key1,fullKey)){
|
||||
it.remove();
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (key1.contains(fullKey)) {
|
||||
if (checkOverride(key1, fullKey)) {
|
||||
it.remove();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
UpdateRequest request = new UpdateRequest(fullKey, value, opCode, mongoBase);
|
||||
listRequest.put(fullKey, request);
|
||||
}
|
||||
UpdateRequest request = new UpdateRequest(fullKey, value, opCode, mongoBase);
|
||||
listRequest.put(fullKey, request);
|
||||
}
|
||||
|
||||
public boolean checkOverride(String key1,String key2){
|
||||
|
@ -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();
|
||||
|
||||
for (Map.Entry<String, Map<String, UpdateRequest>> entry : requestMap.entrySet()) {
|
||||
for (Map.Entry<String, Map<String, UpdateRequest>> entry : updateRequestMap.entrySet()) {
|
||||
String[] strs = entry.getKey().split(":");
|
||||
String collection = strs[0];
|
||||
String id = strs[1];
|
||||
|
||||
searchQuery.put("_id", Integer.parseInt(id));
|
||||
BasicDBObject valueDBObj = new BasicDBObject();
|
||||
BasicDBObject dbobj = new BasicDBObject();
|
||||
|
@ -98,12 +116,10 @@ public class MongoUpdateCache {
|
|||
dbobj.append("$unset", removedbobj);
|
||||
flag = true;
|
||||
}
|
||||
if (flag){
|
||||
if (flag) {
|
||||
ljsdMongoTemplate.updateValue(collection, searchQuery, dbobj);
|
||||
}
|
||||
|
||||
}
|
||||
requestMap.clear();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,12 +1,11 @@
|
|||
package com.ljsd.common.mogodb;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class MongoUpdateCacheThreadLocal {
|
||||
private final static ThreadLocal<MongoUpdateCache> mongoUpdateCacheThreadLocal = new ThreadLocal<>();
|
||||
|
||||
private static MongoUpdateCache getMongoUpdateCache() {
|
||||
public static MongoUpdateCache getMongoUpdateCache() {
|
||||
MongoUpdateCache mongoUpdateCache = mongoUpdateCacheThreadLocal.get();
|
||||
if (mongoUpdateCache == null) {
|
||||
mongoUpdateCache = new MongoUpdateCache();
|
||||
|
@ -29,4 +28,9 @@ public class MongoUpdateCacheThreadLocal {
|
|||
MongoUpdateCache mongoUpdateCache = getMongoUpdateCache();
|
||||
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_tdir" value="/data/jl_tlogs"/>
|
||||
<property name="log_bdir" value="/data/jl_blogs"/>
|
||||
<!-- 日志最大的历史 30天 -->
|
||||
<property name="maxHistory" value="30"/>
|
||||
|
||||
|
@ -74,17 +75,28 @@
|
|||
<maxHistory>${maxHistory}</maxHistory>
|
||||
<maxFileSize>200MB</maxFileSize>
|
||||
</rollingPolicy>
|
||||
</appender>
|
||||
|
||||
<!-- 按照固定窗口模式生成日志文件,当文件大于20MB时,生成新的日志文件。窗口大小是1到3,当保存了3个归档文件后,将覆盖最早的日志。
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
|
||||
<fileNamePattern>${log_dir}/%d{yyyy-MM-dd}/.log.zip</fileNamePattern>
|
||||
<minIndex>1</minIndex>
|
||||
<maxIndex>3</maxIndex>
|
||||
</rollingPolicy> -->
|
||||
<!-- 查看当前活动文件的大小,如果超过指定大小会告知RollingFileAppender 触发当前活动文件滚动
|
||||
<triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
|
||||
<maxFileSize>5KB</maxFileSize>
|
||||
</triggeringPolicy>-->
|
||||
<appender name="file_blog" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<!--<Encoding>UTF-8</Encoding>-->
|
||||
<!-- 过滤器,只记录WARN级别的日志 -->
|
||||
<encoder charset="UTF-8">
|
||||
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS}:%msg%n</pattern>
|
||||
</encoder>
|
||||
<!-- <filter class="ch.qos.logback.classic.filter.LevelFilter">
|
||||
<level>ERROR</level>
|
||||
<onMatch>ACCEPT</onMatch>
|
||||
<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>
|
||||
|
||||
|
||||
|
@ -148,6 +160,10 @@
|
|||
<appender-ref ref="file_tlog"/>
|
||||
</logger>
|
||||
|
||||
<logger name="BackErrorLog" additivity="false">
|
||||
<appender-ref ref="file_blog"/>
|
||||
</logger>
|
||||
|
||||
|
||||
|
||||
<root level="INFO">
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.ljsd;
|
||||
|
||||
import com.ljsd.common.mogodb.util.MongoKeys;
|
||||
import com.ljsd.jieling.config.ServerConfig;
|
||||
import com.ljsd.jieling.config.json.ServerConfiguration;
|
||||
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.session.ISessionFactory;
|
||||
import com.ljsd.jieling.thread.ThreadManager;
|
||||
import com.ljsd.jieling.thread.task.MongoDataHandlerTask;
|
||||
import com.ljsd.jieling.util.KeyGenUtils;
|
||||
import com.ljsd.jieling.util.SensitivewordFilter;
|
||||
import com.ljsd.jieling.util.TimeUtils;
|
||||
|
@ -82,14 +84,16 @@ public class GameApplication {
|
|||
// HttpPool.init();
|
||||
|
||||
STableManager.initialize("com.ljsd.jieling.config");
|
||||
//mongo异步数据处理线程
|
||||
MongoDataHandlerTask.init(configurableApplicationContext);
|
||||
//初始化邮件
|
||||
MailingSystemManager.init(configurableApplicationContext);
|
||||
ThreadManager threadManager = ThreadManager.getInstance();
|
||||
threadManager.init(configurableApplicationContext);
|
||||
MapLogic.getInstance().init(configurableApplicationContext);
|
||||
|
||||
MongoKeys.initmongoKey();
|
||||
SensitivewordFilter.init();
|
||||
HttpPool.init();
|
||||
HttpPool.init();
|
||||
|
||||
// 加载lua文件
|
||||
CheckFight.getInstance().init("luafight/BattleMain.lua");
|
||||
|
|
|
@ -9,7 +9,6 @@ import com.ljsd.jieling.util.http.HttpPool;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.BlockingQueue;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
|
||||
public class DataMessageUtils {
|
||||
|
||||
|
|
|
@ -107,7 +107,7 @@ public class HandlerLogicThread extends Thread{
|
|||
return;
|
||||
}*/
|
||||
}
|
||||
|
||||
long curTimeMillis = System.currentTimeMillis();
|
||||
if(msgId != MessageTypeProto.MessageType.GET_CHAT_MESSAGE_REQUEST_VALUE){
|
||||
LOGGER.info("doWork->uid={},mType={};start", userId, MessageTypeProto.MessageType.valueOf(msgId));
|
||||
}
|
||||
|
@ -115,11 +115,12 @@ public class HandlerLogicThread extends Thread{
|
|||
MissionEventDistributor.requestStart();
|
||||
baseHandler.execute(session, packetNetData);
|
||||
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();
|
||||
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){
|
||||
LOGGER.error("",e);
|
||||
|
|
|
@ -510,7 +510,7 @@ public class ArenaLogic {
|
|||
.build());
|
||||
}
|
||||
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();
|
||||
MessageUtil.sendMessage(iSession,1, MessageTypeProto.MessageType.ARENA_DEFENSE_RESPONSE_VALUE,build,true);
|
||||
return;
|
||||
|
|
|
@ -26,8 +26,6 @@ import org.luaj.vm2.LuaValue;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.data.redis.core.ZSetOperations;
|
||||
import sun.misc.MessageUtils;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class CombatLogic {
|
||||
|
@ -534,7 +532,7 @@ public class CombatLogic {
|
|||
RedisUtil.getInstence().removeMapEntrys(RedisKey.ADVENTRUEN_BOSS_OWN,"",removeAdventureBosseInfo.toArray());
|
||||
}
|
||||
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);
|
||||
}
|
||||
|
@ -592,6 +590,7 @@ public class CombatLogic {
|
|||
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_OWN,Integer.toString(uid),bossId,0);
|
||||
MessageUtil.sendRedIndication(uid,GlobalsDef.SHARE_BOSS_RED_TYPE);
|
||||
}
|
||||
adventureStateInfo.setBossId(bossId);
|
||||
adventureStateInfo.setBossGroupId(bossGroupID);
|
||||
|
|
|
@ -1,10 +1,7 @@
|
|||
package com.ljsd.jieling.thread;
|
||||
|
||||
|
||||
import com.ljsd.jieling.thread.task.DataReportTask;
|
||||
import com.ljsd.jieling.thread.task.MinuteTask;
|
||||
import com.ljsd.jieling.thread.task.PlatConfigureTask;
|
||||
import com.ljsd.jieling.thread.task.RetrySendIndicationThread;
|
||||
import com.ljsd.jieling.thread.task.*;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
|
@ -25,6 +22,7 @@ public class ThreadManager {
|
|||
|
||||
private static PlatConfigureTask platConfigureTask;
|
||||
private static DataReportTask dataReportTask;
|
||||
private static MongoDataHandlerTask mongoDataHandlerTask;
|
||||
|
||||
public static int SLEEP_INTEVAL_TIME = 60; //每1分钟检查一次
|
||||
|
||||
|
@ -37,8 +35,10 @@ public class ThreadManager {
|
|||
public void init(ConfigurableApplicationContext configurableApplicationContext) {
|
||||
|
||||
platConfigureTask = configurableApplicationContext.getBean(PlatConfigureTask.class);
|
||||
DataReportTask dataReportTask = new DataReportTask();
|
||||
dataReportTask.start();
|
||||
mongoDataHandlerTask = configurableApplicationContext.getBean(MongoDataHandlerTask.class);
|
||||
dataReportTask = configurableApplicationContext.getBean(DataReportTask.class);
|
||||
// DataReportTask dataReportTask = new DataReportTask();
|
||||
// dataReportTask.start();
|
||||
go();
|
||||
}
|
||||
|
||||
|
@ -84,6 +84,8 @@ public class ThreadManager {
|
|||
int delayForMinute = 60 - (now%60);
|
||||
LOGGER.info("delayForMinute---->>>>{}" ,delayForMinute);
|
||||
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 Thread(){
|
||||
public void run () {
|
||||
|
|
|
@ -5,10 +5,11 @@ import org.springframework.stereotype.Component;
|
|||
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
@Component
|
||||
public class DataReportTask extends Thread {
|
||||
|
||||
public DataReportTask(){
|
||||
setName("DataReportTaskThread");
|
||||
setName("DataReportTask");
|
||||
}
|
||||
@Override
|
||||
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;
|
||||
|
||||
import com.ljsd.jieling.config.json.ConfMessage;
|
||||
import com.ljsd.jieling.util.TimeUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
@ -10,9 +9,7 @@ import java.io.IOException;
|
|||
|
||||
@Component
|
||||
public class PlatConfigureTask implements Runnable {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(PlatConfigureTask.class);
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
doLogic();
|
||||
|
|
|
@ -71,15 +71,14 @@ public class MessageUtil {
|
|||
if(session!=null){
|
||||
PlayerInfoProto.RedPointInfo redPointInfo = PlayerInfoProto.RedPointInfo.newBuilder().setType(redType).build();
|
||||
MessageUtil.sendIndicationMessage(session,1,MessageTypeProto.MessageType.SEND_RED_POINT_INDICATION_VALUE,redPointInfo,true);
|
||||
}else{
|
||||
if(redType == GlobalsDef.MAIL_RED_TYPE){
|
||||
return;
|
||||
}
|
||||
User user = UserManager.getUser(sendUid);
|
||||
Set<Integer> reds = user.getPlayerInfoManager().getReds();
|
||||
reds.add(redType);
|
||||
user.getPlayerInfoManager().setReds(reds);
|
||||
}
|
||||
if(redType == GlobalsDef.MAIL_RED_TYPE){
|
||||
return;
|
||||
}
|
||||
User user = UserManager.getUser(sendUid);
|
||||
Set<Integer> reds = user.getPlayerInfoManager().getReds();
|
||||
reds.add(redType);
|
||||
user.getPlayerInfoManager().setReds(reds);
|
||||
}
|
||||
|
||||
public static void sendBagIndication(int sendUid,int type, List<CommonProto.Item> sendToFront) {
|
||||
|
|
|
@ -20,7 +20,8 @@ public class HttpPool {
|
|||
private static PoolingHttpClientConnectionManager poolConnection = new PoolingHttpClientConnectionManager();
|
||||
private static CloseableHttpClient httpclient;
|
||||
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 String charset = "UTF-8";
|
||||
|
||||
|
@ -39,6 +40,7 @@ public class HttpPool {
|
|||
HttpPost httpPost = new HttpPost(url);
|
||||
HttpResponse httpResponse;
|
||||
int sendTimes = 0;
|
||||
boolean needBack = true;
|
||||
do {
|
||||
try {
|
||||
StringEntity stringEntity = new StringEntity(info, charset);
|
||||
|
@ -50,6 +52,7 @@ public class HttpPool {
|
|||
EntityUtils.consume(responseEntity);
|
||||
int statusCode = httpResponse.getStatusLine().getStatusCode();
|
||||
if (statusCode >= 200 && statusCode < 300) {
|
||||
needBack = false;
|
||||
LOGGER.debug("Http Send,第" + (sendTimes + 1) + "次调用成功,返回码为:[" + statusCode + "]");
|
||||
break;
|
||||
} else {
|
||||
|
@ -66,11 +69,14 @@ public class HttpPool {
|
|||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
LOGGER.error("Http Send error",e);
|
||||
}finally {
|
||||
sendTimes ++ ;
|
||||
}
|
||||
} while (sendTimes < maxSendTimes);
|
||||
if(needBack){
|
||||
BackErrorLog.info(info);
|
||||
}
|
||||
}
|
||||
|
||||
public static void main (String [] args){
|
||||
|
|
Loading…
Reference in New Issue