20170928 使用网页管理集群 按行读取写入useragent txt文件

来源:互联网 发布:王者荣耀点券充值淘宝 编辑:程序博客网 时间:2024/06/08 13:33

根据20170901---20170903的position数据分析useragent,优化urlutil。

从集群中hdfs dfs -cat /user/log/position/20170901/*/* |awk -Furlutil'\t' 'print $8'|sort|uniq > ua.txt 导出useragent数据,写一个程序读取数据文件,把useragentid加在useragent数据后面,判断useragentid是否准备,由此优化urlutil。

20170901的useragent数据共26469条,1 其他 5527条,2 苹果手机 2216条,3 安卓手机 15809条,4 pc端 2917条。

其余两天数据分布基本一致。


按行读取写入文件


public class Uarw {    public static void main(String[] args) {        try {            // read file content from file            StringBuffer sb= new StringBuffer("");            FileReader reader = new FileReader("/home/hzq/data/ua0903.txt");            BufferedReader br = new BufferedReader(reader);                        String str = null;            String userAgentId = null;                        while((str = br.readLine()) != null) {                userAgentId = UrlUtil.getUAID(str);                sb.append(str).append("===").append(userAgentId).append("\n");//                System.out.println(str);            }            br.close();            reader.close();            // write string to file            FileWriter writer = new FileWriter("/home/hzq/data/0903userAgentId.txt");            BufferedWriter bw = new BufferedWriter(writer);            bw.write(sb.toString());            bw.close();            writer.close();        }        catch(FileNotFoundException e) {            e.printStackTrace();        }        catch(IOException e) {            e.printStackTrace();        }    }}

昨天优化onlinelocationcategory的代码,将输入路径利用conf.set 配置到代码中。出现的问题是在集群中,输出文件中无数据。经过查看日志查找问题,发现是shell脚本中的输入路径中带有代码中无法识别的*,修改此路径。代码中已有递归读文件的功能。所以在输入路径中也无需加*。



利用http://192.168.20.46:7180/cmf/login 数巨管家 在yarn页面上的webUI中点击Resourcemanager可以查看application的日志信息。但需要之前在本地/etc/hosts中添加配置文件

192.168.20.46    agent

192.168.20.47    node01

192.168.20.48    node02

192.168.20.49    node03

192.168.20.50    node04

192.168.20.51    node05


重写上网数据onlinecategory根据uid join位置数据locationtime的mr的shell。projectname 由onlinelocationcategory改为onlinecategorylocationjoin,这样更直接清楚。





原创粉丝点击