|
@@ -58,8 +58,8 @@ public class JavaApiStaticsMapper implements IJavaApiStaticsMapper { |
|
@@ -58,8 +58,8 @@ public class JavaApiStaticsMapper implements IJavaApiStaticsMapper { |
58
|
.addField("mobj_ip", statics.getString("mobj_ip"))
|
58
|
.addField("mobj_ip", statics.getString("mobj_ip"))
|
59
|
.addField("mobj_id", statics.getIntValue("mobj_id"))
|
59
|
.addField("mobj_id", statics.getIntValue("mobj_id"))
|
60
|
.addField("mobj_port", statics.getString("mobj_port"))
|
60
|
.addField("mobj_port", statics.getString("mobj_port"))
|
61
|
- .addField("start", statics.getLongValue("start"))
|
|
|
62
|
- .addField("end", statics.getLongValue("end"))
|
61
|
+ .addField("start_time", statics.getLongValue("start"))
|
|
|
62
|
+ .addField("end_time", statics.getLongValue("end"))
|
63
|
.addField("is_exception", statics.getBooleanValue("is_exception"))
|
63
|
.addField("is_exception", statics.getBooleanValue("is_exception"))
|
64
|
.time(System.currentTimeMillis() * 1000000 + random.nextInt(999999), TimeUnit.NANOSECONDS);
|
64
|
.time(System.currentTimeMillis() * 1000000 + random.nextInt(999999), TimeUnit.NANOSECONDS);
|
65
|
|
65
|
|
|
@@ -101,8 +101,8 @@ public class JavaApiStaticsMapper implements IJavaApiStaticsMapper { |
|
@@ -101,8 +101,8 @@ public class JavaApiStaticsMapper implements IJavaApiStaticsMapper { |
101
|
QueryResult.Series series = rel.getSeries().get(0);
|
101
|
QueryResult.Series series = rel.getSeries().get(0);
|
102
|
|
102
|
|
103
|
Boolean is_exception = (Boolean) series.getValues().get(0).get(series.getColumns().indexOf("is_exception"));
|
103
|
Boolean is_exception = (Boolean) series.getValues().get(0).get(series.getColumns().indexOf("is_exception"));
|
104
|
- long startTime = Math.round((Double) series.getValues().get(0).get(series.getColumns().indexOf("start")));
|
|
|
105
|
- long endTime = Math.round((Double) series.getValues().get(0).get(series.getColumns().indexOf("end")));
|
104
|
+ long startTime = Math.round((Double) series.getValues().get(0).get(series.getColumns().indexOf("start_time")));
|
|
|
105
|
+ long endTime = Math.round((Double) series.getValues().get(0).get(series.getColumns().indexOf("end_time")));
|
106
|
long costTime = (endTime - startTime);
|
106
|
long costTime = (endTime - startTime);
|
107
|
|
107
|
|
108
|
String exception = (String) series.getValues().get(0).get(series.getColumns().indexOf("exception"));
|
108
|
String exception = (String) series.getValues().get(0).get(series.getColumns().indexOf("exception"));
|
|
@@ -126,28 +126,26 @@ public class JavaApiStaticsMapper implements IJavaApiStaticsMapper { |
|
@@ -126,28 +126,26 @@ public class JavaApiStaticsMapper implements IJavaApiStaticsMapper { |
126
|
}
|
126
|
}
|
127
|
|
127
|
|
128
|
|
128
|
|
|
|
129
|
+ /**
|
|
|
130
|
+ * 批量查询
|
|
|
131
|
+ *
|
|
|
132
|
+ * @param influxDBName
|
|
|
133
|
+ * @param paramList
|
|
|
134
|
+ * @return
|
|
|
135
|
+ */
|
129
|
@Override
|
136
|
@Override
|
130
|
public List<JavaApiStaticsModel> selectlatestJavaApiStaticsList(String influxDBName, List<JavaApiStatusReq> paramList) {
|
137
|
public List<JavaApiStaticsModel> selectlatestJavaApiStaticsList(String influxDBName, List<JavaApiStatusReq> paramList) {
|
131
|
|
138
|
|
132
|
- //TODO 后期改批量查询
|
|
|
133
|
-
|
|
|
134
|
List<JavaApiStaticsModel> javaApiStaticsModels = new ArrayList<JavaApiStaticsModel>();
|
139
|
List<JavaApiStaticsModel> javaApiStaticsModels = new ArrayList<JavaApiStaticsModel>();
|
135
|
-
|
|
|
136
|
-
|
|
|
137
|
StringBuilder sb = new StringBuilder();
|
140
|
StringBuilder sb = new StringBuilder();
|
138
|
-
|
|
|
139
|
for (JavaApiStatusReq param : paramList) {
|
141
|
for (JavaApiStatusReq param : paramList) {
|
140
|
-
|
|
|
141
|
int api_id = param.getServiceId();
|
142
|
int api_id = param.getServiceId();
|
142
|
int mobj_id = param.getMObjectId();
|
143
|
int mobj_id = param.getMObjectId();
|
143
|
- sb.append("select * from " + InfluxDBContants.YOMO_TB_JAVAAPI + " where time > now() - 1h ");
|
144
|
+ sb.append("select api_id,mobj_id,start_time,end_time,is_exception,exception from " + InfluxDBContants.YOMO_TB_JAVAAPI + " where time > now() - 1h ");
|
144
|
sb.append(" and api_id=" + api_id);
|
145
|
sb.append(" and api_id=" + api_id);
|
145
|
sb.append(" and mobj_id=" + mobj_id);
|
146
|
sb.append(" and mobj_id=" + mobj_id);
|
146
|
sb.append(" order by time desc limit 1;");
|
147
|
sb.append(" order by time desc limit 1;");
|
147
|
-
|
|
|
148
|
-
|
|
|
149
|
}
|
148
|
}
|
150
|
-
|
|
|
151
|
Query query = new Query(sb.toString(), InfluxDBContants.APP_ALARM);
|
149
|
Query query = new Query(sb.toString(), InfluxDBContants.APP_ALARM);
|
152
|
|
150
|
|
153
|
QueryResult result = inluxDBSingle.getInfluxDBByName(InfluxDBContants.ALARM).getInfluxDB().query(query);
|
151
|
QueryResult result = inluxDBSingle.getInfluxDBByName(InfluxDBContants.ALARM).getInfluxDB().query(query);
|
|
@@ -159,8 +157,8 @@ public class JavaApiStaticsMapper implements IJavaApiStaticsMapper { |
|
@@ -159,8 +157,8 @@ public class JavaApiStaticsMapper implements IJavaApiStaticsMapper { |
159
|
QueryResult.Series series = queryResult.getSeries().get(0);
|
157
|
QueryResult.Series series = queryResult.getSeries().get(0);
|
160
|
|
158
|
|
161
|
Boolean is_exception = (Boolean) series.getValues().get(0).get(series.getColumns().indexOf("is_exception"));
|
159
|
Boolean is_exception = (Boolean) series.getValues().get(0).get(series.getColumns().indexOf("is_exception"));
|
162
|
- long startTime = Math.round((Double) series.getValues().get(0).get(series.getColumns().indexOf("start")));
|
|
|
163
|
- long endTime = Math.round((Double) series.getValues().get(0).get(series.getColumns().indexOf("end")));
|
160
|
+ long startTime = Math.round((Double) series.getValues().get(0).get(series.getColumns().indexOf("start_time")));
|
|
|
161
|
+ long endTime = Math.round((Double) series.getValues().get(0).get(series.getColumns().indexOf("end_time")));
|
164
|
long costTime = (endTime - startTime);
|
162
|
long costTime = (endTime - startTime);
|
165
|
|
163
|
|
166
|
int api_id = ((Double) series.getValues().get(0).get(series.getColumns().indexOf("api_id"))).intValue();
|
164
|
int api_id = ((Double) series.getValues().get(0).get(series.getColumns().indexOf("api_id"))).intValue();
|
|
@@ -242,8 +240,8 @@ public class JavaApiStaticsMapper implements IJavaApiStaticsMapper { |
|
@@ -242,8 +240,8 @@ public class JavaApiStaticsMapper implements IJavaApiStaticsMapper { |
242
|
for (int i = 0; i < size; i++) {
|
240
|
for (int i = 0; i < size; i++) {
|
243
|
JavaApiStaticsModel javaApiStaticsModel = new JavaApiStaticsModel();
|
241
|
JavaApiStaticsModel javaApiStaticsModel = new JavaApiStaticsModel();
|
244
|
Boolean is_exception = (Boolean) series.getValues().get(i).get(series.getColumns().indexOf("is_exception"));
|
242
|
Boolean is_exception = (Boolean) series.getValues().get(i).get(series.getColumns().indexOf("is_exception"));
|
245
|
- long startTime = Math.round((Double) series.getValues().get(i).get(series.getColumns().indexOf("start")));
|
|
|
246
|
- long endTime = Math.round((Double) series.getValues().get(i).get(series.getColumns().indexOf("end")));
|
243
|
+ long startTime = Math.round((Double) series.getValues().get(i).get(series.getColumns().indexOf("start_time")));
|
|
|
244
|
+ long endTime = Math.round((Double) series.getValues().get(i).get(series.getColumns().indexOf("end_time")));
|
247
|
long costTime = (endTime - startTime);
|
245
|
long costTime = (endTime - startTime);
|
248
|
|
246
|
|
249
|
|
247
|
|