Class FlightEndpointDataQueue
java.lang.Object
org.apache.arrow.driver.jdbc.utils.FlightEndpointDataQueue
- All Implemented Interfaces:
AutoCloseable
Auxiliary class used to handle consuming of multiple
FlightStream
.
The usage follows this routine:
- Create a
FlightStreamQueue
; - Call
enqueue(FlightStream)
for all streams to be consumed; - Call
next()
to get a FlightStream that is ready to consume - Consume the given FlightStream and add it back to the queue - call
enqueue(FlightStream)
- Repeat from (3) until
next()
returns null.
-
Constructor Summary
ModifierConstructorDescriptionprotected
FlightEndpointDataQueue
(CompletionService<CloseableEndpointStreamPair> executorService) Instantiate a new FlightStreamQueue. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Checks if this queue is open.void
close()
static FlightEndpointDataQueue
createNewQueue
(ExecutorService service) Creates a newFlightEndpointDataQueue
from the providedExecutorService
.void
enqueue
(Collection<CloseableEndpointStreamPair> endpointRequests) Readily adds givenFlightStream
s to the queue.void
enqueue
(CloseableEndpointStreamPair endpointRequest) Adds givenFlightStream
to the queue.boolean
isClosed()
Gets whether this queue is closed.next()
Blocking request to get the next ready FlightStream in queue.Blocking request with timeout to get the next ready FlightStream in queue.
-
Constructor Details
-
FlightEndpointDataQueue
Instantiate a new FlightStreamQueue.
-
-
Method Details
-
createNewQueue
Creates a newFlightEndpointDataQueue
from the providedExecutorService
.- Parameters:
service
- the service from which to create a new queue.- Returns:
- a new queue.
-
isClosed
public boolean isClosed()Gets whether this queue is closed.- Returns:
- a boolean indicating whether this resource is closed.
-
next
public CloseableEndpointStreamPair next(long timeoutValue, TimeUnit timeoutUnit) throws SQLException Blocking request with timeout to get the next ready FlightStream in queue.- Parameters:
timeoutValue
- the amount of time to be waitedtimeoutUnit
- the timeoutValue time unit- Returns:
- a FlightStream that is ready to consume or null if all FlightStreams are ended.
- Throws:
SQLException
-
next
Blocking request to get the next ready FlightStream in queue.- Returns:
- a FlightStream that is ready to consume or null if all FlightStreams are ended.
- Throws:
SQLException
-
checkOpen
public void checkOpen()Checks if this queue is open. -
enqueue
Readily adds givenFlightStream
s to the queue. -
enqueue
Adds givenFlightStream
to the queue. -
close
- Specified by:
close
in interfaceAutoCloseable
- Throws:
SQLException
-