You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by wu...@apache.org on 2018/11/03 12:09:09 UTC

[incubator-skywalking] branch int-long created (now d508cdb)

This is an automated email from the ASF dual-hosted git repository.

wusheng pushed a change to branch int-long
in repository https://gitbox.apache.org/repos/asf/incubator-skywalking.git.


      at d508cdb  Make metric value to long to avoid too big integer issue.

This branch includes the following new commits:

     new d508cdb  Make metric value to long to avoid too big integer issue.

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[incubator-skywalking] 01/01: Make metric value to long to avoid too big integer issue.

Posted by wu...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

wusheng pushed a commit to branch int-long
in repository https://gitbox.apache.org/repos/asf/incubator-skywalking.git

commit d508cdb39131df6ea4b2292f4eec4faf711da7db
Author: Wu Sheng <wu...@foxmail.com>
AuthorDate: Sat Nov 3 20:08:59 2018 +0800

    Make metric value to long to avoid too big integer issue.
---
 .../skywalking/oap/server/core/query/entity/IntValues.java     |  2 +-
 .../apache/skywalking/oap/server/core/query/entity/KVInt.java  |  2 +-
 .../skywalking/oap/server/core/query/entity/TopNEntity.java    |  2 +-
 .../plugin/elasticsearch/query/AggregationQueryEsDAO.java      |  2 +-
 .../storage/plugin/elasticsearch/query/MetricQueryEsDAO.java   | 10 +++++-----
 .../storage/plugin/jdbc/h2/dao/H2AggregationQueryDAO.java      |  2 +-
 .../server/storage/plugin/jdbc/h2/dao/H2MetricQueryDAO.java    |  4 ++--
 7 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/entity/IntValues.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/entity/IntValues.java
index aab3dff..20f15ef 100644
--- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/entity/IntValues.java
+++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/entity/IntValues.java
@@ -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();
diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/entity/KVInt.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/entity/KVInt.java
index 1d16ad1..7965285 100644
--- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/entity/KVInt.java
+++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/entity/KVInt.java
@@ -27,5 +27,5 @@ import lombok.*;
 @Getter
 public class KVInt {
     private String id;
-    private int value;
+    private long value;
 }
diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/entity/TopNEntity.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/entity/TopNEntity.java
index 8eb8930..49f4c15 100644
--- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/entity/TopNEntity.java
+++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/entity/TopNEntity.java
@@ -28,5 +28,5 @@ import lombok.*;
 public class TopNEntity {
     private String name;
     private String id;
-    private int value;
+    private long value;
 }
diff --git a/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/query/AggregationQueryEsDAO.java b/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/query/AggregationQueryEsDAO.java
index a3a79f7..e1216d8 100644
--- a/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/query/AggregationQueryEsDAO.java
+++ b/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/query/AggregationQueryEsDAO.java
@@ -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);
         }
 
diff --git a/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/query/MetricQueryEsDAO.java b/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/query/MetricQueryEsDAO.java
index b4ae33d..3ee9d47 100644
--- a/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/query/MetricQueryEsDAO.java
+++ b/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/query/MetricQueryEsDAO.java
@@ -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);
         }
diff --git a/oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/h2/dao/H2AggregationQueryDAO.java b/oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/h2/dao/H2AggregationQueryDAO.java
index 5633f8a..7137643 100644
--- a/oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/h2/dao/H2AggregationQueryDAO.java
+++ b/oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/h2/dao/H2AggregationQueryDAO.java
@@ -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) {
diff --git a/oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/h2/dao/H2MetricQueryDAO.java b/oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/h2/dao/H2MetricQueryDAO.java
index b49bef1..a8093a6 100644
--- a/oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/h2/dao/H2MetricQueryDAO.java
+++ b/oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/h2/dao/H2MetricQueryDAO.java
@@ -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);
                 }
             }