码迷,mamicode.com
首页 > 其他好文 > 详细

02.友盟项目--原始日志数据生成

时间:2018-10-28 15:00:26      阅读:229      评论:0      收藏:0      [点我收藏+]

标签:聚合   lap   友盟   自动填充   运营商   down   color   iphone   tca   

 友盟架构图1

技术分享图片

 友盟架构图2

技术分享图片

 

 

日志生成类

技术分享图片

 

技术分享图片
package com.star.umeng.phone.domain;

/**
 * App日志的公共属性
 */
public class AppBaseLog {
    private Long createdAtMs;           //日志创建时间
    private String appId;               //应用唯一标识
    private String tenantId;            //租户唯一标识,企业用户
    private String deviceId;            //设备唯一标识
    private String appVersion;          //版本
    private String appChannel;          //渠道,安装时就在清单中制定了,appStore等。
    private String appPlatform;         //平台
    private String osType;              //操作系统
    private String deviceStyle;         //机型

    public Long getCreatedAtMs() {
        return createdAtMs;
    }

    public void setCreatedAtMs(Long createdAtMs) {
        this.createdAtMs = createdAtMs;
    }

    public String getAppId() {
        return appId;
    }

    public void setAppId(String appId) {
        this.appId = appId;
    }

    public String getTenantId() {
        return tenantId;
    }

    public void setTenantId(String tenantId) {
        this.tenantId = tenantId;
    }

    public String getDeviceId() {
        return deviceId;
    }

    public void setDeviceId(String deviceId) {
        this.deviceId = deviceId;
    }

    public String getAppVersion() {
        return appVersion;
    }

    public void setAppVersion(String appVersion) {
        this.appVersion = appVersion;
    }

    public String getAppChannel() {
        return appChannel;
    }

    public void setAppChannel(String appChannel) {
        this.appChannel = appChannel;
    }

    public String getAppPlatform() {
        return appPlatform;
    }

    public void setAppPlatform(String appPlatform) {
        this.appPlatform = appPlatform;
    }

    public String getOsType() {
        return osType;
    }

    public void setOsType(String osType) {
        this.osType = osType;
    }

    public String getDeviceStyle() {
        return deviceStyle;
    }

    public void setDeviceStyle(String deviceStyle) {
        this.deviceStyle = deviceStyle;
    }
}
AppBaseLog-App日志的公共属性
技术分享图片
package com.star.umeng.phone.domain;

/**
 * 错误日志
 */
public class AppErrorLog extends AppBaseLog {
    private String errorBrief;        //错误摘要
    private String errorDetail;       //错误详情

    public String getErrorBrief() {
        return errorBrief;
    }

    public void setErrorBrief(String errorBrief) {
        this.errorBrief = errorBrief;
    }

    public String getErrorDetail() {
        return errorDetail;
    }

    public void setErrorDetail(String errorDetail) {
        this.errorDetail = errorDetail;
    }
}
AppErrorLog-错误日志
技术分享图片
package com.star.umeng.phone.domain;

import java.util.Map;

/**
 * 事件日志
 */
public class AppEventLog extends AppBaseLog {
    private String eventId;                                //事件唯一标识
    private Long eventDurationSecs;                        //事件持续时长
    private Map<String, String> paramKeyValueMap;        //参数名/值对

    public String getEventId() {
        return eventId;
    }

    public void setEventId(String eventId) {
        this.eventId = eventId;
    }

    public Long getEventDurationSecs() {
        return eventDurationSecs;
    }

    public void setEventDurationSecs(Long eventDurationSecs) {
        this.eventDurationSecs = eventDurationSecs;
    }

    public Map<String, String> getParamKeyValueMap() {
        return paramKeyValueMap;
    }

    public void setParamKeyValueMap(Map<String, String> paramKeyValueMap) {
        this.paramKeyValueMap = paramKeyValueMap;
    }
    //getter/setter
}
AppEventLog-事件日志
技术分享图片
package com.star.umeng.phone.domain;

/**
 * 页面日志
 */
public class AppPageLog extends AppBaseLog {
    private int pageViewCntInSession = 0;
    private String pageId;                        //页面id
    private int visitIndex = 0;                    //访问顺序号,0为第一个页面
    private String nextPage;                    //下一个访问页面,空表示为退出应用的页面
    private Long stayDurationSecs = (long) 0;     //当前页面停留时长

    public int getPageViewCntInSession() {
        return pageViewCntInSession;
    }

    public void setPageViewCntInSession(int pageViewCntInSession) {
        this.pageViewCntInSession = pageViewCntInSession;
    }

    public String getPageId() {
        return pageId;
    }

    public void setPageId(String pageId) {
        this.pageId = pageId;
    }

    public int getVisitIndex() {
        return visitIndex;
    }

