private boolean hasTaskPendingBeyondThreshold(Collection<? extends TaskRunnerWorkItem> pendingTasks) { long now = System.currentTimeMillis(); for (TaskRunnerWorkItem pendingTask : pendingTasks) { final Duration durationSinceInsertion = new Duration(pendingTask.getQueueInsertionTime().getMillis(), now); final Duration timeoutDuration = config.getPendingTaskTimeout().toStandardDuration(); if (durationSinceInsertion.isEqual(timeoutDuration) || durationSinceInsertion.isLongerThan(timeoutDuration)) { return true; } } return false; }
if (durSinceLastTerminate.isLongerThan(config.getMaxScalingDuration().toStandardDuration())) { log.makeAlert("Worker node termination taking too long!") .addData("millisSinceLastTerminate", durSinceLastTerminate.getMillis())
Duration durSinceLastProvision = new Duration(lastProvisionTime, DateTimes.nowUtc()); log.info("%s provisioning. Current wait time: %s", currentlyProvisioning, durSinceLastProvision); if (durSinceLastProvision.isLongerThan(config.getMaxScalingDuration().toStandardDuration())) { log.makeAlert("Worker node provisioning taking too long!") .addData("millisSinceLastProvision", durSinceLastProvision.getMillis())
if (durSinceLastTerminate.isLongerThan(config.getMaxScalingDuration().toStandardDuration())) { log.makeAlert("Worker node termination taking too long!") .addData("millisSinceLastTerminate", durSinceLastTerminate.getMillis())
Duration durSinceLastProvision = new Duration(lastProvisionTime, DateTimes.nowUtc()); log.info("%s provisioning. Current wait time: %s", currentlyProvisioning, durSinceLastProvision); if (durSinceLastProvision.isLongerThan(config.getMaxScalingDuration().toStandardDuration())) { log.makeAlert("Worker node provisioning taking too long!") .addData("millisSinceLastProvision", durSinceLastProvision.getMillis())
transitionResolution.toPeriod().toDurationFrom(now); Duration maxDuration = Weeks.ONE.toPeriod().toDurationTo(timeDt); if (transitionDuration.isLongerThan(maxDuration)) { transitionDuration = maxDuration; if (!duration.isLongerThan(transitionDuration)) { CharSequence relativeClause = getRelativeTimeSpanString(context, time, flags); result = r.getString(R.string.joda_time_android_relative_time, relativeClause, timeClause);
if (remaininInterval.toDuration().isLongerThan(spec.segmentPeriod.toStandardDuration())) { segmentInterval = new Interval(spec.segmentPeriod, remaininInterval.getEnd()); } else {
private Duration getPeriodSize() { // normalize by the time since server start ReadableDateTime now = new DateTime(); Duration periodSize = new Duration(start, now); if (periodSize.isLongerThan(windowSize)) { return windowSize; } else { return periodSize; } } }
/** * testing to see if we can merge counter1 and counter2 and not violate * the maxChunkLength * <p/> * ...| counter2 | counter1 | */ private void mergeChunksIfNeeded() { C counter1 = eventCounters.removeLast(); C counter2 = eventCounters.getLast(); if (StatsUtil.extentOf(counter1, counter2).isLongerThan(maxChunkLength)) { eventCounters.add(counter1); } else { eventCounters.removeLast(); eventCounters.add(counter1.merge(counter2)); } }
/** * Updates the current composite counter so that it is up to date with the * current timestamp. * <p/> * This should be called by any method that needs to have the most updated * view of the current set of counters. */ protected synchronized void trimIfNeeded() { Duration delta = new Duration(start, new DateTime()) .minus(maxLength); if (delta.isLongerThan(Duration.ZERO)) { start = start.toDateTime().plus(delta); if (start.isAfter(end)) { end = start; } Iterator<C> iter = eventCounters.iterator(); while (iter.hasNext()) { EventCounterIf<C> counter = iter.next(); // trim any counter with an end up to and including start since our composite counter is // [start, ... and each counter is [..., end) if (!start.isBefore(counter.getEnd())) { iter.remove(); } else { break; } } } }
private Duration getPeriodSize() { // normalize by the time since server start ReadableDateTime now = new DateTime(); Duration periodSize = new Duration(start, now); if (periodSize.isLongerThan(windowSize)) { return windowSize; } else { return periodSize; } } }
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; }
@Override public boolean canStopPolling(Instant now, KV<Instant, ReadableDuration> state) { Instant timeOfLastNewOutput = state.getKey(); ReadableDuration maxTimeSinceNewOutput = state.getValue(); return timeOfLastNewOutput != null && new Duration(timeOfLastNewOutput, now).isLongerThan(maxTimeSinceNewOutput); }
void logIfLagging(WorkflowInstance instance) { Duration executionLag = new Duration(instance.nextActivation, now()); if (executionLag.isLongerThan(standardMinutes(1))) { laggingLogger.warn("Execution lagging {} seconds.", executionLag.getStandardSeconds()); } }
private boolean dateDiffIsLongerThanAMinute(long first, long second) { return new Interval(min(first, second), max(first, second)).toDuration().isLongerThan(standardMinutes(1)); } }
private Duration boundReadDuration(double readTimePercentage, long minReadTimeMillis) { long batchDurationMillis = ssc().graph().batchDuration().milliseconds(); Duration proportionalDuration = new Duration(Math.round(batchDurationMillis * readTimePercentage)); Duration lowerBoundDuration = new Duration(minReadTimeMillis); Duration readDuration = proportionalDuration.isLongerThan(lowerBoundDuration) ? proportionalDuration : lowerBoundDuration; LOG.info("Read duration set to: " + readDuration); return readDuration; }
private boolean hasTaskPendingBeyondThreshold(Collection<? extends TaskRunnerWorkItem> pendingTasks) { long now = System.currentTimeMillis(); for (TaskRunnerWorkItem pendingTask : pendingTasks) { final Duration durationSinceInsertion = new Duration(pendingTask.getQueueInsertionTime().getMillis(), now); final Duration timeoutDuration = config.getPendingTaskTimeout().toStandardDuration(); if (durationSinceInsertion.isEqual(timeoutDuration) || durationSinceInsertion.isLongerThan(timeoutDuration)) { return true; } } return false; }
private boolean hasTaskPendingBeyondThreshold(Collection<? extends TaskRunnerWorkItem> pendingTasks) { long now = System.currentTimeMillis(); for (TaskRunnerWorkItem pendingTask : pendingTasks) { final Duration durationSinceInsertion = new Duration(pendingTask.getQueueInsertionTime().getMillis(), now); final Duration timeoutDuration = config.getPendingTaskTimeout().toStandardDuration(); if (durationSinceInsertion.isEqual(timeoutDuration) || durationSinceInsertion.isLongerThan(timeoutDuration)) { return true; } } return false; }
static Duration getDefaultPeriod(Duration size) { if (size.isLongerThan(Duration.standardHours(1))) { return Duration.standardHours(1); } if (size.isLongerThan(Duration.standardMinutes(1))) { return Duration.standardMinutes(1); } if (size.isLongerThan(Duration.standardSeconds(1))) { return Duration.standardSeconds(1); } return Duration.millis(1); }
public static RetryConfiguration create(int maxAttempts, Duration maxDuration) { checkArgument(maxAttempts > 0, "maxAttempts should be greater than 0"); checkArgument( maxDuration != null && maxDuration.isLongerThan(Duration.ZERO), "maxDuration should be greater than 0"); return new AutoValue_SnsIO_RetryConfiguration.Builder() .setMaxAttempts(maxAttempts) .setMaxDuration(maxDuration) .setRetryPredicate(DEFAULT_RETRY_PREDICATE) .build(); }