Skip to content

Commit

Permalink
Fix #1517, Fix fake data generation bug
Browse files Browse the repository at this point in the history
  • Loading branch information
littlezhou committed Jan 2, 2018
1 parent cd00407 commit 397687f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ public List<Utilization> getHistUtilization(String resourceName, long granularit

// fake data
List<Utilization> utils = new ArrayList<>();
long ts = end;
long ts = begin;
if (ts % granularity != 0) {
ts += granularity;
ts = (ts / granularity) * granularity;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,12 @@ public Response utilization(@PathParam("resourceName") String resourceName,
try {
long now = System.currentTimeMillis();
long granularity = Long.valueOf(timeGranularity);
if (granularity <= 0) {
return new JsonResponse<>(Status.BAD_REQUEST,
"Invalid time granularity, must larger than 0").build();
}
long tsEnd = Long.valueOf(endTs);
long tsBegin = Long.valueOf(beginTs);
if (granularity == 0) {
granularity = 1;
}
if (tsEnd <= 0) {
tsEnd += now;
}
Expand Down

0 comments on commit 397687f

Please sign in to comment.