    public void setVisitIndex(int visitIndex) {
        this.visitIndex = visitIndex;
    }

    public String getNextPage() {
        return nextPage;
    }

    public void setNextPage(String nextPage) {
        this.nextPage = nextPage;
    }

    public Long getStayDurationSecs() {
        return stayDurationSecs;
    }

    public void setStayDurationSecs(Long stayDurationSecs) {
        this.stayDurationSecs = stayDurationSecs;
    }
}
AppPageLog --页面日志
技术分享图片
package com.star.umeng.phone.domain;

/**
 * 启动日志
 */
public class AppStartupLog extends AppBaseLog {
    private String country;           //国家,终端不用上报,服务器自动填充该属性
    private String province;          //省份,终端不用上报,服务器自动填充该属性
    private String ipAddress;         //ip地址

    private String network;           //网络
    private String carrier;           //运营商

    private String brand;             //品牌
    private String screenSize;        //分辨率

    public String getCountry() {
        return country;
    }

    public void setCountry(String country) {
        this.country = country;
    }

    public String getProvince() {
        return province;
    }

    public void setProvince(String province) {
        this.province = province;
    }

    public String getIpAddress() {
        return ipAddress;
    }

    public void setIpAddress(String ipAddress) {
        this.ipAddress = ipAddress;
    }

    public String getNetwork() {
        return network;
    }

    public void setNetwork(String network) {
        this.network = network;
    }

    public String getCarrier() {
        return carrier;
    }

    public void setCarrier(String carrier) {
        this.carrier = carrier;
    }

    public String getBrand() {
        return brand;
    }

    public void setBrand(String brand) {
        this.brand = brand;
    }

    public String getScreenSize() {
        return screenSize;
    }

    public void setScreenSize(String screenSize) {
        this.screenSize = screenSize;
    }
}
AppStartupLog --启动日志
技术分享图片
package com.star.umeng.phone.domain;

/**
 * 使用日志
 */
public class AppUsageLog extends AppBaseLog {
    private Long singleUseDurationSecs;      //单次使用时长
    private Long singleUploadTraffic;        //单次使用过程中的上传流量
    private Long singleDownloadTraffic;      //单次使用过程中的下载流量

    public Long getSingleUseDurationSecs() {
        return singleUseDurationSecs;
    }

    public void setSingleUseDurationSecs(Long singleUseDurationSecs) {
        this.singleUseDurationSecs = singleUseDurationSecs;
    }

    public Long getSingleUploadTraffic() {
        return singleUploadTraffic;
    }

    public void setSingleUploadTraffic(Long singleUploadTraffic) {
        this.singleUploadTraffic = singleUploadTraffic;
    }

    public Long getSingleDownloadTraffic() {
        return singleDownloadTraffic;
    }

    public void setSingleDownloadTraffic(Long singleDownloadTraffic) {
        this.singleDownloadTraffic = singleDownloadTraffic;
    }
}
AppUsageLog --使用日志
技术分享图片
package com.star.umeng.phone.domain;


import java.util.ArrayList;
import java.util.List;

/**
 * 日志聚合体
 */
public class AppLogAggEntity {
    private String appId;               //应用唯一标识
    private String tenantId;            //租户唯一标识,企业用户
    private String deviceId;            //设备唯一标识
    private String appVersion;          //版本
    private String appChannel;          //渠道,安装时就在清单中制定了,appStore等。
    private String appPlatform;         //平台
    private String osType;              //操作系统
    private String deviceStyle;         //机型

    //5中类型的日志集合
    private List<AppStartupLog> startupLogs = new ArrayList<AppStartupLog>();
    private List<AppErrorLog> errorLogs = new ArrayList<AppErrorLog>();
    private List<AppEventLog> eventLogs = new ArrayList<AppEventLog>();
    private List<AppUsageLog> usageLogs = new ArrayList<AppUsageLog>();
    private List<AppPageLog> pageLogs = new ArrayList<AppPageLog>();

    public String getAppId() {
        return appId;
    }

    public void setAppId(String appId) {
        this.appId = appId;
    }

    public String getTenantId() {
        return tenantId;
    }

    public void setTenantId(String tenantId) {
        this.tenantId = tenantId;
    }

    public String getDeviceId() {
        return deviceId;
    }

    public void setDeviceId(String deviceId) {
        this.deviceId = deviceId;
    }

    public String getAppVersion() {
        return appVersion;
    }

    public void setAppVersion(String appVersion) {
        this.appVersion = appVersion;
    }

    public String getAppChannel() {
        return appChannel;
    }

    public void setAppChannel(String appChannel) {
        this.appChannel = appChannel;
    }

    public String getAppPlatform() {
        return appPlatform;
    }

    public void setAppPlatform(String appPlatform) {
        this.appPlatform = appPlatform;
    }

