public static void main(String[] args) { TimeZone localTimezone = Calendar.getInstance().getTimeZone(); TimeZone gmtTimezone = TimeZone.getTimeZone("GMT"); TimeZone estTimezone = TimeZone.getTimeZone("EST"); Date time = new Date(); System.out.println("local time :" + DateUtil.getDateDisplayString(localTimezone, time)); System.out.println("GMT time :" + DateUtil.getDateDisplayString(gmtTimezone, time)); System.out.println("EST time :" + DateUtil.getDateDisplayString(estTimezone, time)); //Test next run time. Expects interval and schedule as arguments if (args.length == 2) { System.out.println("Next run time: " + DateUtil.getNextRunTime(IntervalType.getIntervalType(args[0]), args[1], "GMT", time).toString()); } }
public SnapshotPolicyVO(long volumeId, String schedule, String timezone, IntervalType intvType, int maxSnaps, boolean display) { this.volumeId = volumeId; this.schedule = schedule; this.timezone = timezone; this.interval = (short)intvType.ordinal(); this.maxSnaps = maxSnaps; this.active = true; this.display = display; this.uuid = UUID.randomUUID().toString(); }
case HOURLY: if (scheduleParts.length < 1) { throw new CloudRuntimeException("Incorrect schedule format: " + schedule + " for interval type:" + type.toString()); case DAILY: if (scheduleParts.length < 2) { throw new CloudRuntimeException("Incorrect schedule format: " + schedule + " for interval type:" + type.toString()); case WEEKLY: if (scheduleParts.length < 3) { throw new CloudRuntimeException("Incorrect schedule format: " + schedule + " for interval type:" + type.toString()); case MONTHLY: if (scheduleParts.length < 3) { throw new CloudRuntimeException("Incorrect schedule format: " + schedule + " for interval type:" + type.toString()); throw new CloudRuntimeException("Incorrect interval: " + type.toString());
case HOURLY: if (scheduleParts.length < 1) { throw new CloudRuntimeException("Incorrect schedule format: " + schedule + " for interval type:" + type.toString()); case DAILY: if (scheduleParts.length < 2) { throw new CloudRuntimeException("Incorrect schedule format: " + schedule + " for interval type:" + type.toString()); case WEEKLY: if (scheduleParts.length < 3) { throw new CloudRuntimeException("Incorrect schedule format: " + schedule + " for interval type:" + type.toString()); case MONTHLY: if (scheduleParts.length < 3) { throw new CloudRuntimeException("Incorrect schedule format: " + schedule + " for interval type:" + type.toString()); throw new CloudRuntimeException("Incorrect interval: " + type.toString());
IntervalType intvType = DateUtil.IntervalType.getIntervalType(cmd.getIntervalType()); if (intvType == null) { throw new InvalidParameterValueException("Unsupported interval type " + cmd.getIntervalType()); policy.setSchedule(cmd.getSchedule()); policy.setTimezone(timezoneId); policy.setInterval((short)intvType.ordinal()); policy.setMaxSnaps(cmd.getMaxSnaps()); policy.setActive(true);
private Type getSnapshotType(IntervalType intvType) { if (intvType.equals(IntervalType.HOURLY)) { return Type.HOURLY; } else if (intvType.equals(IntervalType.DAILY)) { return Type.DAILY; } else if (intvType.equals(IntervalType.WEEKLY)) { return Type.WEEKLY; } else if (intvType.equals(IntervalType.MONTHLY)) { return Type.MONTHLY; } return null; }
@Override public SnapshotPolicyVO findOneByVolumeInterval(long volumeId, IntervalType intvType) { SearchCriteria<SnapshotPolicyVO> sc = VolumeIdIntervalSearch.create(); sc.setParameters("volumeId", volumeId); sc.setParameters("interval", intvType.ordinal()); return findOneBy(sc); }