Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
梦中观雨
cat
提交
0dfcc047
C
cat
项目概览
梦中观雨
/
cat
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
C
cat
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
0dfcc047
编写于
5月 21, 2014
作者:
Y
youyong205
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
modify the broker service
上级
f75ab1bb
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
26 addition
and
27 deletion
+26
-27
cat-broker/src/main/java/com/dianping/cat/broker/api/page/IpService.java
...main/java/com/dianping/cat/broker/api/page/IpService.java
+15
-14
cat-broker/src/main/resources/config/iptable_china
cat-broker/src/main/resources/config/iptable_china
+0
-0
cat-broker/src/test/java/com/dianping/cat/broker/IpServiceTest.java
.../src/test/java/com/dianping/cat/broker/IpServiceTest.java
+0
-2
cat-broker/src/test/java/com/dianping/cat/broker/PostTest.java
...roker/src/test/java/com/dianping/cat/broker/PostTest.java
+11
-11
未找到文件。
cat-broker/src/main/java/com/dianping/cat/broker/api/page/IpService.java
浏览文件 @
0dfcc047
package
com.dianping.cat.broker.api.page
;
import
java.io.BufferedReader
;
import
java.io.DataInputStream
;
import
java.io.FileInputStream
;
import
java.io.IOException
;
import
java.io.InputStreamReader
;
import
java.io.RandomAccessFile
;
import
java.util.LinkedHashMap
;
import
java.util.Map
;
...
...
@@ -141,32 +139,35 @@ public class IpService implements Initializable {
initCorpMap
(
corpFile
);
initIpTable
(
ipFile
);
}
public
void
initIpTable
(
String
ipFile
)
{
DataInputStream
reader
=
null
;
BufferedReader
reader
=
null
;
try
{
RandomAccessFile
sizeReader
=
new
RandomAccessFile
(
ipFile
,
"r"
);
sizeReader
.
seek
(
sizeReader
.
length
()
-
4
);
int
size
=
sizeReader
.
readInt
()
;
sizeReader
.
close
()
;
reader
=
new
BufferedReader
(
new
InputStreamReader
(
new
FileInputStream
(
ipFile
))
);
int
size
=
Integer
.
parseInt
(
reader
.
readLine
()
);
String
line
;
String
[]
strs
;
reader
=
new
DataInputStream
(
new
FileInputStream
(
ipFile
));
m_starts
=
new
long
[
size
];
m_ends
=
new
long
[
size
];
m_areaIds
=
new
int
[
size
];
m_corpIds
=
new
int
[
size
];
for
(
int
i
=
0
;
i
<
size
;
i
++)
{
m_starts
[
i
]
=
reader
.
readLong
();
m_ends
[
i
]
=
reader
.
readLong
();
m_areaIds
[
i
]
=
reader
.
readInt
();
m_corpIds
[
i
]
=
reader
.
readInt
();
line
=
reader
.
readLine
();
strs
=
line
.
split
(
":"
);
m_starts
[
i
]
=
Long
.
parseLong
(
strs
[
0
]);
m_ends
[
i
]
=
Long
.
parseLong
(
strs
[
1
]);
m_areaIds
[
i
]
=
Integer
.
parseInt
(
strs
[
2
]);
m_corpIds
[
i
]
=
Integer
.
parseInt
(
strs
[
3
]);
}
}
catch
(
IOException
e
)
{
Cat
.
logError
(
e
);
}
finally
{
try
{
reader
.
close
();
}
catch
(
IO
Exception
e
)
{
}
catch
(
Exception
e
)
{
Cat
.
logError
(
e
);
}
}
...
...
cat-broker/src/main/resources/config/iptable_china
浏览文件 @
0dfcc047
无法预览此类型文件
cat-broker/src/test/java/com/dianping/cat/broker/IpServiceTest.java
浏览文件 @
0dfcc047
...
...
@@ -19,8 +19,6 @@ public class IpServiceTest extends ComponentTestCase {
System
.
out
.
println
(
info
.
getChannel
());
System
.
out
.
println
(
info
.
getCity
());
System
.
out
.
println
(
info
.
getProvince
());
}
else
{
System
.
err
.
println
(
"===="
);
}
}
}
...
...
cat-broker/src/test/java/com/dianping/cat/broker/PostTest.java
浏览文件 @
0dfcc047
...
...
@@ -21,35 +21,35 @@ public class PostTest {
while
(
true
)
{
long
time
=
System
.
currentTimeMillis
();
long
time
=
System
.
currentTimeMillis
()
-
60
*
1000
*
5
;
String
url
=
null
;
for
(
int
i
=
0
;
i
<
100
;
i
++)
{
url
=
"http://"
+
host
+
"/broker-service/api/singel?v=1.0&tu=http://www.dianping.com/test&d=100&hs=200&ts="
+
time
;
url
=
"http://"
+
host
+
"/broker-service/api/singel?v=1.0&tu=http://www.dianping.com/test&d=100&hs=200&ts="
+
time
;
System
.
out
.
println
(
url
);
read
(
url
);
}
for
(
int
i
=
0
;
i
<
150
;
i
++)
{
url
=
"http://"
+
host
+
"/broker-service/api/singel?v=1.0&tu=http://www.dianping.com/test&d=100&hs=300&ts="
+
time
;
url
=
"http://"
+
host
+
"/broker-service/api/singel?v=1.0&tu=http://www.dianping.com/test&d=100&hs=300&ts="
+
time
;
read
(
url
);
}
for
(
int
i
=
0
;
i
<
200
;
i
++)
{
url
=
"http://"
+
host
+
"/broker-service/api/singel?v=1.0&tu=http://www.dianping.com/test&d=100&hs=400&ts="
+
time
;
url
=
"http://"
+
host
+
"/broker-service/api/singel?v=1.0&tu=http://www.dianping.com/test&d=100&hs=400&ts="
+
time
;
read
(
url
);
}
for
(
int
i
=
0
;
i
<
250
;
i
++)
{
url
=
"http://"
+
host
+
"/broker-service/api/singel?v=1.0&tu=http://www.dianping.com/test&d=100&ec=300&ts="
+
time
;
url
=
"http://"
+
host
+
"/broker-service/api/singel?v=1.0&tu=http://www.dianping.com/test&d=100&ec=300&ts="
+
time
;
read
(
url
);
}
for
(
int
i
=
0
;
i
<
300
;
i
++)
{
url
=
"http://"
+
host
+
"/broker-service/api/singel?v=1.0&tu=http://www.dianping.com/test&d=100&ec=400&ts="
+
time
;
url
=
"http://"
+
host
+
"/broker-service/api/singel?v=1.0&tu=http://www.dianping.com/test&d=100&ec=400&ts="
+
time
;
read
(
url
);
}
Thread
.
sleep
(
20
*
1000
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录