Package org.wildfly.discovery
Interface ServicesQueue
- All Superinterfaces:
AutoCloseable
A queue for receiving service query answers.
- Author:
- David M. Lloyd
-
Method Summary
Modifier and TypeMethodDescriptionvoidawait()Wait for a queue entry to become available.voidWait for a certain amount of time for a queue entry to become available.voidclose()Cancel any in-progress discovery for this queue.Get a list of problems that occurred during discovery.booleanQuery whether this queue is finished (all services have been read).booleanisReady()Query whether there is a value ready to be read.default URIpoll()Get the location URI of the next entry from the queue without blocking.Get the next entry from the queue without blocking.default URItake()Get the location URI of the next entry from the queue, blocking until one is available or the thread is interrupted.Get the next entry from the queue, blocking until one is available or the thread is interrupted.takeService(long timeout, TimeUnit timeUnit) Get the next entry from the queue, blocking until one is available or timeout expires.default ServicesQueuewithTimeout(long time, TimeUnit unit) Create a version of this queue which has an absolute timeout, relative to when this method is called.
-
Method Details
-
await
Wait for a queue entry to become available. When this method returns,poll()will return a value (ornullif all services have been read) andtake()will return without blocking.- Throws:
InterruptedException- if the calling thread was interrupted while waiting for the next entry
-
await
Wait for a certain amount of time for a queue entry to become available.- Parameters:
time- the amount of time to waitunit- the unit of time (must not benull)- Throws:
InterruptedException- if the calling thread was interrupted while waiting for the next entry
-
isReady
boolean isReady()Query whether there is a value ready to be read.- Returns:
trueif the queue has a value,falseotherwise
-
poll
Get the location URI of the next entry from the queue without blocking. Returnsnullif there is no entry ready, or if the queue is finished (all services have been read). UseisFinished()to distinguish the cases.- Returns:
- the next URI, or
nullif the queue is not ready or is finished
-
take
Get the location URI of the next entry from the queue, blocking until one is available or the thread is interrupted. Returnsnullif the queue is finished (all services have been read).- Returns:
- the next URI, or
nullif the queue is finished - Throws:
InterruptedException- if the calling thread was interrupted while waiting for the next entry
-
pollService
ServiceURL pollService()Get the next entry from the queue without blocking. Returnsnullif there is no entry ready, or if the queue is finished (all services have been read). UseisFinished()to distinguish the cases.- Returns:
- the next service URL, or
nullif the queue is not ready or is finished
-
takeService
Get the next entry from the queue, blocking until one is available or the thread is interrupted. Returnsnullif the queue is finished (all services have been read).- Returns:
- the next service URL, or
nullif the queue is finished - Throws:
InterruptedException- if the calling thread was interrupted while waiting for the next entry
-
takeService
Get the next entry from the queue, blocking until one is available or timeout expires. Returnsnullif the queue is finished (all services have been read).- Returns:
- the next service URL, or
nullif the queue is finished - Throws:
InterruptedException- if the calling thread was interrupted while waiting for the next entry
-
isFinished
boolean isFinished()Query whether this queue is finished (all services have been read).- Returns:
trueif the queue is finished,falseotherwise
-
close
void close()Cancel any in-progress discovery for this queue. This method is idempotent.- Specified by:
closein interfaceAutoCloseable
-
getProblems
Get a list of problems that occurred during discovery.- Returns:
- a list of problems that occurred during discovery (not
null)
-
withTimeout
Create a version of this queue which has an absolute timeout, relative to when this method is called.- Parameters:
time- the timeout timeunit- the timeout unit (must not benull)- Returns:
- the services queue with a timeout (not
null)
-