public class FragmentExecutor extends Object implements Runnable
The FragmentExecutor
runs a fragment's RootExec
in the
run()
method in a single thread. While a fragment is
running it may be subject to termination requests. The
FragmentExecutor
is responsible for gracefully handling termination
requests for the RootExec
. There are two types of termination
messages:
RootExec
need to terminate immediately.RootExec
will only
terminate once it has received
FragmentExecutor.EventType.RECEIVER_FINISHED
messages for all
downstream receivers.
The FragmentExecutor
processes termination requests appropriately for
the RootExec
. A Cancellation Request is signaled when
cancel()
is called. A Receiver Finished event
is signaled when
FragmentExecutor#receivingFragmentFinished(FragmentHandle)
is called.
The way in which these signals are handled is the following:
There are two ways in which a cancellation request can be handled when
cancel()
is called.
RootExec
for the
fragment is even started. In this case we can cleanup resources allocated for
the fragment and never start a RootExec
RootExec
for the
fragment is started. In this the cancellation request is sent to the
FragmentEventProcessor
. If this is not the first cancellation request
it is ignored. If this is the first cancellation request the RootExec
for this fragment is terminated by interrupting it. Then the
run()
thread proceeds to cleanup resources
normally
When FragmentExecutor#receivingFragmentFinished(FragmentHandle)
is
called, the message is passed to the FragmentEventProcessor
if we did
not already receive a Cancellation request. Then the finished message is
queued in receiverFinishedQueue
. The
run()
polls
receiverFinishedQueue
and signals the
RootExec
with
RootExec#receivingFragmentFinished(FragmentHandle)
appropriately.
There are still a few aspects of the FragmentExecutor
design that are
not clear.
Constructor and Description |
---|
FragmentExecutor(ExecutorFragmentContext context,
BitControl.PlanFragment fragment,
FragmentStatusReporter statusReporter)
Create a FragmentExecutor where we need to parse and materialize the root operator.
|
FragmentExecutor(ExecutorFragmentContext context,
BitControl.PlanFragment fragment,
FragmentStatusReporter statusReporter,
FragmentRoot rootOperator)
Create a FragmentExecutor where we already have a root operator in memory.
|
Modifier and Type | Method and Description |
---|---|
void |
cancel()
Cancel the execution of this fragment is in an appropriate state.
|
ExecutorFragmentContext |
getContext() |
BitControl.FragmentStatus |
getStatus()
Returns the current fragment status if the fragment is running.
|
void |
receivingFragmentFinished(ExecProtos.FragmentHandle handle)
Inform this fragment that one of its downstream partners no longer needs
additional records.
|
void |
run() |
String |
toString() |
void |
unpause()
Resume all the pauses within the current context.
|
public FragmentExecutor(ExecutorFragmentContext context, BitControl.PlanFragment fragment, FragmentStatusReporter statusReporter)
context
- fragment
- statusReporter
- public FragmentExecutor(ExecutorFragmentContext context, BitControl.PlanFragment fragment, FragmentStatusReporter statusReporter, FragmentRoot rootOperator)
context
- fragment
- statusReporter
- rootOperator
- public BitControl.FragmentStatus getStatus()
public void cancel()
Cancel the execution of this fragment is in an appropriate state. Messages come from external.
Note: This will be called from threads Other than the one running this runnable(), so we need to be careful about the state transitions that can result.
public void unpause()
public void receivingFragmentFinished(ExecProtos.FragmentHandle handle)
handle
- The downstream FragmentHandle of the Fragment that needs no more
records from this Fragment.public ExecutorFragmentContext getContext()
Copyright © 1970 The Apache Software Foundation. All rights reserved.