提交 6d9dcb4d 编写于 作者: 曾伟伟

app data

上级 0946b4f0
......@@ -147,6 +147,7 @@ public class BucketHandler implements Task {
m_appDataService.insert(proto);
} catch (Exception e) {
Cat.logError(e);
e.printStackTrace();
saveToFile(appData);
}
......
......@@ -116,6 +116,7 @@ public class Handler implements PageHandler<Context>, LogEnabled {
}
private void processVersion2(Payload payload, HttpServletRequest request, String userIp) {
userIp = "180.153.132.49";
if (userIp != null) {
String content = payload.getContent();
String records[] = content.split("\n");
......@@ -126,7 +127,7 @@ public class Handler implements PageHandler<Context>, LogEnabled {
String operatorStr = ipInfo.getChannel();
Integer cityId = m_appConfigManager.getCities().get(province);
Integer operatorId = m_appConfigManager.getOperators().get(operatorStr);
if (cityId != null && operatorId != null) {
for (String record : records) {
processOneRecord(cityId, operatorId, record);
......@@ -146,7 +147,7 @@ public class Handler implements PageHandler<Context>, LogEnabled {
try {
appData.setTimestamp(Long.parseLong(items[0]));
Integer command = m_appConfigManager.getCommands().get(items[2]);
Integer command = m_appConfigManager.getCommands().get(items[1]);
if (command != null) {
appData.setCommand(command);
......
......@@ -17,7 +17,7 @@ public class AppTest {
long timestamp = System.currentTimeMillis();
for (int i = 0; i < 10; i++) {
urls.add(url_pre + "?v=2&c=" + timestamp + URLEncoder.encode("\tshop.bin\t1\t1\t1\t1\t1\t1\t1\t1\n", "utf-8"));
urls.add(url_pre + "?v=2&c=" + timestamp + URLEncoder.encode("\thttp://www.dianping.com/\t1\t1\t1\t1\t1\t1\t1\t1\n", "utf-8"));
}
for (String url : urls) {
......
......@@ -121,6 +121,7 @@ public class DomainManager implements Initializable, LogEnabled {
return true;
} catch (Exception ex) {
Cat.logError(ex);
ex.printStackTrace();
}
return false;
}
......
......@@ -71,6 +71,7 @@ public class AppConfigManager implements Initializable {
m_configId = config.getId();
m_config = DefaultSaxParser.parse(content);
m_modifyTime = config.getModifyDate().getTime();
refreshData();
} catch (DalNotFoundException e) {
try {
String content = Files.forIO().readFrom(
......@@ -132,14 +133,14 @@ public class AppConfigManager implements Initializable {
public Map<String, Integer> getCommands() {
return m_commands;
}
public Map<String, Integer> getCities() {
return m_cities;
}
return m_cities;
}
public Map<String, Integer> getOperators() {
return m_operators;
}
return m_operators;
}
private void refreshData() {
Collection<Command> commands = m_config.getCommands().values();
......@@ -149,19 +150,19 @@ public class AppConfigManager implements Initializable {
commandMap.put(c.getName(), c.getId());
}
m_commands = commandMap;
Map<String, Integer> cityMap = new HashMap<String, Integer>();
ConfigItem cities = m_config.findConfigItem(CITY);
for(Item item:cities.getItems().values()){
for (Item item : cities.getItems().values()) {
cityMap.put(item.getName(), item.getId());
}
m_cities = cityMap;
Map<String, Integer> operatorMap = new HashMap<String, Integer>();
ConfigItem operations = m_config.findConfigItem(OPERATOR);
for(Item item:operations.getItems().values()){
for (Item item : operations.getItems().values()) {
operatorMap.put(item.getName(), item.getId());
}
m_operators = operatorMap;
......
......@@ -56,6 +56,7 @@ public class AppDataService {
return querySuccessRatio(dataPair);
} else {
datas = m_dao.findDataByMinute(commandId, period, city, operator, network, appVersion, connnectType, code,
platform, AppDataCommandEntity.READSET_COUNT_DATA);
Pair<Integer, Map<Integer, List<AppDataCommand>>> dataPair = convert2AppDataCommandMap(datas);
......@@ -68,6 +69,7 @@ public class AppDataService {
}
} catch (Exception e) {
Cat.logError(e);
e.printStackTrace();
}
return null;
}
......@@ -95,7 +97,9 @@ public class AppDataService {
}
data.add(from);
}
int n = (max - min) / 5;
int gap = max - min;
int n = gap <= 0 ? max / 5 : gap / 5;
return new Pair<Integer, Map<Integer, List<AppDataCommand>>>(n, dataMap);
}
......@@ -117,10 +121,11 @@ public class AppDataService {
}
sum += number;
}
value[key / 5] = (double) success / sum;
value[key / 5 - 1] = (double) success / sum;
}
} catch (Exception e) {
Cat.logError(e);
e.printStackTrace();
}
return value;
......@@ -129,7 +134,6 @@ public class AppDataService {
private boolean isSuccessStatus(AppDataCommand data) {
int code = data.getCode();
Collection<Code> codes = m_appConfigManager.queryCodeByCommand(data.getCommandId());
for (Code c : codes) {
if (c.getId() == code) {
return (c.getStatus() == 0);
......@@ -145,7 +149,7 @@ public class AppDataService {
for (AppDataCommand data : entry.getValue()) {
long count = data.getAccessNumberSum();
value[data.getMinuteOrder() / 5] = count;
value[data.getMinuteOrder() / 5 - 1] = count;
}
}
return value;
......@@ -160,7 +164,7 @@ public class AppDataService {
long sum = data.getResponseSumTimeSum();
double avg = sum / count;
value[data.getMinuteOrder() / 5] = avg;
value[data.getMinuteOrder() / 5 - 1] = avg;
}
}
return value;
......
......@@ -5,8 +5,10 @@
<item id="3" name="4G"></item>
</config-item>
<config-item id="运营商">
<item id="1" name="移动"></item>
<item id="2" name="联通"></item>
<item id="1" name="中国移动"></item>
<item id="2" name="中国联通"></item>
<item id="3" name="中国电信"></item>
<item id="4" name="中国铁通"></item>
</config-item>
<config-item id="版本">
<item id="1" name="1.0"></item>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册