java.lang.Object
org.elasticsearch.compute.operator.Driver
- All Implemented Interfaces:
Closeable,AutoCloseable,Describable,Releasable
- Direct Known Subclasses:
BatchDriver
A driver operates single-threadedly on a simple chain of
Operators, passing
Pages from one operator to the next. It also controls the lifecycle of the
operators.
The operator chain typically starts with a source operator (i.e. an operator that purely produces pages)
and ends with a sink operator (i.e. an operator that purely consumes pages).
More details on how this integrates with other components can be found in the package documentation of
org.elasticsearch.compute-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionDriver(String sessionId, String shortDescription, String clusterName, String nodeName, long startTime, long startNanos, DriverContext driverContext, Supplier<String> description, SourceOperator source, List<Operator> intermediateOperators, SinkOperator sink, TimeValue statusInterval, Releasable releasable) Creates a new driver with a chain of operators. -
Method Summary
Modifier and TypeMethodDescriptionvoidabort(Exception reason, ActionListener<Void> listener) Abort the driver and wait for it to finishvoidvoidclose()protected intcloseEarlyFinishedOperators(ListIterator<Operator> operators, LongSupplier currentTimeNanosSupplier, long lastStatusUpdate) describe()Returns a description of the component.protected voidprotected voidFinish all active operators.booleanRequests that this driver wind down at its next iteration by treating the operator chain as if its sink had closed.protected voidCalled when no pages were moved in a loop iteration.profile()Build a "profile" of this driver's operations after it's been completed.booleanFires any non-destructive stop hooks operators registered on this driver'sDriverContext.static voidstart(ThreadContext threadContext, Executor executor, Driver driver, int maxIterations, ActionListener<Void> listener) status()Get the last status update from the driver.toString()
-
Field Details
-
DEFAULT_TIME_BEFORE_YIELDING
-
DEFAULT_MAX_ITERATIONS
public static final int DEFAULT_MAX_ITERATIONS- See Also:
-
DEFAULT_STATUS_INTERVAL
Minimum time between updating status. -
shortDescription
Description of the driver. This description should be short and meaningful as a grouping identifier. We use the phase of the query right now: "data", "node_reduce", "final". -
activeOperators
-
-
Constructor Details
-
Driver
public Driver(String sessionId, String shortDescription, String clusterName, String nodeName, long startTime, long startNanos, DriverContext driverContext, Supplier<String> description, SourceOperator source, List<Operator> intermediateOperators, SinkOperator sink, TimeValue statusInterval, Releasable releasable) Creates a new driver with a chain of operators.- Parameters:
sessionId- session IdshortDescription- Description of the driver. This description should be short and meaningful as a grouping identifier. We use the phase of the query right now: "data", "node_reduce", "final".driverContext- the driver contextsource- source operatorintermediateOperators- the chain of operators to executesink- sink operatorstatusInterval- minimum status reporting intervalreleasable- aReleasableto invoked once the chain of operators has run to completion
-
-
Method Details
-
driverContext
-
close
public void close()- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein interfaceReleasable
-
abort
Abort the driver and wait for it to finish -
onNoPagesMoved
protected void onNoPagesMoved()Called when no pages were moved in a loop iteration. Subclasses can override this to detect when the driver is idle/empty. -
closeEarlyFinishedOperators
protected int closeEarlyFinishedOperators(ListIterator<Operator> operators, LongSupplier currentTimeNanosSupplier, long lastStatusUpdate) -
finishAllActiveOperators
protected void finishAllActiveOperators()Finish all active operators. This is used before throwing DriverEarlyTerminationException to ensure all operators are properly finished and can be closed. -
cancel
-
start
public static void start(ThreadContext threadContext, Executor executor, Driver driver, int maxIterations, ActionListener<Void> listener) -
finishEarly
public boolean finishEarly()Requests that this driver wind down at its next iteration by treating the operator chain as if its sink had closed. Existing callers wire this toExchangeSinkOperatorcompletion, so we keep its semantics narrow — the early-termination checker throwsDriverEarlyTerminationExceptionand operator teardown discards anything that has not already crossed the sink. Source operators that want STOP to drain in-flight pages rather than drop them should register astop hookinstead. -
runStopHooks
public boolean runStopHooks()Fires any non-destructive stop hooks operators registered on this driver'sDriverContext. Operators use this to interrupt their input side (e.g. close a buffer's producer) while leaving already-buffered pages reachable to the driver loop, so the response contains every row the source had already produced when STOP arrived. Returnstruewhen at least one hook reported it cut a still-running unit of work, which the async stop action uses as an honest signal to flagis_partial=true. -
drainAndCloseOperators
-
toString
-
describe
Description copied from interface:DescribableReturns a description of the component. This description can be more specific than Object::toString.- Specified by:
describein interfaceDescribable- Returns:
- the description
-
sessionId
-
status
Get the last status update from the driver. These updates are made when the driver is queued and after every processingbatch. -
profile
Build a "profile" of this driver's operations after it's been completed. This doesn't make sense to call before the driver is done.
-