Class DelayLoadingQueue
-
- All Implemented Interfaces:
-
ai.platon.pulsar.common.collect.Loadable,ai.platon.pulsar.common.collect.queue.LoadingQueue,java.util.Queue,kotlin.collections.Collection,kotlin.collections.Iterable,kotlin.collections.MutableCollection,kotlin.collections.MutableIterable
public class DelayLoadingQueue extends AbstractLoadingQueue
A delay loading queue to reduce IO
-
-
Field Summary
Fields Modifier and Type Field Description private final DurationidleTimeprivate final BooleanisIdleprivate final BooleanisBusyprivate final DurationadjustedEstimateDelayprivate final BooleanisExpiredprivate final IntegerestimatedExternalSizeprivate DurationloadDelayprivate DurationestimateDelayprivate final IntegerloadCountprivate final IntegersavedCountprivate final Collection<UrlAware>cacheprivate final Integersizeprivate final IntegerexternalSizeprivate final IntegerestimatedSizeprivate final IntegerfreeSlotsprivate final BooleanisFullprivate final ExternalUrlLoaderloaderprivate final UrlTopictopicprivate final Function1<UrlAware, UrlAware>transformer
-
Constructor Summary
Constructors Constructor Description DelayLoadingQueue(ExternalUrlLoader loader, UrlTopic topic, Duration loadDelay, Duration estimateDelay, Function1<UrlAware, UrlAware> transformer)
-
Method Summary
Modifier and Type Method Description final DurationgetIdleTime()final BooleanisIdle()final BooleanisBusy()final DurationgetAdjustedEstimateDelay()final BooleanisExpired()IntegergetEstimatedExternalSize()final DurationgetLoadDelay()The delay time to load after another load final UnitsetLoadDelay(Duration loadDelay)The delay time to load after another load final DurationgetEstimateDelay()final UnitsetEstimateDelay(Duration estimateDelay)final BooleanisExpired(Duration delay, Instant now)Determine whether the deadline has been exceeded. final Unitexpire()Unitload()final Unitload(Duration delay)Collection<UrlAware>loadNow()UrlAwarepeek()UrlAwarepoll()-
Methods inherited from class ai.platon.pulsar.common.collect.queue.AbstractLoadingQueue
add, addAll, clear, deepClear, externalClear, getCache, getEstimatedSize, getExternalSize, getFreeSlots, getLoadCount, getLoader, getSavedCount, getSize, getTopic, getTransformer, isFull, iterator, offer, overflow, overflow, removeIf, shuffle -
Methods inherited from class java.util.AbstractQueue
element, remove -
Methods inherited from class java.util.AbstractCollection
contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray, toString -
Methods inherited from class kotlin.collections.Iterable
forEach -
Methods inherited from class kotlin.collections.Collection
parallelStream, spliterator, stream, toArray -
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
Method Detail
-
getIdleTime
final Duration getIdleTime()
-
getAdjustedEstimateDelay
final Duration getAdjustedEstimateDelay()
-
getEstimatedExternalSize
@Synchronized() Integer getEstimatedExternalSize()
-
getLoadDelay
final Duration getLoadDelay()
The delay time to load after another load
-
setLoadDelay
final Unit setLoadDelay(Duration loadDelay)
The delay time to load after another load
-
getEstimateDelay
final Duration getEstimateDelay()
-
setEstimateDelay
final Unit setEstimateDelay(Duration estimateDelay)
-
isExpired
final Boolean isExpired(Duration delay, Instant now)
Determine whether the deadline has been exceeded.
- Parameters:
delay- the expiration timenow- the time in used to compare against the expiration time.- Returns:
<code>true</code> if last load time + <code>delay</code> is <<code>now</code>. <code>false</code> otherwise.
-
load
@Synchronized() Unit load()
-
load
@Synchronized() final Unit load(Duration delay)
-
loadNow
@Synchronized() Collection<UrlAware> loadNow()
-
peek
@Synchronized() UrlAware peek()
-
poll
@Synchronized() UrlAware poll()
-
-
-
-