    public String getOsType() {
        return osType;
    }

    public void setOsType(String osType) {
        this.osType = osType;
    }

    public String getDeviceStyle() {
        return deviceStyle;
    }

    public void setDeviceStyle(String deviceStyle) {
        this.deviceStyle = deviceStyle;
    }

    public List<AppStartupLog> getStartupLogs() {
        return startupLogs;
    }

    public void setStartupLogs(List<AppStartupLog> startupLogs) {
        this.startupLogs = startupLogs;
    }

    public List<AppErrorLog> getErrorLogs() {
        return errorLogs;
    }

    public void setErrorLogs(List<AppErrorLog> errorLogs) {
        this.errorLogs = errorLogs;
    }

    public List<AppEventLog> getEventLogs() {
        return eventLogs;
    }

    public void setEventLogs(List<AppEventLog> eventLogs) {
        this.eventLogs = eventLogs;
    }

    public List<AppUsageLog> getUsageLogs() {
        return usageLogs;
    }

    public void setUsageLogs(List<AppUsageLog> usageLogs) {
        this.usageLogs = usageLogs;
    }

    public List<AppPageLog> getPageLogs() {
        return pageLogs;
    }

    public void setPageLogs(List<AppPageLog> pageLogs) {
        this.pageLogs = pageLogs;
    }
}
AppLogAggEntity-- 日志聚合体

 

 

测试生成

技术分享图片
package com.star.umeng.phone;

import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URL;

/**
 * 入口点程序
 */
