Search in sources :

Example 1 with RootFragmentManager

use of org.apache.drill.exec.work.fragment.RootFragmentManager in project drill by apache.

the class Foreman method setupRootFragment.

/**
   * Set up the root fragment (which will run locally), and submit it for execution.
   *
   * @param rootFragment
   * @param rootOperator
   * @throws ExecutionSetupException
   */
private void setupRootFragment(final PlanFragment rootFragment, final FragmentRoot rootOperator) throws ExecutionSetupException {
    @SuppressWarnings("resource") final FragmentContext rootContext = new FragmentContext(drillbitContext, rootFragment, queryContext, initiatingClient, drillbitContext.getFunctionImplementationRegistry());
    @SuppressWarnings("resource") final IncomingBuffers buffers = new IncomingBuffers(rootFragment, rootContext);
    rootContext.setBuffers(buffers);
    queryManager.addFragmentStatusTracker(rootFragment, true);
    final ControlTunnel tunnel = drillbitContext.getController().getTunnel(queryContext.getCurrentEndpoint());
    final FragmentExecutor rootRunner = new FragmentExecutor(rootContext, rootFragment, new FragmentStatusReporter(rootContext, tunnel), rootOperator);
    final RootFragmentManager fragmentManager = new RootFragmentManager(rootFragment.getHandle(), buffers, rootRunner);
    if (buffers.isDone()) {
        // if we don't have to wait for any incoming data, start the fragment runner.
        bee.addFragmentRunner(fragmentManager.getRunnable());
    } else {
        // if we do, record the fragment manager in the workBus.
        drillbitContext.getWorkBus().addFragmentManager(fragmentManager);
    }
}
Also used : ControlTunnel(org.apache.drill.exec.rpc.control.ControlTunnel) IncomingBuffers(org.apache.drill.exec.work.batch.IncomingBuffers) FragmentContext(org.apache.drill.exec.ops.FragmentContext) FragmentStatusReporter(org.apache.drill.exec.work.fragment.FragmentStatusReporter) RootFragmentManager(org.apache.drill.exec.work.fragment.RootFragmentManager) FragmentExecutor(org.apache.drill.exec.work.fragment.FragmentExecutor)

Aggregations

FragmentContext (org.apache.drill.exec.ops.FragmentContext)1 ControlTunnel (org.apache.drill.exec.rpc.control.ControlTunnel)1 IncomingBuffers (org.apache.drill.exec.work.batch.IncomingBuffers)1 FragmentExecutor (org.apache.drill.exec.work.fragment.FragmentExecutor)1 FragmentStatusReporter (org.apache.drill.exec.work.fragment.FragmentStatusReporter)1 RootFragmentManager (org.apache.drill.exec.work.fragment.RootFragmentManager)1