public int getPercentComplete() { Duration eta = eta(); if (eta.getMillis() == 0) { return 0; } if (eta.isShorterThan(getElapsedTime())) { return 100; } return (int) ((getElapsedTime().getMillis() * 100) / eta.getMillis()); }
if (timeSpan.isShorterThan(TWENTY_DAYS)) { bucketSize = DateHistogramInterval.DAY; } else if (timeSpan.isShorterThan(TWENTY_WEEKS)) { bucketSize = DateHistogramInterval.WEEK; } else if (timeSpan.isShorterThan(TWENTY_MONTHS)) { bucketSize = DateHistogramInterval.MONTH;
public Optional<Violation> validate(IndexSetConfig newConfig) { // Build an example index name with the new prefix and check if this would be managed by an existing index set final String indexName = newConfig.indexPrefix() + MongoIndexSet.SEPARATOR + "0"; if (indexSetRegistry.isManagedIndex(indexName)) { return Optional.of(Violation.create("Index prefix \"" + newConfig.indexPrefix() + "\" would conflict with an existing index set!")); } // Check if an existing index set has a more generic index prefix. // Example: new=graylog_foo existing=graylog => graylog is more generic so this is an error // Example: new=gray existing=graylog => gray is more generic so this is an error // This avoids problems with wildcard matching like "graylog_*". for (final IndexSet indexSet : indexSetRegistry) { if (newConfig.indexPrefix().startsWith(indexSet.getIndexPrefix()) || indexSet.getIndexPrefix().startsWith(newConfig.indexPrefix())) { return Optional.of(Violation.create("Index prefix \"" + newConfig.indexPrefix() + "\" would conflict with existing index set prefix \"" + indexSet.getIndexPrefix() + "\"")); } } // Ensure fieldTypeRefreshInterval is not shorter than a second, as that may impact performance if (newConfig.fieldTypeRefreshInterval().isShorterThan(MINIMUM_FIELD_TYPE_REFRESH_INTERVAL)) { return Optional.of(Violation.create("Index field_type_refresh_interval \"" + newConfig.fieldTypeRefreshInterval().toString() + "\" is too short. It must be 1 second or longer.")); } return Optional.empty(); }
transitionDuration = maxDuration; else if (transitionDuration.isShorterThan(minDuration)) { transitionDuration = minDuration;
@Override public boolean assignsToOneWindow() { return !this.period.isShorterThan(this.size); }
private FixedWindows(Duration size, Duration offset) { if (offset.isShorterThan(Duration.ZERO) || !offset.isShorterThan(size)) { throw new IllegalArgumentException( "FixedWindows WindowingStrategies must have 0 <= offset < size"); } this.size = size; this.offset = offset; }
public Interval(@NonNull Duration duration) { if (duration.isShorterThan(Duration.ZERO)) throw new IllegalArgumentException("negative duration not supported"); this.duration = duration; }
private SlidingWindows(Duration period, Duration size, Duration offset) { if (offset.isShorterThan(Duration.ZERO) || !offset.isShorterThan(period) || !size.isLongerThan(Duration.ZERO)) { throw new IllegalArgumentException( "SlidingWindows WindowingStrategies must have 0 <= offset < period and 0 < size"); } this.period = period; this.size = size; this.offset = offset; }
/** * Checks whether the given date-times are close enough next to each other. * * @param t1 * @param t2 * @param millis * @throws XAdESValidationException */ public static void checkCloseEnough(DateTime t1, DateTime t2, long millis) throws XAdESValidationException { Duration dt; if (t1.isBefore(t2)) { dt = new Duration(t1, t2); } else { dt = new Duration(t2, t1); } if (false == dt.isShorterThan(new Duration(millis))) { throw new XAdESValidationException("max dt of " + millis + " ms exceeded between " + t1 + " and " + t2 + " with dt = " + dt); } }
@Contract("null -> null; !null -> !null") public static @Nullable String jodaDurationToString(final Duration d) { if (d == null) { return null; } if (d.isShorterThan(new Duration(60000))) { return "0min"; } return DURATIONFORMAT.print(d.toPeriod()); }
public boolean isFiring() { return isTriggered().orElse(Boolean.FALSE) && !getDuration().isShorterThan(getFireDuration()); } public String getMessage() { return message_; }
public boolean isFiring() { return isTriggered().orElse(Boolean.FALSE) && !getDuration().isShorterThan(getFireDuration()); } public String getMessage() { return message_; }
public boolean isRemake() { if(coreData.getDuration() == null) { load(MATCH_LOAD_GROUP); } return coreData.getDuration().isShorterThan(Duration.standardMinutes(5)); }
if ( interval.isShorterThan(Duration.standardSeconds(1)) ) {
if (timeSpan.isShorterThan(TWENTY_DAYS)) { bucketSize = DateHistogramInterval.DAY; } else if (timeSpan.isShorterThan(TWENTY_WEEKS)) { bucketSize = DateHistogramInterval.WEEK; } else if (timeSpan.isShorterThan(TWENTY_MONTHS)) { bucketSize = DateHistogramInterval.MONTH;
/** * Returns a human-readable string representation of a {@link Duration}, * which expresses the duration in hours, minutes and seconds using the * highest possible units. * * @param duration * @return A duration such as "48 hours, 10 minutes, 1 second" */ public static String durationAsString(Duration duration) { if (duration.isShorterThan(new Duration(1))) { return "0 seconds"; } PeriodFormatter formatter = new PeriodFormatterBuilder().printZeroNever().appendHours() .appendSuffix(" hour", " hours").appendSeparator(", ").printZeroNever().appendMinutes() .appendSuffix(" minute", " minutes").appendSeparator(", ").printZeroNever().appendSeconds() .appendSuffix(" second", " seconds").toFormatter(); new Period(duration.getStandardDays()); return formatter.print(duration.toPeriod()); }