public class Main {
    public static void main(String[] args) throws Exception {
        String strURL = "http://localhost/1.html" ;
        URL url = new URL(strURL) ;
        HttpURLConnection conn = (HttpURLConnection) url.openConnection();
        //设置请求方式
        conn.setRequestMethod("POST");
        //设置发送的内容类型
        conn.setRequestProperty("Content-Type" , "application/json");
        //允许输出到服务器
        conn.setDoOutput(true);
        OutputStream out = conn.getOutputStream() ;

        String json = "{\n" + "  \"appChannel\": \"anroid bus\",\n" + "  \"appId\": \"sohuvideo\",\n" + "  \"appPlatform\": \"ios\",\n" + "  \"appVersion\": \"1.1.0\",\n" + "  \"deviceStyle\": \"oppo 1\",\n" + "  \"errorLogs\": [\n" + "    {\n" + "      \"appChannel\": \"umeng\",\n" + "      \"appId\": \"gaodemap\",\n" + "      \"appPlatform\": \"blackberry\",\n" + "      \"appVersion\": \"1.1.0\",\n" + "      \"deviceStyle\": \"vivo 3\",\n" + "      \"errorBrief\": \"at cn.lift.dfdf.web.AbstractBaseController.validInbound(AbstractBaseController.java:72)\",\n" + "      \"errorDetail\": \"at cn.lift.dfdfdf.control.CommandUtil.getInfo(CommandUtil.java:67) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606)\",\n" + "      \"osType\": \"android 4.0\",\n" + "      \"tenantId\": \"tnt023\"\n" + "    }\n" + "  ],\n" + "  \"eventLogs\": [\n" + "    {\n" + "      \"appChannel\": \"anroid bus\",\n" + "      \"appId\": \"tianya\",\n" + "      \"appPlatform\": \"android\",\n" + "      \"appVersion\": \"2.0.0\",\n" + "      \"deviceStyle\": \"红米\",\n" + "      \"eventId\": \"popmenu\",\n" + "      \"osType\": \"ios11\",\n" + "      \"tenantId\": \"tnt009\"\n" + "    },\n" + "    {\n" + "      \"appChannel\": \"appstore\",\n" + "      \"appId\": \"gaodemap\",\n" + "      \"appPlatform\": \"android\",\n" + "      \"appVersion\": \"1.1.0\",\n" + "      \"deviceStyle\": \"iphone 7 plus\",\n" + "      \"eventId\": \"popmenu\",\n" + "      \"osType\": \"android 4.0\",\n" + "      \"tenantId\": \"tnt009\"\n" + "    },\n" + "    {\n" + "      \"appChannel\": \"appstore\",\n" + "      \"appId\": \"faobengplay\",\n" + "      \"appPlatform\": \"blackberry\",\n" + "      \"appVersion\": \"1.0.0\",\n" + "      \"deviceStyle\": \"vivo 3\",\n" + "      \"eventId\": \"autoImport\",\n" + "      \"osType\": \"ios11\",\n" + "      \"tenantId\": \"tnt009\"\n" + "    },\n" + "    {\n" + "      \"appChannel\": \"anroid bus\",\n" + "      \"appId\": \"tianya\",\n" + "      \"appPlatform\": \"blackberry\",\n" + "      \"appVersion\": \"1.1.0\",\n" + "      \"deviceStyle\": \"iphone 7 plus\",\n" + "      \"eventId\": \"popmenu\",\n" + "      \"osType\": \"mi 5.5\",\n" + "      \"tenantId\": \"tnt009\"\n" + "    },\n" + "    {\n" + "      \"appChannel\": \"anroid bus\",\n" + "      \"appId\": \"tianya\",\n" + "      \"appPlatform\": \"android\",\n" + "      \"appVersion\": \"1.2.0\",\n" + "      \"deviceStyle\": \"iphone 7\",\n" + "      \"eventId\": \"bookstore\",\n" + "      \"osType\": \"ios11\",\n" + "      \"tenantId\": \"tnt501\"\n" + "    }\n" + "  ],\n" + "  \"osType\": \"ios11\",\n" + "  \"pageLogs\": [\n" + "    null,\n" + "    null,\n" + "    null,\n" + "    null,\n" + "    null\n" + "  ],\n" + "  \"startupLogs\": [\n" + "    {\n" + "      \"appChannel\": \"anroid bus\",\n" + "      \"appId\": \"faobengplay\",\n" + "      \"appPlatform\": \"ios\",\n" + "      \"appVersion\": \"1.2.0\",\n" + "      \"brand\": \"魅族\",\n" + "      \"carrier\": \"中国铁通\",\n" + "      \"country\": \"america\",\n" + "      \"deviceStyle\": \"vivo 3\",\n" + "      \"network\": \"wifi\",\n" + "      \"osType\": \"android 4.0\",\n" + "      \"province\": \"guangdong\",\n" + "      \"screenSize\": \"480 * 320\",\n" + "      \"tenantId\": \"tnt501\"\n" + "    },\n" + "    {\n" + "      \"appChannel\": \"appstore\",\n" + "      \"appId\": \"sohuvideo\",\n" + "      \"appPlatform\": \"blackberry\",\n" + "      \"appVersion\": \"2.0.0\",\n" + "      \"brand\": \"Apple\",\n" + "      \"carrier\": \"中国铁通\",\n" + "      \"country\": \"china\",\n" + "      \"deviceStyle\": \"iphone 7\",\n" + "      \"network\": \"3g\",\n" + "      \"osType\": \"ios11\",\n" + "      \"province\": \"guangxi\",\n" + "      \"screenSize\": \"1136 * 640\",\n" + "      \"tenantId\": \"tnt501\"\n" + "    }\n" + "  ],\n" + "  \"tenantId\": \"tnt009\",\n" + "  \"usageLogs\": [\n" + "    {\n" + "      \"appChannel\": \"umeng\",\n" + "      \"appId\": \"gaodemap\",\n" + "      \"appPlatform\": \"winphone\",\n" + "      \"appVersion\": \"1.1.0\",\n" + "      \"deviceStyle\": \"iphone 7\",\n" + "      \"osType\": \"ios11\",\n" + "      \"tenantId\": \"tnt009\"\n" + "    },\n" + "    {\n" + "      \"appChannel\": \"anroid bus\",\n" + "      \"appId\": \"tianya\",\n" + "      \"appPlatform\": \"android\",\n" + "      \"appVersion\": \"1.2.0\",\n" + "      \"deviceStyle\": \"iphone 6\",\n" + "      \"osType\": \"android 4.0\",\n" + "      \"tenantId\": \"tnt501\"\n" + "    },\n" + "    {\n" + "      \"appChannel\": \"umeng\",\n" + "      \"appId\": \"tianya\",\n" + "      \"appPlatform\": \"winphone\",\n" + "      \"appVersion\": \"1.0.0\",\n" + "      \"deviceStyle\": \"vivo 3\",\n" + "      \"osType\": \"mi 5.5\",\n" + "      \"tenantId\": \"tnt023\"\n" + "    },\n" + "    {\n" + "      \"appChannel\": \"umeng\",\n" + "      \"appId\": \"sohuvideo\",\n" + "      \"appPlatform\": \"android\",\n" + "      \"appVersion\": \"1.0.0\",\n" + "      \"deviceStyle\": \"iphone 6 plus\",\n" + "      \"osType\": \"mi 5.5\",\n" + "      \"tenantId\": \"tnt023\"\n" + "    }\n" + "  ]\n" + "}" ;
        out.write(json.getBytes());
        out.flush();
        out.close();
        int code = conn.getResponseCode() ;
        if(code == 200){
            System.out.println("发送ok!!");
        }
    }
}
测试代码-生成数据

s102--s104查看生成的数据

技术分享图片

 

02.友盟项目--原始日志数据生成

标签:聚合   lap   友盟   自动填充   运营商   down   color   iphone   tca   

原文地址:https://www.cnblogs.com/star521/p/9865381.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!