test2
package com.analysis.code;
import org.apache.commons.lang3.StringUtils;
import java.io.*;
import java.net.URL;
import java.util.*;
/**
* Created by Zephery on 2016/9/26.
*/
public class ThirdTest {
public static boolean judgeURL(String line) throws Exception { //判断来源的主域名
String lineformat = java.net.URLDecoder.decode(line, "utf-8");
URL url = new URL(lineformat);
String host = url.getHost();
//System.out.println(host);
if (host != null) {
if (!host.equals("api.app.happyjuzi.com") && !host.equals("m.happyjuzi.com") && !host.equals("a.happyjuzi.com")) {
//System.out.println(host);
return false;
}
if (lineformat.contains("&uid=")) {
//System.out.println(lineformat);
return false;
}
}
return true;
}
//
// public static List<String> getFileList(File file) {
// List<String> result = new ArrayList<String>();
// if (!file.isDirectory()) {
// System.out.println(file.getAbsolutePath());
// result.add(file.getAbsolutePath());
// } else {
// File[] directoryList = file.listFiles(new FileFilter() {
// public boolean accept(File file) {
// if (file.isFile() && file.getName().indexOf("log") > -1) {
// return true;
// } else {
// return false;
// }
// }
// });
// for (int i = 0; i < directoryList.length; i++) {
// result.add(directoryList[i].getPath());
// }
// }
// return result;
// }
public static List<String> getFileList(String path, String pathtodate) { //fu wu qi tiao shi
List<String> pathlist = new ArrayList<>();
Iterator it = pathlist.iterator();
for (int i = 0; i <= 2; i++) {
for (int j = 0; j <= 9; j++) {
String hour = i + "" + j;
pathlist.add(path + "/logstat-" + pathtodate + "-" + hour + ".log");
if (Integer.parseInt(hour) > 22) {
break;
}
}
}
return pathlist;
}
public static void main(String args[]) {
Long programstarttime = System.currentTimeMillis();
try {
int repeatecount = 0;
String path = args[0]; //fuwuqi
String pathsplit[] = path.split("/");
String pathtodate = pathsplit[pathsplit.length - 1];
List<String> pathlist = getFileList(path, pathtodate);
String line = null;
// String path = "src/log/2016-09-26";
// String pathsplit[] = path.split("/");
// String pathtodate = "2016-09-26";
// File file = new File(path);
// List<String> pathlist = getFileList(file);
// String line = null;
int count = 0;
Map<String, List<Map<String, String>>> originmap = new HashMap<>(); //声明一个全局的map
Map<String, Long> timemap = new HashMap<>(); //用来存储时间的map
for (String l : pathlist) {
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(
new FileInputStream(l)));
while ((line = bufferedReader.readLine()) != null) {
try {
String[] data = line.split("&");
Map<String, String> tojson = new HashMap<>();
//List<Map> list = new ArrayList<>();
String iphost = data[0].split("=")[1].split(",")[0];
String usi = data[1].split("=")[1];
// List<Map> list = originmap.get(iphost);
for (String da : data) {
String source[] = da.split("=");
if (source.length < 2) {
tojson.put(source[0], null);
} else {
tojson.put(source[0], source[1].equals("null") ? null : source[1]);
}
}
tojson.put("ip", iphost);
tojson.put("comefrom", "");
if (!judgeURL(tojson.get("u"))) {
continue;
}
String key = "";
if (originmap.get(usi) != null) {
key = usi;
} else if (originmap.get(iphost) != null) {
key = iphost;
}
if (StringUtils.isNotBlank(key) && originmap.containsKey(key)) {
long starttime = Long.parseLong(timemap.get(key).toString().substring(0, 10));
long endtime = Long.parseLong(tojson.get("ipt").substring(0, 10));
//大于30秒的情况
if ((endtime - starttime) < 300) {
originmap.get(key).add(tojson);
} else {
//数据库处理
new JudgeFrom(pathtodate).judgeoneip(originmap.get(key));
repeatecount++;
List<Map<String, String>> list = new ArrayList<>();
list.add(tojson);
originmap.put(key, list);
}
} else {
//###
List<Map<String, String>> list = new ArrayList<>();
list.add(tojson);
originmap.put(iphost, list);
}
timemap.put(iphost, Long.parseLong(tojson.get("ipt")));
} catch (Exception e) {
e.printStackTrace();
}
//System.out.println(data[0].split("=")[1].split(",")[0]);
//只判断100条数据
count++;
// if (count > 1999) {
// break;
// }
System.out.println(count);
}
}
System.out.println("end");
JudgeFrom judgeFrom = new JudgeFrom(pathtodate);
judgeFrom.judgefromwhere(originmap);
System.out.println(repeatecount);
//System.out.println("PV:" + (PV + originmap.size()));
} catch (Exception e) {
e.printStackTrace();
}
System.out.println(System.currentTimeMillis() - programstarttime);
}
}
test
test2的更多相关文章
- python 装饰器--对有无参数的函数进行装饰
# 使用装饰器无参数的函数进行装饰# def func(funcionName): # print('-----1------') # def func_in(): # print('--func_i ...
- 如果是多个 c 代码的源码文件,编译方法如下: $ gcc test1.c test2.c -o main.out $ ./main.out test1.c 与 test2.c 是两个源代码文件。
如果是多个 c 代码的源码文件,编译方法如下: $ gcc test1.c test2.c -o main.out $ ./main.out test1.c 与 test2.c 是两个源代码文件.
- VS2010 正在创建“Debug\test2.unsuccessfulbuild”,因为已指定“AlwaysCreate”。
问题一:VS2010 正在创建“Debug\test2.unsuccessfulbuild”,因为已指定“AlwaysCreate”. 方法解决: The relevant setting is i ...
- python遍历目录os.walk(''d:\\test2",topdown=False)
os.walk(top, topdown=True, onerror=None, followlinks=False)遍历目录,topdown=false表示先返回目录,后返回文件 参数说明: top ...
- load data infile出现“ERROR 13 (HY000): Can't get stat of '/tmp/test2.txt' (Errcode: 2)”问题
用load data infile导数据到mysql数据库出现这个该问题,解决方法如下: 安全起见,连接mysql的语句需要添加–local-infile, mysql -hlocalhost -ur ...
- 2016/3/30 ①投票checkbox ②进度条两个div套起百分比控制内div(width) <div><div></div></div> ③数据库test2 表 diaoyan... 35岁发展方向投票
分两个页面,要点:提交form 相连action method 两个页面可以合成一个页面action传到自身页面 但分开较清晰 第一个页面vote.php <!DOCTYPE html P ...
- 5、数组的复制(test2.java、test3.java)
对于数组的复制,在最开始的时候最容易犯的一个错误,那就是自己认为的申请一个数组,然后将已存在的数组赋值到新申请数组名上,这样是错误的,这样仅仅是将数组的地址复制了过去,并不是,将数组内的元素拷贝过去, ...
- 还可以使用 -c 参数来显示全部内容,并标出不同之处 diff -c test2.txt test1.txt
二.实例 在test目录下存放了两个文本文件,test1.txt test2.txt . 比较这两个文件的异同. diff test1.txt test2.txt "5c5& ...
- 20150706 test2
净心守志:可会至道.譬如磨镜:垢去明存.断欲无求:当得宿命
随机推荐
- javascript-适配器模式
适配器模式笔记 将一个类(对象)的接口(方法或属性)转化成另一个接口,以满足用户需求,使类(对象)之间接口的不兼容性问题通过适配器方法得以解决 demo实例:1.适配参数对象,使传入的参数完整 2.适 ...
- Linux信号
信号本质上就是一个软件中断,它既可以作为两个进程间的通信的方式, 更重要的是, 信号可以终止一个正常程序的执行, 通常被用于处理意外情况 ,* 信号是异步的, 也就是进程并不知道信号何时会到达 $ki ...
- shell编程入门
背景知识 Shell 是用户与内核进行交互操作的一种接口,是 Linux 最重要的软件之一.目前最流行的 Shell 称为 bash Shell,bash Shell 脚本编程以其简洁.高效而著称,多 ...
- 理解 OpenStack + Ceph (3):Ceph RBD 接口和工具 [Ceph RBD API and Tools]
本系列文章会深入研究 Ceph 以及 Ceph 和 OpenStack 的集成: (1)安装和部署 (2)Ceph RBD 接口和工具 (3)Ceph 物理和逻辑结构 (4)Ceph 的基础数据结构 ...
- 增量式PID计算公式4个疑问与理解
一开始见到PID计算公式时总是疑问为什么是那样子?为了理解那几道公式,当时将其未简化前的公式“活生生”地算了一遍,现在想来,这样的演算过程固然有助于理解,但假如一开始就带着对疑问的答案已有一定看法后再 ...
- 第二届中国移动互联网测试大会PPT
第二届中国移动互联网测试大会PPT下载_360云盘 (提取密码:7799) 第二届中国移动互联网测试大会PPT下载_百度云盘 (提取密码: ws8m) 第二届中国移动互联网测试大会PPT下载_Goog ...
- 转载:JavaSE之反射
该文章转载自:http://www.cnblogs.com/rollenholt/archive/2011/09/02/2163758.html Java反射详解 本篇文章依旧采用小例子来说明,因为我 ...
- 第15章 设备无关位图_15.2 显示和打印DIB
15.2.1 探究DIB (1)DIB文件的结构 整个文件 紧凑DIB(整个文件除文件头) 文件头(File Header) 信息头(Information Header) 信息头(Informati ...
- 2016.11.17 NOI plus day0
今天很乱乱乱乱 根本不想写代码 玩了一早上了 昨晚失眠了 今天又懵逼了 中午就要走了 明天就要考试了 考完试回来就要补文化课了 现在我的内心很平静 因为已经紧张的冻结了 你知道什么叫彷徨么? 机房里的 ...
- 精通CSS version2笔记之⒈选择器
1.常用的选择器:①元素选择器 指定希望应用样式的元素.比如:p {color:#fff;}②后代选择器 寻找特定元素或者元素的后代. 比如:body p{color:#ccc;} 这个选 ...