提交 0dfcc047 编写于 作者: Y youyong205

modify the broker service

上级 f75ab1bb
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 (IOException e) {
} catch (Exception e) {
Cat.logError(e);
}
}
......
......@@ -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("====");
}
}
}
......
......@@ -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.
先完成此消息的编辑!
想要评论请 注册