From 8eb6e90e56900580785518c401f434f2951d9fbd Mon Sep 17 00:00:00 2001 From: Bo Yang Date: Mon, 10 Sep 2018 11:42:19 -0700 Subject: [PATCH] update based on review comments --- src/autoscaler/collection/TSDCache.go | 2 +- src/autoscaler/metricscollector/server/metric_handler.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/autoscaler/collection/TSDCache.go b/src/autoscaler/collection/TSDCache.go index 0079fd9c4..b717595f6 100644 --- a/src/autoscaler/collection/TSDCache.go +++ b/src/autoscaler/collection/TSDCache.go @@ -47,7 +47,7 @@ func (c *TSDCache) binarySearch(t int64) int { if l > r { return l } - m := (l + r) / 2 + m := l + (r-l)/2 if t <= c.data[m%c.capacity].GetTimestamp() { r = m - 1 } else { diff --git a/src/autoscaler/metricscollector/server/metric_handler.go b/src/autoscaler/metricscollector/server/metric_handler.go index 8f624a2f9..08081a744 100644 --- a/src/autoscaler/metricscollector/server/metric_handler.go +++ b/src/autoscaler/metricscollector/server/metric_handler.go @@ -135,7 +135,7 @@ func (h *MetricHandler) GetMetricHistories(w http.ResponseWriter, r *http.Reques if instanceIndex >= 0 { labels[models.MetricLabelInstanceIndex] = fmt.Sprintf("%d", instanceIndex) } - mtrcs, ok := h.queryFunc(appId, start, end, order, labels) + mtrcs, ok := h.queryFunc(appId, start, end+1, order, labels) if !ok { h.logger.Debug("get-metric-histories-query-cache-miss", lager.Data{"appId": appId, "metrictype": metricType, "instanceIndex": instanceIndex, "start": start, "end": end, "order": order}) mtrcs, err = h.database.RetrieveInstanceMetrics(appId, int(instanceIndex), metricType, start, end, order)