在线人数打点提交
parent
deb08dbaf7
commit
919fcb252a
|
@ -5,6 +5,7 @@ import com.ljsd.GameApplication;
|
|||
import com.ljsd.common.mogodb.util.BlockingUniqueQueue;
|
||||
import com.ljsd.jieling.exception.ErrorCode;
|
||||
import com.ljsd.jieling.exception.ErrorCodeException;
|
||||
import com.ljsd.jieling.ktbeans.sendbeans.ReportServerEvent;
|
||||
import com.ljsd.jieling.logic.dao.GuilidManager;
|
||||
import com.ljsd.jieling.logic.dao.Item;
|
||||
import com.ljsd.jieling.logic.dao.root.GuildInfo;
|
||||
|
@ -27,6 +28,8 @@ public class ReportUtil {
|
|||
|
||||
private static ThinkingDataAnalytics ta = new ThinkingDataAnalytics(new ThinkingDataAnalytics.LoggerConsumer(LOG_PATH));
|
||||
|
||||
private static ThinkingDataAnalytics serverTa = new ThinkingDataAnalytics(new ThinkingDataAnalytics.LoggerConsumer(LOG_PATH));
|
||||
|
||||
public static BlockingQueue<ReportUserEvent> queue = new BlockingUniqueQueue<>();
|
||||
|
||||
public static final int COIN_ID = 14;
|
||||
|
@ -119,6 +122,20 @@ public class ReportUtil {
|
|||
}
|
||||
}
|
||||
|
||||
public static void doReport(ReportServerEvent reportServerEvent){
|
||||
try {
|
||||
//todo 访客id
|
||||
Map<String, Object> eventProperties = reportServerEvent.getEventProperties();
|
||||
Object server_id = eventProperties.getOrDefault("server_id", "10001");
|
||||
serverTa.track(server_id.toString(),server_id.toString(),reportServerEvent.getEventName(),eventProperties);
|
||||
serverTa.flush();
|
||||
} catch (Exception e) {
|
||||
//异常处理
|
||||
e.printStackTrace();
|
||||
System.out.println("except:"+e);
|
||||
}
|
||||
}
|
||||
|
||||
public static void saveBaseInfo(int uid,PlayerInfoProto.LoginRequest loginRequest){
|
||||
ReportBaseBean reportBaseBean = new ReportBaseBean(loginRequest.getOpenId(),loginRequest.getDistinctId(),loginRequest.getDeviceIdS(),loginRequest.getIpS(),0);
|
||||
baseBeanMap.put(uid,reportBaseBean);
|
||||
|
|
|
@ -0,0 +1,45 @@
|
|||
package com.ljsd.jieling.ktbeans.sendbeans;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author lvxinran
|
||||
* @date 2020/7/15
|
||||
* @discribe
|
||||
*/
|
||||
public class ReportServerEvent {
|
||||
private String eventName ;
|
||||
|
||||
private Map<String,Object> eventProperties;
|
||||
|
||||
|
||||
|
||||
public ReportServerEvent(String eventName, Map<String, Object> eventProperties) {
|
||||
this.eventName = eventName;
|
||||
this.eventProperties = eventProperties;
|
||||
|
||||
}
|
||||
|
||||
public String getEventName() {
|
||||
return eventName;
|
||||
}
|
||||
|
||||
public void setEventName(String eventName) {
|
||||
this.eventName = eventName;
|
||||
}
|
||||
|
||||
public Map<String, Object> getEventProperties() {
|
||||
return eventProperties;
|
||||
}
|
||||
|
||||
public void setEventProperties(Map<String, Object> eventProperties) {
|
||||
this.eventProperties = eventProperties;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ReportServerEvent{" +
|
||||
"eventName='" + eventName + '\'' +
|
||||
", eventProperties=" + eventProperties +
|
||||
'}';
|
||||
}
|
||||
}
|
|
@ -14,8 +14,10 @@ import com.ljsd.jieling.handler.map.MapLogic;
|
|||
import com.ljsd.jieling.hotfix.HotfixUtil;
|
||||
import com.ljsd.jieling.ktbeans.BeanBuilder.KtBeanBuilderUtils;
|
||||
import com.ljsd.jieling.ktbeans.KTRequestBeans.LoginParamType;
|
||||
import com.ljsd.jieling.ktbeans.ReportUtil;
|
||||
import com.ljsd.jieling.ktbeans.parmsBean.ParamEventBean;
|
||||
import com.ljsd.jieling.ktbeans.sendbeans.KTAppOnline;
|
||||
import com.ljsd.jieling.ktbeans.sendbeans.ReportServerEvent;
|
||||
import com.ljsd.jieling.logic.GlobalDataManaager;
|
||||
import com.ljsd.jieling.logic.OnlineUserManager;
|
||||
import com.ljsd.jieling.logic.activity.ActivityLogic;
|
||||
|
@ -36,6 +38,7 @@ import com.ljsd.jieling.logic.question.QuestionLogic;
|
|||
import com.ljsd.jieling.logic.store.BuyGoodsLogic;
|
||||
import com.ljsd.jieling.logic.store.StoreLogic;
|
||||
import com.ljsd.jieling.network.server.ProtocolsManager;
|
||||
import com.ljsd.jieling.network.session.ISession;
|
||||
import com.ljsd.jieling.util.MessageUtil;
|
||||
import manager.STableManager;
|
||||
import org.slf4j.Logger;
|
||||
|
@ -84,6 +87,7 @@ public class MinuteTask extends Thread {
|
|||
RedisUtil.getInstence().set(RedisKey.ONLINE_NUM+RedisKey.Delimiter_colon+GameApplication.serverId, String.valueOf(OnlineUserManager.sessionMap.entrySet().size()));
|
||||
DeathPathLogic.getInstance().statusCheck();
|
||||
GuildFightLogic.minuteCheckForCarFight();
|
||||
reportUserOnline();
|
||||
LOGGER.info("MinuteTask end...");
|
||||
} catch (Exception e) {
|
||||
LOGGER.error("e",e);
|
||||
|
@ -106,9 +110,13 @@ public class MinuteTask extends Thread {
|
|||
DataMessageUtils.addLogQueue(ktAppOnline);
|
||||
}
|
||||
}
|
||||
//每分钟异步上报在线人数
|
||||
private void reportUserOnline() {
|
||||
new OnlineUserReportTask().start();
|
||||
}
|
||||
|
||||
//每日凌晨执行
|
||||
public void everyHourTask() throws Exception {
|
||||
public void everyHourTask() {
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
int hour = calendar.get(Calendar.HOUR_OF_DAY);
|
||||
int minute = calendar.get(Calendar.MINUTE);
|
||||
|
|
|
@ -0,0 +1,62 @@
|
|||
package com.ljsd.jieling.thread.task;
|
||||
|
||||
import com.ljsd.GameApplication;
|
||||
import com.ljsd.jieling.ktbeans.ReportUtil;
|
||||
import com.ljsd.jieling.ktbeans.sendbeans.ReportServerEvent;
|
||||
import com.ljsd.jieling.logic.OnlineUserManager;
|
||||
import com.ljsd.jieling.logic.dao.UserManager;
|
||||
import com.ljsd.jieling.logic.dao.root.User;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author lvxinran
|
||||
* @date 2020/7/15
|
||||
* @discribe
|
||||
*/
|
||||
public class OnlineUserReportTask extends Thread {
|
||||
public OnlineUserReportTask(){
|
||||
setName("OnlineUserReportTask");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
try{
|
||||
Set<Integer> uids = OnlineUserManager.sessionMap.keySet();
|
||||
Map<String,Integer> channelMap = new HashMap<>();
|
||||
for(int uid:uids){
|
||||
User user = UserManager.getUser(uid);
|
||||
String channel = user.getPlayerInfoManager().getChannel();
|
||||
channelMap.put(channel,channelMap.getOrDefault(channel,0)+1);
|
||||
}
|
||||
int serverId = GameApplication.serverId;
|
||||
Map<String,Object> properties = new HashMap<>();
|
||||
if(channelMap.isEmpty()){
|
||||
|
||||
properties.put("channel","DEFAULT_CHANNEL");
|
||||
properties.put("server_id",serverId);
|
||||
properties.put("online_user",0);
|
||||
}
|
||||
for(Map.Entry<String,Integer> entry:channelMap.entrySet()){
|
||||
properties.put("channel",entry.getKey());
|
||||
properties.put("server_id",serverId);
|
||||
properties.put("online_user",entry.getValue());
|
||||
}
|
||||
int all_online = 0 ;
|
||||
for(int value:channelMap.values()){
|
||||
all_online+=value;
|
||||
}
|
||||
properties.put("online_user_all",all_online);
|
||||
properties.put("platform","DEFAULT_platform");
|
||||
properties.put("#time",new Date());
|
||||
ReportServerEvent reportServerEvent = new ReportServerEvent("online_user_amount",properties);
|
||||
System.out.println(reportServerEvent.toString());
|
||||
ReportUtil.doReport(reportServerEvent);
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue