@Override public Period parse(String text, Locale locale) throws ParseException { return Period.parse(text); }
@Override public Period parse(String text, Locale locale) throws ParseException { return Period.parse(text); }
private Period getChunkPeriod(Query<T> query) { final String p = QueryContexts.getChunkPeriod(query); return Period.parse(p); } }
public LookbackPartitionFilterGenerator(Properties properties) { Preconditions.checkArgument(properties.containsKey(PARTITION_COLUMN), ERROR_MESSAGE); Preconditions.checkArgument(properties.containsKey(LOOKBACK), ERROR_MESSAGE); Preconditions.checkArgument(properties.containsKey(DATETIME_FORMAT), ERROR_MESSAGE); this.partitionColumn = properties.getProperty(PARTITION_COLUMN); this.lookback = Period.parse(properties.getProperty(LOOKBACK)); this.formatter = DateTimeFormat.forPattern(properties.getProperty(DATETIME_FORMAT)); }
@Override public Date resolveDuedate(String duedate, int maxIterations) { try { // check if due period was specified if(duedate.startsWith("P")){ return new DateTime(clockReader.getCurrentTime()).plus(Period.parse(duedate)).toDate(); } return DateTime.parse(duedate).toDate(); } catch (Exception e) { throw new ActivitiException("couldn't resolve duedate: " + e.getMessage(), e); } } }
@Nullable static Period getPeriodProperty(Table table, String propertyName) { String val = getTableProperty(table, propertyName); if (val == null) { return null; } try { return Period.parse(val); } catch (IllegalArgumentException e) { throw new IllegalArgumentException(String.format("Exception while parsing property[%s] with Value [%s] as Period", propertyName, val)); } }
@VisibleForTesting static int parsePeriodToSeconds(String periodStr) { try { return Period.parse(periodStr.toUpperCase(), PERIOD_FORMATTER).toStandardSeconds().getSeconds(); } catch(ArithmeticException ae) { throw new RuntimeException(String.format("Reporting interval is too long. Max: %d seconds.", Integer.MAX_VALUE)); } }
/** * Parses a {@code Period} from the specified string. * <p> * This uses {@link ISOPeriodFormat#standard()}. * * @param str the string to parse, not null * @since 2.0 */ @FromString public static Period parse(String str) { return parse(str, ISOPeriodFormat.standard()); }
/** * Parses a {@code Period} from the specified string. * <p> * This uses {@link ISOPeriodFormat#standard()}. * * @param str the string to parse, not null * @since 2.0 */ @FromString public static Period parse(String str) { return parse(str, ISOPeriodFormat.standard()); }
/** * Set the timeout for shutting down the Gobblin instance driver after the job is done from ISO-style period. */ public EmbeddedGobblin setShutdownTimeout(String timeout) { return setShutdownTimeout(Period.parse(timeout).getSeconds(), TimeUnit.SECONDS); }
private long createLowWatermarkForBootstrap(WorkUnitState state) throws IOException { String bootstrapPeriodString = state.getProp(BOOTSTRAP_PERIOD, DEFAULT_BOOTSTRAP_PERIOD); Period period = Period.parse(bootstrapPeriodString); DateTime startTime = DateTime.now().minus(period); try { Queue<JsonElement> firstRevision = retrievePageRevisions(ImmutableMap.<String, String>builder().putAll(this.baseQuery) .put("rvprop", "ids") .put("titles", this.requestedTitle) .put("rvlimit", "1") .put("rvstart", WIKIPEDIA_TIMESTAMP_FORMAT.print(startTime)) .put("rvdir", "newer") .build()); if (firstRevision.isEmpty()) { throw new IOException("Could not retrieve oldest revision, returned empty revisions list."); } return parseRevision(firstRevision.poll()); } catch (URISyntaxException use) { throw new IOException(use); } }
/** * Set the timeout for the Gobblin job execution from ISO-style period. */ public EmbeddedGobblin setJobTimeout(String timeout) { return setJobTimeout(Period.parse(timeout).getSeconds(), TimeUnit.SECONDS); }
/** * Set the timeout for launching the Gobblin job from ISO-style period. */ public EmbeddedGobblin setLaunchTimeout(String timeout) { return setLaunchTimeout(Period.parse(timeout).getSeconds(), TimeUnit.SECONDS); }
@Test public void testDeserializationFromJson() throws Exception { TaskStorageConfig config = jsonMapper.readValue( "{\"recentlyFinishedThreshold\": \"PT12H\" }", TaskStorageConfig.class); Assert.assertEquals(Period.parse("PT12H").toStandardDuration(), config.getRecentlyFinishedThreshold()); }
@Test public void testDeserializationDefault() throws Exception { TaskStorageConfig config = jsonMapper.readValue( "{}", TaskStorageConfig.class); Assert.assertEquals(Period.parse("PT24H").toStandardDuration(), config.getRecentlyFinishedThreshold()); } }
Period period = Period.parse(text);
Period p = Period.parse(periodBuilder.toString()); Duration d = p.toStandardDuration().plus(millis); return d;
Period period = Period.parse(text);
@Override public Period parse(String value) { return Period.parse(value); }
/** * Parses a {@code Period} from the specified string. * <p> * This uses {@link ISOPeriodFormat#standard()}. * * @param str the string to parse, not null * @since 2.0 */ @FromString public static Period parse(String str) { return parse(str, ISOPeriodFormat.standard()); }