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

app data

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