/** * Used to normalize the end date to the last update time but only if it's * close to it * * @param p the probe to check against * @param endDate the desired end date * @return the normalized end date */ public static Date endDate(Probe<?, ?> p, Date endDate) { // Date normalized = endDate; // We normalize the last update time, it can't be used directly long step = p.getStep(); Date lastUpdate = p.getLastUpdate(); // We dont want to graph past the last normalized update time // but only if we are within a step interval if(Math.abs(endDate.getTime() - lastUpdate.getTime()) <= (step * 1000L)) return normalize(lastUpdate, step); // Else rrd4j will manage the normalization itself return endDate; }
static public Period getPeriod(Probe<?, ?> p, long endSec) { Date end = org.rrd4j.core.Util.getDate(endSec); Calendar calBegin = Calendar.getInstance(); calBegin.setTime(end); calBegin.add(Calendar.MONTH, -1); Date begin = calBegin.getTime(); end = jrds.Util.normalize(end, p.getStep()); Period pr = null; try { pr = new Period(Long.toString(begin.getTime()), Long.toString(end.getTime())); } catch (ParseException e) { } return pr; }