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
净心守志:可会至道.譬如磨镜:垢去明存.断欲无求:当得宿命
随机推荐
- 基础篇之 Create Type
Create Type 的话呢,是创建一个自定义的数据类型,等于说为常用的数据类型建造一个别名的样纸.然后就可以通用当前数据库的当前架构.(当然了,一般来说我们都是使用dbo架构,所以都会无事前面那个 ...
- mysql / mysqld_safe / mysqld 常见错误处理
1. FATAL ERROR: Could not find ./bin/my_print_defaults [root@localhost scripts]# ./mysql_install_db ...
- python scrapy+Mongodb爬取蜻蜓FM,酷我及懒人听书
1.初衷:想在网上批量下载点听书.脱口秀之类,资源匮乏,大家可以一试 2.技术:wireshark scrapy jsonMonogoDB 3.思路:wireshark分析移动APP返回的各种连接分类 ...
- Linux IPC System V 信号量
模型 #include <sys/types.h> #include <sys/ipc.h> #include <sys/sem.h> ftok() //获取key ...
- 004.UDP--拼接UDP数据包,构造ip头和udp头通信(使用原始套接字)
一.大致流程: 建立一个client端,一个server端,自己构建IP头和UDP头,写入数据(hello,world!)后通过原始套接字(SOCK_RAW)将包发出去. server端收到数据后,打 ...
- 实现台式机redhat6.4无线网卡上网RTL8188CUS
台式机装了红帽6.4,无法无线wlan上网,特此用usb无线网卡设置 输入命令lsusb,可以看到USB无线网卡是 Realtek Semiconductor Corp. RTL8188CUS 8 ...
- 支付宝APP支付开发- IOException : DerInputStream.getLength(): lengthTag=127, too big.
支付宝APP支付Java开发报错: IOException : DerInputStream.getLength(): lengthTag=127, too big. 后来排查是因为没有设置私钥.
- POJ1523 SPF[无向图割点]
SPF Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 8139 Accepted: 3723 Description C ...
- 洛谷八月月赛Round1凄惨记
个人背景: 上午9:30放学,然后因为学校举办读书工程跟同学去书城选书,中午回来开始打比赛,下午又回老家,中间抽出一点时间调代码,回家已经8:50了 也许是7月月赛时“连蒙带骗”AK的太幸运然而因同学 ...
- java 之前的安全的类回顾,以及以后需要线程安全时使用哪些类
之前所学习到的线程安全的类: StringBuffer:线程安全的可变字符序列.一个类似于 String 的字符串缓冲区,但不能修改. Vector:Vector 类可以实现可增长的对象数组. Has ...