MixedTimeWatchdog
@Deprecated public class WatchdogCache extends MixedTimeWatchdog
Watchdog
instances. Because the timeout for
Watchdog
is set in the constructor Watchdog.Watchdog(long, boolean)
, you can
use this class to be more flexible and set the timeout at the time of watching the future.
Using CancelDebuggingListenableFuture
to wrap the futures before providing to this class
can provide an easier understanding of the state of a Future when it was timed out by this class.
Constructor and Description |
---|
WatchdogCache(boolean sendInterruptOnFutureCancel)
Deprecated.
Please use
centralWatchdogCache(boolean) |
WatchdogCache(SubmitterScheduler scheduler,
boolean sendInterruptOnFutureCancel)
Deprecated.
Constructs a new
WatchdogCache with a scheduler of your choosing. |
WatchdogCache(SubmitterScheduler scheduler,
boolean sendInterruptOnFutureCancel,
long resolutionMillis)
Deprecated.
Constructs a new
WatchdogCache with a scheduler of your choosing. |
Modifier and Type | Method and Description |
---|---|
static WatchdogCache |
centralWatchdogCache(boolean sendInterruptOnFutureCancel)
Deprecated.
Return a static / shared
WatchdogCache instance. |
void |
watch(ListenableFuture<?> future,
long timeoutInMillis)
Deprecated.
Please re-order arguments to use
MixedTimeWatchdog.watch(long, ListenableFuture) |
centralWatchdog, getWatchingCount, watch
@Deprecated public WatchdogCache(boolean sendInterruptOnFutureCancel)
centralWatchdogCache(boolean)
WatchdogCache
. This constructor will use a default static scheduler
(which is lazily constructed). This should be fine in most cases, but you can provide your
own scheduler if you want to avoid the thread creation (which is shared among all instances
that were constructed with this constructor or Watchdog.Watchdog(long, boolean)
}.sendInterruptOnFutureCancel
- If true
, and a thread is provided with the future,
an interrupt will be sent on timeoutpublic WatchdogCache(SubmitterScheduler scheduler, boolean sendInterruptOnFutureCancel)
WatchdogCache
with a scheduler of your choosing. It is critical
that this scheduler has a free thread available to inspect futures which may not have
completed in the given timeout. You may want to use a org.threadly.concurrent.limiter to
ensure that there are threads available.scheduler
- Scheduler to schedule task to look for expired futuressendInterruptOnFutureCancel
- If true
, and a thread is provided with the future,
an interrupt will be sent on timeoutpublic WatchdogCache(SubmitterScheduler scheduler, boolean sendInterruptOnFutureCancel, long resolutionMillis)
WatchdogCache
with a scheduler of your choosing. It is critical
that this scheduler has a free thread available to inspect futures which may not have
completed in the given timeout. You may want to use a org.threadly.concurrent.limiter to
ensure that there are threads available.
This constructor allows you to set the timeout resolutions. Setting the resolution too large can result in futures timing out later than you expected. Setting it too low results in heavy memory consumption when used with a wide variety of timeouts.
scheduler
- Scheduler to schedule task to look for expired futuressendInterruptOnFutureCancel
- If true
, and a thread is provided with the future,
an interrupt will be sent on timeoutresolutionMillis
- The resolution to allow timeout granularitypublic static final WatchdogCache centralWatchdogCache(boolean sendInterruptOnFutureCancel)
WatchdogCache
instance. This instance is backed by the
CentralThreadlyPool
which should be fine in most cases, but if
you have specific needs you can construct your own instance by
WatchdogCache(SubmitterScheduler, boolean)
, or if you need to specify a specific
timeout resolution using the WatchdogCache(SubmitterScheduler, boolean, long)
constructor.
As long as those special cases are not needed, using a shared instance allows for potentially improved efficiency.
sendInterruptOnFutureCancel
- If true
, and a thread is provided with the future,
an interrupt will be sent on timeoutWatchdogCache
with the specified configuration@Deprecated public void watch(ListenableFuture<?> future, long timeoutInMillis)
MixedTimeWatchdog.watch(long, ListenableFuture)
ListenableFuture
to ensure that it completes within the provided
time limit. If the future is not marked as done by the time limit then it will be
completed by invoking Future.cancel(boolean)
. Weather a true
or
false
will be provided to interrupt the running thread is dependent on how this
WatchdogCache
was constructed.future
- Future to inspect to ensure completiontimeoutInMillis
- Time in milliseconds that future should be completed within