private void setTimeRangeInQueryRequest( MetricQueryRequest request, Map<String, List<String>> queryTimeParams) { Long start = queryTimeParams.containsKey(PARAM_START_TIME) ? TimeMathParser.parseTimeInSeconds(queryTimeParams.get(PARAM_START_TIME).get(0)) : null; Long end = queryTimeParams.containsKey(PARAM_END_TIME) ? TimeMathParser.parseTimeInSeconds(queryTimeParams.get(PARAM_END_TIME).get(0)) : null; Integer count = null; boolean aggregate = queryTimeParams.containsKey(PARAM_AGGREGATE) && queryTimeParams.get(PARAM_AGGREGATE).get(0).equals("true") || ((start == null) && (end == null)); Integer resolution = queryTimeParams.containsKey(PARAM_RESOLUTION) ? getResolution(queryTimeParams.get(PARAM_RESOLUTION).get(0), start, end) : 1; Interpolator interpolator = null; if (queryTimeParams.containsKey(PARAM_INTERPOLATE)) { long timeLimit = queryTimeParams.containsKey(PARAM_MAX_INTERPOLATE_GAP) ? Long.parseLong(queryTimeParams.get(PARAM_MAX_INTERPOLATE_GAP).get(0)) : Long.MAX_VALUE; interpolator = getInterpolator(queryTimeParams.get(PARAM_INTERPOLATE).get(0), timeLimit); } if (queryTimeParams.containsKey(PARAM_COUNT)) { count = Integer.valueOf(queryTimeParams.get(PARAM_COUNT).get(0)); if (start == null && end != null) { start = end - count * resolution; } else if (start != null && end == null) { end = start + count * resolution; } } else if (start != null && end != null) { count = (int) (((end / resolution * resolution) - (start / resolution * resolution)) / resolution + 1); } else if (!aggregate) { throw new IllegalArgumentException( "At least two of count/start/end parameters " + "are required for time-range queries "); } if (aggregate) { request.setTimeRange(0L, 0L, 1, Integer.MAX_VALUE, null); } else { request.setTimeRange(start, end, count, resolution, interpolator); } }