wu-sheng closed pull request #900: Table name and time bucket error
URL: https://github.com/apache/incubator-skywalking/pull/900
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git 
a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/utils/TimePyramidTableNameBuilder.java
 
b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/utils/TimePyramidTableNameBuilder.java
index 6bfd365ee..57acbcb14 100644
--- 
a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/utils/TimePyramidTableNameBuilder.java
+++ 
b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/utils/TimePyramidTableNameBuilder.java
@@ -39,7 +39,7 @@ public static String build(Step step, String tableName) {
                 tableName = tableName + Const.ID_SPLIT + 
TimePyramid.Day.getName();
                 break;
             case HOUR:
-                tableName = tableName + Const.ID_SPLIT + 
TimePyramid.Day.getName();
+                tableName = tableName + Const.ID_SPLIT + 
TimePyramid.Hour.getName();
                 break;
             case MINUTE:
                 tableName = tableName + Const.ID_SPLIT + 
TimePyramid.Minute.getName();
diff --git 
a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ui/InstanceEsUIDAO.java
 
b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ui/InstanceEsUIDAO.java
index e3a048fb8..d3d7eff89 100644
--- 
a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ui/InstanceEsUIDAO.java
+++ 
b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ui/InstanceEsUIDAO.java
@@ -106,6 +106,7 @@ private Long heartBeatTime(AbstractQueryBuilder 
queryBuilder) {
 
         BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery();
 
+        //TODO second
         BoolQueryBuilder timeBoolQuery = QueryBuilders.boolQuery();
         
timeBoolQuery.should().add(QueryBuilders.rangeQuery(InstanceTable.COLUMN_REGISTER_TIME).gte(startSecondTimeBucket).lte(endSecondTimeBucket));
         
timeBoolQuery.should().add(QueryBuilders.rangeQuery(InstanceTable.COLUMN_HEARTBEAT_TIME).gte(startSecondTimeBucket).lte(endSecondTimeBucket));
@@ -171,6 +172,7 @@ private Long heartBeatTime(AbstractQueryBuilder 
queryBuilder) {
         }
         
boolQuery.must().add(QueryBuilders.termQuery(InstanceTable.COLUMN_IS_ADDRESS, 
BooleanUtils.FALSE));
 
+        //TODO second
         BoolQueryBuilder timeBoolQuery = QueryBuilders.boolQuery();
         
timeBoolQuery.should().add(QueryBuilders.rangeQuery(InstanceTable.COLUMN_REGISTER_TIME).gte(startSecondTimeBucket).lte(endSecondTimeBucket));
         
timeBoolQuery.should().add(QueryBuilders.rangeQuery(InstanceTable.COLUMN_HEARTBEAT_TIME).gte(startSecondTimeBucket).lte(endSecondTimeBucket));
@@ -197,6 +199,7 @@ private Long heartBeatTime(AbstractQueryBuilder 
queryBuilder) {
         
boolQuery.must().add(QueryBuilders.termQuery(InstanceTable.COLUMN_APPLICATION_ID,
 applicationId));
         
boolQuery.must().add(QueryBuilders.termQuery(InstanceTable.COLUMN_IS_ADDRESS, 
BooleanUtils.FALSE));
 
+        //TODO second
         BoolQueryBuilder timeBoolQuery = QueryBuilders.boolQuery();
         
timeBoolQuery.should().add(QueryBuilders.rangeQuery(InstanceTable.COLUMN_REGISTER_TIME).gte(startSecondTimeBucket).lte(endSecondTimeBucket));
         
timeBoolQuery.should().add(QueryBuilders.rangeQuery(InstanceTable.COLUMN_HEARTBEAT_TIME).gte(startSecondTimeBucket).lte(endSecondTimeBucket));
diff --git 
a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ui/SegmentDurationEsUIDAO.java
 
b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ui/SegmentDurationEsUIDAO.java
index 90046b2d3..22f9b8405 100644
--- 
a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ui/SegmentDurationEsUIDAO.java
+++ 
b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ui/SegmentDurationEsUIDAO.java
@@ -57,6 +57,7 @@ public TraceBrief loadTop(long startSecondTimeBucket, long 
endSecondTimeBucket,
         List<QueryBuilder> mustQueryList = boolQueryBuilder.must();
 
         if (startSecondTimeBucket != 0 && endSecondTimeBucket != 0) {
+            //TODO second
             
mustQueryList.add(QueryBuilders.rangeQuery(SegmentDurationTable.COLUMN_TIME_BUCKET).gte(startSecondTimeBucket).lte(endSecondTimeBucket));
         }
 
diff --git 
a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/query/AlarmQuery.java
 
b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/query/AlarmQuery.java
index c56ae44a3..040b58d9d 100644
--- 
a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/query/AlarmQuery.java
+++ 
b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/query/AlarmQuery.java
@@ -51,8 +51,8 @@ private AlarmService getAlarmService() {
 
     public Alarm loadAlarmList(String keyword, AlarmType alarmType, Duration 
duration,
         Pagination paging) throws ParseException {
-        long startTimeBucket = 
DurationUtils.INSTANCE.durationToSecondTimeBucket(duration.getStep(), 
duration.getStart()) / 100;
-        long endTimeBucket = 
DurationUtils.INSTANCE.durationToSecondTimeBucket(duration.getStep(), 
duration.getEnd()) / 100;
+        long startTimeBucket = 
DurationUtils.INSTANCE.startTimeDurationToSecondTimeBucket(duration.getStep(), 
duration.getStart()) / 100;
+        long endTimeBucket = 
DurationUtils.INSTANCE.endTimeDurationToSecondTimeBucket(duration.getStep(), 
duration.getEnd()) / 100;
 
         PaginationUtils.Page page = PaginationUtils.INSTANCE.exchange(paging);
 
diff --git 
a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/query/ApplicationQuery.java
 
b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/query/ApplicationQuery.java
index aa48d3d97..2a4bac3c7 100644
--- 
a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/query/ApplicationQuery.java
+++ 
b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/query/ApplicationQuery.java
@@ -69,8 +69,8 @@ private ServerService getServerService() {
     }
 
     public List<Application> getAllApplication(Duration duration) throws 
ParseException {
-        long startSecondTimeBucket = 
DurationUtils.INSTANCE.durationToSecondTimeBucket(duration.getStep(), 
duration.getStart());
-        long endSecondTimeBucket = 
DurationUtils.INSTANCE.durationToSecondTimeBucket(duration.getStep(), 
duration.getEnd());
+        long startSecondTimeBucket = 
DurationUtils.INSTANCE.startTimeDurationToSecondTimeBucket(duration.getStep(), 
duration.getStart());
+        long endSecondTimeBucket = 
DurationUtils.INSTANCE.endTimeDurationToSecondTimeBucket(duration.getStep(), 
duration.getEnd());
 
         return getApplicationService().getApplications(startSecondTimeBucket, 
endSecondTimeBucket);
     }
@@ -79,8 +79,8 @@ public Topology getApplicationTopology(int applicationId, 
Duration duration) thr
         long startTimeBucket = 
DurationUtils.INSTANCE.exchangeToTimeBucket(duration.getStart());
         long endTimeBucket = 
DurationUtils.INSTANCE.exchangeToTimeBucket(duration.getEnd());
 
-        long startSecondTimeBucket = 
DurationUtils.INSTANCE.durationToSecondTimeBucket(duration.getStep(), 
duration.getStart());
-        long endSecondTimeBucket = 
DurationUtils.INSTANCE.durationToSecondTimeBucket(duration.getStep(), 
duration.getEnd());
+        long startSecondTimeBucket = 
DurationUtils.INSTANCE.startTimeDurationToSecondTimeBucket(duration.getStep(), 
duration.getStart());
+        long endSecondTimeBucket = 
DurationUtils.INSTANCE.endTimeDurationToSecondTimeBucket(duration.getStep(), 
duration.getEnd());
 
         return 
getApplicationTopologyService().getApplicationTopology(duration.getStep(), 
applicationId, startTimeBucket, endTimeBucket, startSecondTimeBucket, 
endSecondTimeBucket);
     }
@@ -90,8 +90,8 @@ public Topology getApplicationTopology(int applicationId, 
Duration duration) thr
         long startTimeBucket = 
DurationUtils.INSTANCE.exchangeToTimeBucket(duration.getStart());
         long endTimeBucket = 
DurationUtils.INSTANCE.exchangeToTimeBucket(duration.getEnd());
 
-        long startSecondTimeBucket = 
DurationUtils.INSTANCE.durationToSecondTimeBucket(duration.getStep(), 
duration.getStart());
-        long endSecondTimeBucket = 
DurationUtils.INSTANCE.durationToSecondTimeBucket(duration.getStep(), 
duration.getEnd());
+        long startSecondTimeBucket = 
DurationUtils.INSTANCE.startTimeDurationToSecondTimeBucket(duration.getStep(), 
duration.getStart());
+        long endSecondTimeBucket = 
DurationUtils.INSTANCE.endTimeDurationToSecondTimeBucket(duration.getStep(), 
duration.getEnd());
 
         return getApplicationService().getSlowService(applicationId, 
duration.getStep(), startTimeBucket, endTimeBucket, startSecondTimeBucket, 
endSecondTimeBucket, topN);
     }
@@ -101,8 +101,8 @@ public Topology getApplicationTopology(int applicationId, 
Duration duration) thr
         long startTimeBucket = 
DurationUtils.INSTANCE.exchangeToTimeBucket(duration.getStart());
         long endTimeBucket = 
DurationUtils.INSTANCE.exchangeToTimeBucket(duration.getEnd());
 
-        long startSecondTimeBucket = 
DurationUtils.INSTANCE.durationToSecondTimeBucket(duration.getStep(), 
duration.getStart());
-        long endSecondTimeBucket = 
DurationUtils.INSTANCE.durationToSecondTimeBucket(duration.getStep(), 
duration.getEnd());
+        long startSecondTimeBucket = 
DurationUtils.INSTANCE.startTimeDurationToSecondTimeBucket(duration.getStep(), 
duration.getStart());
+        long endSecondTimeBucket = 
DurationUtils.INSTANCE.endTimeDurationToSecondTimeBucket(duration.getStep(), 
duration.getEnd());
 
         return getServerService().getServerThroughput(applicationId, 
duration.getStep(), startTimeBucket, endTimeBucket, startSecondTimeBucket, 
endSecondTimeBucket, topN);
     }
diff --git 
a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/query/OverViewLayerQuery.java
 
b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/query/OverViewLayerQuery.java
index 81210b679..becf0658e 100644
--- 
a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/query/OverViewLayerQuery.java
+++ 
b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/query/OverViewLayerQuery.java
@@ -92,15 +92,15 @@ public Topology getClusterTopology(Duration duration) 
throws ParseException {
         long startTimeBucket = 
DurationUtils.INSTANCE.exchangeToTimeBucket(duration.getStart());
         long endTimeBucket = 
DurationUtils.INSTANCE.exchangeToTimeBucket(duration.getEnd());
 
-        long startSecondTimeBucket = 
DurationUtils.INSTANCE.durationToSecondTimeBucket(duration.getStep(), 
duration.getStart());
-        long endSecondTimeBucket = 
DurationUtils.INSTANCE.durationToSecondTimeBucket(duration.getStep(), 
duration.getEnd());
+        long startSecondTimeBucket = 
DurationUtils.INSTANCE.startTimeDurationToSecondTimeBucket(duration.getStep(), 
duration.getStart());
+        long endSecondTimeBucket = 
DurationUtils.INSTANCE.endTimeDurationToSecondTimeBucket(duration.getStep(), 
duration.getEnd());
 
         return 
getClusterTopologyService().getClusterTopology(duration.getStep(), 
startTimeBucket, endTimeBucket, startSecondTimeBucket, endSecondTimeBucket);
     }
 
     public ClusterBrief getClusterBrief(Duration duration) throws 
ParseException {
-        long startSecondTimeBucket = 
DurationUtils.INSTANCE.durationToSecondTimeBucket(duration.getStep(), 
duration.getStart());
-        long endSecondTimeBucket = 
DurationUtils.INSTANCE.durationToSecondTimeBucket(duration.getStep(), 
duration.getEnd());
+        long startSecondTimeBucket = 
DurationUtils.INSTANCE.startTimeDurationToSecondTimeBucket(duration.getStep(), 
duration.getStart());
+        long endSecondTimeBucket = 
DurationUtils.INSTANCE.endTimeDurationToSecondTimeBucket(duration.getStep(), 
duration.getEnd());
 
         ClusterBrief clusterBrief = new ClusterBrief();
         
clusterBrief.setNumOfApplication(getApplicationService().getApplications(startSecondTimeBucket,
 endSecondTimeBucket).size());
@@ -115,15 +115,15 @@ public AlarmTrend getAlarmTrend(Duration duration) throws 
ParseException {
         long startTimeBucket = 
DurationUtils.INSTANCE.exchangeToTimeBucket(duration.getStart());
         long endTimeBucket = 
DurationUtils.INSTANCE.exchangeToTimeBucket(duration.getEnd());
 
-        long startSecondTimeBucket = 
DurationUtils.INSTANCE.durationToSecondTimeBucket(duration.getStep(), 
duration.getStart());
-        long endSecondTimeBucket = 
DurationUtils.INSTANCE.durationToSecondTimeBucket(duration.getStep(), 
duration.getEnd());
+        long startSecondTimeBucket = 
DurationUtils.INSTANCE.startTimeDurationToSecondTimeBucket(duration.getStep(), 
duration.getStart());
+        long endSecondTimeBucket = 
DurationUtils.INSTANCE.endTimeDurationToSecondTimeBucket(duration.getStep(), 
duration.getEnd());
 
         return getAlarmService().getApplicationAlarmTrend(duration.getStep(), 
startTimeBucket, endTimeBucket, startSecondTimeBucket, endSecondTimeBucket);
     }
 
     public ConjecturalAppBrief getConjecturalApps(Duration duration) throws 
ParseException {
-        long startSecondTimeBucket = 
DurationUtils.INSTANCE.durationToSecondTimeBucket(duration.getStep(), 
duration.getStart());
-        long endSecondTimeBucket = 
DurationUtils.INSTANCE.durationToSecondTimeBucket(duration.getStep(), 
duration.getEnd());
+        long startSecondTimeBucket = 
DurationUtils.INSTANCE.startTimeDurationToSecondTimeBucket(duration.getStep(), 
duration.getStart());
+        long endSecondTimeBucket = 
DurationUtils.INSTANCE.endTimeDurationToSecondTimeBucket(duration.getStep(), 
duration.getEnd());
 
         return getApplicationService().getConjecturalApps(duration.getStep(), 
startSecondTimeBucket, endSecondTimeBucket);
     }
@@ -132,8 +132,8 @@ public ConjecturalAppBrief getConjecturalApps(Duration 
duration) throws ParseExc
         long startTimeBucket = 
DurationUtils.INSTANCE.exchangeToTimeBucket(duration.getStart());
         long endTimeBucket = 
DurationUtils.INSTANCE.exchangeToTimeBucket(duration.getEnd());
 
-        long startSecondTimeBucket = 
DurationUtils.INSTANCE.durationToSecondTimeBucket(duration.getStep(), 
duration.getStart());
-        long endSecondTimeBucket = 
DurationUtils.INSTANCE.durationToSecondTimeBucket(duration.getStep(), 
duration.getEnd());
+        long startSecondTimeBucket = 
DurationUtils.INSTANCE.startTimeDurationToSecondTimeBucket(duration.getStep(), 
duration.getStart());
+        long endSecondTimeBucket = 
DurationUtils.INSTANCE.endTimeDurationToSecondTimeBucket(duration.getStep(), 
duration.getEnd());
 
         return getServiceNameService().getSlowService(duration.getStep(), 
startTimeBucket, endTimeBucket, startSecondTimeBucket, endSecondTimeBucket, 
topN);
     }
diff --git 
a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/query/ServerQuery.java
 
b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/query/ServerQuery.java
index cae9a389f..ed8db55e1 100644
--- 
a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/query/ServerQuery.java
+++ 
b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/query/ServerQuery.java
@@ -53,14 +53,14 @@ private ServerService getServerService() {
     }
 
     public List<AppServerInfo> searchServer(String keyword, Duration duration) 
throws ParseException {
-        long startSecondTimeBucket = 
DurationUtils.INSTANCE.durationToSecondTimeBucket(duration.getStep(), 
duration.getStart());
-        long endSecondTimeBucket = 
DurationUtils.INSTANCE.durationToSecondTimeBucket(duration.getStep(), 
duration.getEnd());
+        long startSecondTimeBucket = 
DurationUtils.INSTANCE.startTimeDurationToSecondTimeBucket(duration.getStep(), 
duration.getStart());
+        long endSecondTimeBucket = 
DurationUtils.INSTANCE.endTimeDurationToSecondTimeBucket(duration.getStep(), 
duration.getEnd());
         return getServerService().searchServer(keyword, startSecondTimeBucket, 
endSecondTimeBucket);
     }
 
     public List<AppServerInfo> getAllServer(int applicationId, Duration 
duration) throws ParseException {
-        long startSecondTimeBucket = 
DurationUtils.INSTANCE.durationToSecondTimeBucket(duration.getStep(), 
duration.getStart());
-        long endSecondTimeBucket = 
DurationUtils.INSTANCE.durationToSecondTimeBucket(duration.getStep(), 
duration.getEnd());
+        long startSecondTimeBucket = 
DurationUtils.INSTANCE.startTimeDurationToSecondTimeBucket(duration.getStep(), 
duration.getStart());
+        long endSecondTimeBucket = 
DurationUtils.INSTANCE.endTimeDurationToSecondTimeBucket(duration.getStep(), 
duration.getEnd());
         return getServerService().getAllServer(applicationId, 
startSecondTimeBucket, endSecondTimeBucket);
     }
 
diff --git 
a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/query/ServiceQuery.java
 
b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/query/ServiceQuery.java
index ba7c6433a..e9e33ece5 100644
--- 
a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/query/ServiceQuery.java
+++ 
b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/query/ServiceQuery.java
@@ -74,8 +74,8 @@ public ThroughputTrend getServiceTPSTrend(int serviceId, 
Duration duration) thro
         long startTimeBucket = 
DurationUtils.INSTANCE.exchangeToTimeBucket(duration.getStart());
         long endTimeBucket = 
DurationUtils.INSTANCE.exchangeToTimeBucket(duration.getEnd());
 
-        long startSecondTimeBucket = 
DurationUtils.INSTANCE.durationToSecondTimeBucket(duration.getStep(), 
duration.getStart());
-        long endSecondTimeBucket = 
DurationUtils.INSTANCE.durationToSecondTimeBucket(duration.getStep(), 
duration.getEnd());
+        long startSecondTimeBucket = 
DurationUtils.INSTANCE.startTimeDurationToSecondTimeBucket(duration.getStep(), 
duration.getStart());
+        long endSecondTimeBucket = 
DurationUtils.INSTANCE.endTimeDurationToSecondTimeBucket(duration.getStep(), 
duration.getEnd());
 
         return getServiceNameService().getServiceTPSTrend(serviceId, 
duration.getStep(), startTimeBucket, endTimeBucket, startSecondTimeBucket, 
endSecondTimeBucket);
     }
@@ -90,8 +90,8 @@ public Topology getServiceTopology(int serviceId, Duration 
duration) throws Pars
         long startTimeBucket = 
DurationUtils.INSTANCE.exchangeToTimeBucket(duration.getStart());
         long endTimeBucket = 
DurationUtils.INSTANCE.exchangeToTimeBucket(duration.getEnd());
 
-        long startSecondTimeBucket = 
DurationUtils.INSTANCE.durationToSecondTimeBucket(duration.getStep(), 
duration.getStart());
-        long endSecondTimeBucket = 
DurationUtils.INSTANCE.durationToSecondTimeBucket(duration.getStep(), 
duration.getEnd());
+        long startSecondTimeBucket = 
DurationUtils.INSTANCE.startTimeDurationToSecondTimeBucket(duration.getStep(), 
duration.getStart());
+        long endSecondTimeBucket = 
DurationUtils.INSTANCE.endTimeDurationToSecondTimeBucket(duration.getStep(), 
duration.getEnd());
 
         return 
getServiceTopologyService().getServiceTopology(duration.getStep(), serviceId, 
startTimeBucket, endTimeBucket, startSecondTimeBucket, endSecondTimeBucket);
     }
diff --git 
a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/query/TraceQuery.java
 
b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/query/TraceQuery.java
index a39c1cf0d..9351793b4 100644
--- 
a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/query/TraceQuery.java
+++ 
b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/query/TraceQuery.java
@@ -68,8 +68,8 @@ public TraceBrief queryBasicTraces(TraceQueryCondition 
condition) throws ParseEx
         if (StringUtils.isNotEmpty(condition.getTraceId())) {
             traceId = condition.getTraceId();
         } else if (ObjectUtils.isNotEmpty(condition.getQueryDuration())) {
-            startSecondTimeBucket = 
DurationUtils.INSTANCE.durationToSecondTimeBucket(condition.getQueryDuration().getStep(),
 condition.getQueryDuration().getStart());
-            endSecondTimeBucket = 
DurationUtils.INSTANCE.durationToSecondTimeBucket(condition.getQueryDuration().getStep(),
 condition.getQueryDuration().getEnd());
+            startSecondTimeBucket = 
DurationUtils.INSTANCE.startTimeDurationToSecondTimeBucket(condition.getQueryDuration().getStep(),
 condition.getQueryDuration().getStart());
+            endSecondTimeBucket = 
DurationUtils.INSTANCE.endTimeDurationToSecondTimeBucket(condition.getQueryDuration().getStep(),
 condition.getQueryDuration().getEnd());
         } else {
             throw new UnexpectedException("The condition must contains either 
queryDuration or traceId.");
         }
diff --git 
a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/utils/DurationUtils.java
 
b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/utils/DurationUtils.java
index 52e5976dd..f14f7414b 100644
--- 
a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/utils/DurationUtils.java
+++ 
b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/utils/DurationUtils.java
@@ -42,7 +42,7 @@ public long exchangeToTimeBucket(String dateStr) throws 
ParseException {
         return Long.valueOf(dateStr);
     }
 
-    public long durationToSecondTimeBucket(Step step, String dateStr) throws 
ParseException {
+    public long startTimeDurationToSecondTimeBucket(Step step, String dateStr) 
throws ParseException {
         long secondTimeBucket = 0;
         switch (step) {
             case MONTH:
@@ -64,6 +64,28 @@ public long durationToSecondTimeBucket(Step step, String 
dateStr) throws ParseEx
         return secondTimeBucket;
     }
 
+    public long endTimeDurationToSecondTimeBucket(Step step, String dateStr) 
throws ParseException {
+        long secondTimeBucket = 0;
+        switch (step) {
+            case MONTH:
+                secondTimeBucket = (((exchangeToTimeBucket(dateStr) * 100 + 
99) * 100 + 99) * 100 + 99) * 100 + 99;
+                break;
+            case DAY:
+                secondTimeBucket = ((exchangeToTimeBucket(dateStr) * 100 + 99) 
* 100 + 99) * 100 + 99;
+                break;
+            case HOUR:
+                secondTimeBucket = (exchangeToTimeBucket(dateStr) * 100 + 99) 
* 100 + 99;
+                break;
+            case MINUTE:
+                secondTimeBucket = exchangeToTimeBucket(dateStr) * 100 + 99;
+                break;
+            case SECOND:
+                secondTimeBucket = exchangeToTimeBucket(dateStr);
+                break;
+        }
+        return secondTimeBucket;
+    }
+
     public int secondsBetween(Step step, long startTimeBucket, long 
endTimeBucket) throws ParseException {
         Date startDate = null;
         Date endDate = null;
@@ -139,7 +161,8 @@ public DateTime parseToDateTime(Step step, long time) 
throws ParseException {
         return dateTime;
     }
 
-    public List<DurationPoint> getDurationPoints(Step step, long 
startTimeBucket, long endTimeBucket) throws ParseException {
+    public List<DurationPoint> getDurationPoints(Step step, long 
startTimeBucket,
+        long endTimeBucket) throws ParseException {
         DateTime dateTime = parseToDateTime(step, startTimeBucket);
 
         List<DurationPoint> durations = new LinkedList<>();
diff --git 
a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/test/java/org/apache/skywalking/apm/collector/ui/query/ApplicationQueryTestCase.java
 
b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/test/java/org/apache/skywalking/apm/collector/ui/query/ApplicationQueryTestCase.java
index 234a9c85d..99d96b4eb 100644
--- 
a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/test/java/org/apache/skywalking/apm/collector/ui/query/ApplicationQueryTestCase.java
+++ 
b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/test/java/org/apache/skywalking/apm/collector/ui/query/ApplicationQueryTestCase.java
@@ -41,7 +41,7 @@ public void testGetAllApplicationByMonthDuration() throws 
ParseException {
         Mockito.when(applicationService.getApplications(Mockito.anyLong(), 
Mockito.anyLong())).then(invocation -> {
             Object[] arguments = invocation.getArguments();
             Assert.assertEquals(20170100000000L, arguments[0]);
-            Assert.assertEquals(20170100000000L, arguments[1]);
+            Assert.assertEquals(20170199999999L, arguments[1]);
             return null;
         });
 
@@ -62,7 +62,7 @@ public void testGetAllApplicationByDayDuration() throws 
ParseException {
         Mockito.when(applicationService.getApplications(Mockito.anyLong(), 
Mockito.anyLong())).then(invocation -> {
             Object[] arguments = invocation.getArguments();
             Assert.assertEquals(20170101000000L, arguments[0]);
-            Assert.assertEquals(20170101000000L, arguments[1]);
+            Assert.assertEquals(20170101999999L, arguments[1]);
             return null;
         });
 
@@ -83,7 +83,7 @@ public void testGetAllApplicationByHourDuration() throws 
ParseException {
         Mockito.when(applicationService.getApplications(Mockito.anyLong(), 
Mockito.anyLong())).then(invocation -> {
             Object[] arguments = invocation.getArguments();
             Assert.assertEquals(20170101010000L, arguments[0]);
-            Assert.assertEquals(20170101010000L, arguments[1]);
+            Assert.assertEquals(20170101019999L, arguments[1]);
             return null;
         });
 
@@ -104,7 +104,7 @@ public void testGetAllApplicationByMinuteDuration() throws 
ParseException {
         Mockito.when(applicationService.getApplications(Mockito.anyLong(), 
Mockito.anyLong())).then(invocation -> {
             Object[] arguments = invocation.getArguments();
             Assert.assertEquals(20170101010100L, arguments[0]);
-            Assert.assertEquals(20170101010100L, arguments[1]);
+            Assert.assertEquals(20170101010199L, arguments[1]);
             return null;
         });
 
diff --git 
a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/test/java/org/apache/skywalking/apm/collector/ui/utils/DurationUtilsTestCase.java
 
b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/test/java/org/apache/skywalking/apm/collector/ui/utils/DurationUtilsTestCase.java
index 1ab46eaab..1b3639f52 100644
--- 
a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/test/java/org/apache/skywalking/apm/collector/ui/utils/DurationUtilsTestCase.java
+++ 
b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/test/java/org/apache/skywalking/apm/collector/ui/utils/DurationUtilsTestCase.java
@@ -109,4 +109,40 @@ public void testGetDurationPoints() throws ParseException {
     public void testGetDurationPointsErrorDuration() throws ParseException {
         DurationUtils.INSTANCE.getDurationPoints(Step.MONTH, 20171001, 
20180301);
     }
+
+    @Test
+    public void testStartTimeDurationToSecondTimeBucket() throws 
ParseException {
+        long secondTimeBucket = 
DurationUtils.INSTANCE.startTimeDurationToSecondTimeBucket(Step.MONTH, 
"201710");
+        Assert.assertEquals(20171000000000L, secondTimeBucket);
+
+        secondTimeBucket = 
DurationUtils.INSTANCE.startTimeDurationToSecondTimeBucket(Step.DAY, 
"20171001");
+        Assert.assertEquals(20171001000000L, secondTimeBucket);
+
+        secondTimeBucket = 
DurationUtils.INSTANCE.startTimeDurationToSecondTimeBucket(Step.HOUR, 
"2017100108");
+        Assert.assertEquals(20171001080000L, secondTimeBucket);
+
+        secondTimeBucket = 
DurationUtils.INSTANCE.startTimeDurationToSecondTimeBucket(Step.MINUTE, 
"201710010805");
+        Assert.assertEquals(20171001080500L, secondTimeBucket);
+
+        secondTimeBucket = 
DurationUtils.INSTANCE.startTimeDurationToSecondTimeBucket(Step.SECOND, 
"20171001080501");
+        Assert.assertEquals(20171001080501L, secondTimeBucket);
+    }
+
+    @Test
+    public void testEndTimeDurationToSecondTimeBucket() throws ParseException {
+        long secondTimeBucket = 
DurationUtils.INSTANCE.endTimeDurationToSecondTimeBucket(Step.MONTH, "201710");
+        Assert.assertEquals(20171099999999L, secondTimeBucket);
+
+        secondTimeBucket = 
DurationUtils.INSTANCE.endTimeDurationToSecondTimeBucket(Step.DAY, "20171001");
+        Assert.assertEquals(20171001999999L, secondTimeBucket);
+
+        secondTimeBucket = 
DurationUtils.INSTANCE.endTimeDurationToSecondTimeBucket(Step.HOUR, 
"2017100108");
+        Assert.assertEquals(20171001089999L, secondTimeBucket);
+
+        secondTimeBucket = 
DurationUtils.INSTANCE.endTimeDurationToSecondTimeBucket(Step.MINUTE, 
"201710010805");
+        Assert.assertEquals(20171001080599L, secondTimeBucket);
+
+        secondTimeBucket = 
DurationUtils.INSTANCE.endTimeDurationToSecondTimeBucket(Step.SECOND, 
"20171001080501");
+        Assert.assertEquals(20171001080501L, secondTimeBucket);
+    }
 }


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to