@Override protected void runTask() { DateTime start = new DateTime(DateTimeZones.UTC); log.info("C4 EPG Update initiated"); DayRange dayRange = rangeGenerator.generate(new LocalDate(DateTimeZones.UTC)); BiMap<String, Channel> channelMap = c4AtomApi.getChannelMap(); int total = Iterables.size(dayRange) * channelMap.size(); int processed = 0; UpdateProgress progress = UpdateProgress.START; for (Map.Entry<String, Channel> channelEntry : channelMap.entrySet()) { for (LocalDate scheduleDay : dayRange) { reportStatus(progressReport("Processing", processed++, total, progress)); progress = progress.reduce( channelDayUpdater.update( channelEntry.getKey(), channelEntry.getValue(), scheduleDay)); } } reportStatus(progressReport("Processed", processed++, total, progress)); String runTime = new Period(start, new DateTime(DateTimeZones.UTC)).toString(PeriodFormat.getDefault()); log.info("C4 EPG Update finished in " + runTime); if (progress.hasFailures()) { throw new IllegalStateException( String.format("Completed with %s failures", progress.getFailures())); } }
public void schedule(String jobId, DateTime dateTime, ReadablePeriod period, boolean ignoreDep) { logger.info( "Scheduling job '" + jobId + "' for " + _dateFormat.print(dateTime) + " with a period of " + PeriodFormat.getDefault().print(period)); schedule(new ScheduledJob(jobId, dateTime, period, ignoreDep)); }
protected void checkTimestamp(WindowedValue<IN> ref, Instant timestamp) { if (timestamp.isBefore(ref.getTimestamp().minus(doFn.getAllowedTimestampSkew()))) { throw new IllegalArgumentException( String.format( "Cannot output with timestamp %s. Output timestamps must be no earlier than the " + "timestamp of the current input (%s) minus the allowed skew (%s). See the " + "DoFn#getAllowedTimestmapSkew() Javadoc for details on changing the allowed skew.", timestamp, ref.getTimestamp(), PeriodFormat.getDefault().print(doFn.getAllowedTimestampSkew().toPeriod()))); } }
private String epocToSimpleDate(long epoc) { Period diff = new Period(epoc, System.currentTimeMillis(), PeriodType.standard()); PeriodType type; if (diff.getMonths() > 0) { type = PeriodType.yearMonthDay(); } else if (diff.getWeeks() > 0) { type = PeriodType.yearWeekDay(); } else if (diff.getDays() > 0) { type = PeriodType.dayTime().withSecondsRemoved().withMillisRemoved().withMinutesRemoved(); } else if (diff.getMinutes() > 0) { type = PeriodType.time().withMillisRemoved().withSecondsRemoved(); } else { type = PeriodType.time().withMillisRemoved(); } return PeriodFormat.getDefault().print(new Period(epoc, System.currentTimeMillis(), type)); }