Authored by FengRuwei

添加更新时间

package com.monitor.javaserver.common;
import com.monitor.common.util.DateFormatUtil;
import com.monitor.model.response.JavaApiStaticsRep;
import com.monitor.model.response.JavaApiStatusRep;
import org.apache.commons.collections.map.MultiKeyMap;
... ... @@ -28,24 +29,33 @@ public class JavaApiStatus {
private ConcurrentHashMap<String, Long> mapUpdateTime = new ConcurrentHashMap<String, Long>();
public void addError(int apiType, int cloud) {
public void addError(JavaApiStatics javaApiStatics) {
int apiType = javaApiStatics.getJavaApiInfo().getServiceType();
int cloud = javaApiStatics.getMObjectDetails().getCloudType();
String key = cloud + "_" + apiType;
mapStaticsErr.putIfAbsent(key, new AtomicInteger(0));
mapStaticsErr.get(key).getAndIncrement();
mapUpdateTime.putIfAbsent(key, javaApiStatics.getEndTime());
}
public void addSuccess(int apiType, int cloud) {
public void addSuccess(JavaApiStatics javaApiStatics) {
int apiType = javaApiStatics.getJavaApiInfo().getServiceType();
int cloud = javaApiStatics.getMObjectDetails().getCloudType();
String key = cloud + "_" + apiType;
mapStaticsOk.putIfAbsent(key, new AtomicInteger(0));
mapStaticsOk.get(key).getAndIncrement();
mapUpdateTime.putIfAbsent(key, javaApiStatics.getEndTime());
}
public void clear() {
mapStaticsErr.clear();
mapStaticsOk.clear();
mapUpdateTime.clear();
}
... ... @@ -87,6 +97,12 @@ public class JavaApiStatus {
rel.add(statics);
}
long time;
for (JavaApiStaticsRep javaApiStaticsRep : rel) {
time = mapUpdateTime.get(javaApiStaticsRep.getCloudType() + "_" + javaApiStaticsRep.getServiceType());
javaApiStaticsRep.setUpdateTime(DateFormatUtil.parseLongToTimeStr(time));
}
return rel;
}
... ...
... ... @@ -27,9 +27,9 @@ public class StaticsJavaApiHandler implements IJavaApiHadnler {
return;
}
if (javaApiStatics.isHasException()) {
javaApiStatus.addError(javaApiStatics.getJavaApiInfo().getServiceType(), javaApiStatics.getMObjectDetails().getCloudType());
javaApiStatus.addError(javaApiStatics);
} else {
javaApiStatus.addSuccess(javaApiStatics.getJavaApiInfo().getServiceType(), javaApiStatics.getMObjectDetails().getCloudType());
javaApiStatus.addSuccess(javaApiStatics);
}
}
... ...
... ... @@ -16,7 +16,7 @@
http://www.springframework.org/schema/task
http://www.springframework.org/schema/task/spring-task.xsd">
<context:property-placeholder location="classpath:*.properties" />
<context:property-placeholder location="classpath:test/*.properties" />
<context:component-scan base-package="com.monitor" />
... ...
... ... @@ -2,7 +2,7 @@
influxdb.num=2
influxdb.name=test;alarm
influxdb.ip=http://192.168.102.162:8086;http://123.206.79.151:18086
influxdb.ip=http://192.168.102.162:8086;http://192.168.102.162:8086
influxdb.user=yoho;root
influxdb.pwd=Yoho_9646;root
influxdb.connect.timeout=15;15
... ...