Make metric value to long to avoid too big integer issue. (#1876)
* Make metric value to long to avoid too big integer issue. * Update protocol. * Add a new filter to service number.
This commit is contained in:
parent
5f867ad739
commit
4399c66278
|
|
@ -32,7 +32,7 @@ public class IntValues {
|
|||
values.add(e);
|
||||
}
|
||||
|
||||
public int findValue(String id, int defaultValue) {
|
||||
public long findValue(String id, int defaultValue) {
|
||||
for (KVInt value : values) {
|
||||
if (value.getId().equals(id)) {
|
||||
return value.getValue();
|
||||
|
|
|
|||
|
|
@ -27,5 +27,5 @@ import lombok.*;
|
|||
@Getter
|
||||
public class KVInt {
|
||||
private String id;
|
||||
private int value;
|
||||
private long value;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,5 +28,5 @@ import lombok.*;
|
|||
public class TopNEntity {
|
||||
private String name;
|
||||
private String id;
|
||||
private int value;
|
||||
private long value;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
Subproject commit 1122e97b5604ae96447bd58ecdb248d7e02952aa
|
||||
Subproject commit c65a23bd6b9bba8d1df30d4de261624952df2b7b
|
||||
|
|
@ -129,7 +129,7 @@ public class AggregationQueryEsDAO extends EsDAO implements IAggregationQueryDAO
|
|||
TopNEntity topNEntity = new TopNEntity();
|
||||
topNEntity.setId(termsBucket.getKeyAsString());
|
||||
Avg value = termsBucket.getAggregations().get(valueCName);
|
||||
topNEntity.setValue((int)value.getValue());
|
||||
topNEntity.setValue((long)value.getValue());
|
||||
topNEntities.add(topNEntity);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -61,19 +61,19 @@ public class MetricQueryEsDAO extends EsDAO implements IMetricQueryDAO {
|
|||
IntValues intValues = new IntValues();
|
||||
Terms idTerms = response.getAggregations().get(Indicator.ENTITY_ID);
|
||||
for (Terms.Bucket idBucket : idTerms.getBuckets()) {
|
||||
int value = 0;
|
||||
long value = 0;
|
||||
switch (function) {
|
||||
case Sum:
|
||||
Sum sum = idBucket.getAggregations().get(valueCName);
|
||||
value = (int)sum.getValue();
|
||||
value = (long)sum.getValue();
|
||||
break;
|
||||
case Avg:
|
||||
Avg avg = idBucket.getAggregations().get(valueCName);
|
||||
value = (int)avg.getValue();
|
||||
value = (long)avg.getValue();
|
||||
break;
|
||||
default:
|
||||
avg = idBucket.getAggregations().get(valueCName);
|
||||
value = (int)avg.getValue();
|
||||
value = (long)avg.getValue();
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
@ -113,7 +113,7 @@ public class MetricQueryEsDAO extends EsDAO implements IMetricQueryDAO {
|
|||
kvInt.setValue(0);
|
||||
Map<String, Object> source = itemResponse.getResponse().getSource();
|
||||
if (source != null) {
|
||||
kvInt.setValue(((Number)source.getOrDefault(valueCName, 0)).intValue());
|
||||
kvInt.setValue(((Number)source.getOrDefault(valueCName, 0)).longValue());
|
||||
}
|
||||
intValues.getValues().add(kvInt);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -102,7 +102,7 @@ public class H2AggregationQueryDAO implements IAggregationQueryDAO {
|
|||
while (resultSet.next()) {
|
||||
TopNEntity topNEntity = new TopNEntity();
|
||||
topNEntity.setId(resultSet.getString(Indicator.ENTITY_ID));
|
||||
topNEntity.setValue(resultSet.getInt("value"));
|
||||
topNEntity.setValue(resultSet.getLong("value"));
|
||||
topNEntities.add(topNEntity);
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
|
|
|
|||
|
|
@ -55,6 +55,7 @@ public class H2MetadataQueryDAO implements IMetadataQueryDAO {
|
|||
List<Object> condition = new ArrayList<>(5);
|
||||
sql.append("select count(*) num from ").append(ServiceInventory.MODEL_NAME).append(" where ");
|
||||
setTimeRangeCondition(sql, condition, startTimestamp, endTimestamp);
|
||||
sql.append(" and ").append(ServiceInventory.IS_ADDRESS).append("=0");
|
||||
|
||||
Connection connection = null;
|
||||
try {
|
||||
|
|
|
|||
|
|
@ -103,7 +103,7 @@ public class H2MetricQueryDAO extends H2SQLExecutor implements IMetricQueryDAO {
|
|||
while (resultSet.next()) {
|
||||
KVInt kv = new KVInt();
|
||||
kv.setId(resultSet.getString("id"));
|
||||
kv.setValue(resultSet.getInt("value"));
|
||||
kv.setValue(resultSet.getLong("value"));
|
||||
intValues.getValues().add(kv);
|
||||
}
|
||||
}
|
||||
|
|
@ -136,7 +136,7 @@ public class H2MetricQueryDAO extends H2SQLExecutor implements IMetricQueryDAO {
|
|||
while (resultSet.next()) {
|
||||
KVInt kv = new KVInt();
|
||||
kv.setId(resultSet.getString("id"));
|
||||
kv.setValue(resultSet.getInt(valueCName));
|
||||
kv.setValue(resultSet.getLong(valueCName));
|
||||
intValues.getValues().add(kv);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue