use of org.apache.drill.exec.work.fragment.FragmentExecutor 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);
}
}
use of org.apache.drill.exec.work.fragment.FragmentExecutor in project drill by apache.
the class ControlMessageHandler method startNewRemoteFragment.
private void startNewRemoteFragment(final PlanFragment fragment) throws UserRpcException {
logger.debug("Received remote fragment start instruction", fragment);
final DrillbitContext drillbitContext = bee.getContext();
try {
// we either need to start the fragment if it is a leaf fragment, or set up a fragment manager if it is non leaf.
if (fragment.getLeafFragment()) {
final FragmentContext context = new FragmentContext(drillbitContext, fragment, drillbitContext.getFunctionImplementationRegistry());
final ControlTunnel tunnel = drillbitContext.getController().getTunnel(fragment.getForeman());
final FragmentStatusReporter statusReporter = new FragmentStatusReporter(context, tunnel);
final FragmentExecutor fr = new FragmentExecutor(context, fragment, statusReporter);
bee.addFragmentRunner(fr);
} else {
// isIntermediate, store for incoming data.
final NonRootFragmentManager manager = new NonRootFragmentManager(fragment, drillbitContext);
drillbitContext.getWorkBus().addFragmentManager(manager);
}
} catch (final Exception e) {
throw new UserRpcException(drillbitContext.getEndpoint(), "Failure while trying to start remote fragment", e);
} catch (final OutOfMemoryError t) {
if (t.getMessage().startsWith("Direct buffer")) {
throw new UserRpcException(drillbitContext.getEndpoint(), "Out of direct memory while trying to start remote fragment", t);
} else {
throw t;
}
}
}
use of org.apache.drill.exec.work.fragment.FragmentExecutor in project drill by axbaretto.
the class FragmentsRunner method setupRootFragment.
/**
* Set up the root fragment (which will run locally), and submit it for execution.
*
* @param rootFragment root fragment
* @param rootOperator root operator
* @throws ExecutionSetupException
*/
private void setupRootFragment(final PlanFragment rootFragment, final FragmentRoot rootOperator) throws ExecutionSetupException {
QueryManager queryManager = foreman.getQueryManager();
final FragmentContextImpl rootContext = new FragmentContextImpl(drillbitContext, rootFragment, foreman.getQueryContext(), initiatingClient, drillbitContext.getFunctionImplementationRegistry());
final FragmentStatusReporter statusReporter = new FragmentStatusReporter(rootContext);
final FragmentExecutor rootRunner = new FragmentExecutor(rootContext, rootFragment, statusReporter, rootOperator);
final RootFragmentManager fragmentManager = new RootFragmentManager(rootFragment, rootRunner, statusReporter);
queryManager.addFragmentStatusTracker(rootFragment, true);
// FragmentManager is setting buffer for FragmentContext
if (rootContext.isBuffersDone()) {
// if we don't have to wait for any incoming data, start the fragment runner.
bee.addFragmentRunner(rootRunner);
} else {
// if we do, record the fragment manager in the workBus.
drillbitContext.getWorkBus().addFragmentManager(fragmentManager);
}
}
use of org.apache.drill.exec.work.fragment.FragmentExecutor in project drill by axbaretto.
the class FragmentsRunner method startLocalFragment.
/**
* Start the locally assigned leaf or intermediate fragment
*
* @param fragment fragment
*/
private void startLocalFragment(final PlanFragment fragment) throws ExecutionSetupException {
logger.debug("Received local fragment start instruction", fragment);
final FragmentContextImpl fragmentContext = new FragmentContextImpl(drillbitContext, fragment, drillbitContext.getFunctionImplementationRegistry());
final FragmentStatusReporter statusReporter = new FragmentStatusReporter(fragmentContext);
final FragmentExecutor fragmentExecutor = new FragmentExecutor(fragmentContext, fragment, statusReporter);
// we either need to start the fragment if it is a leaf fragment, or set up a fragment manager if it is non leaf.
if (fragment.getLeafFragment()) {
bee.addFragmentRunner(fragmentExecutor);
} else {
// isIntermediate, store for incoming data.
final NonRootFragmentManager manager = new NonRootFragmentManager(fragment, fragmentExecutor, statusReporter);
drillbitContext.getWorkBus().addFragmentManager(manager);
}
}
use of org.apache.drill.exec.work.fragment.FragmentExecutor in project drill by axbaretto.
the class ControlMessageHandler method startNewFragment.
/**
* Start a new fragment on this node. These fragments can be leaf or intermediate fragments
* which are scheduled by remote or local Foreman node.
* @param fragment
* @throws UserRpcException
*/
private void startNewFragment(final PlanFragment fragment, final DrillbitContext drillbitContext) throws UserRpcException {
logger.debug("Received remote fragment start instruction", fragment);
try {
final FragmentContextImpl fragmentContext = new FragmentContextImpl(drillbitContext, fragment, drillbitContext.getFunctionImplementationRegistry());
final FragmentStatusReporter statusReporter = new FragmentStatusReporter(fragmentContext);
final FragmentExecutor fragmentExecutor = new FragmentExecutor(fragmentContext, fragment, statusReporter);
// we either need to start the fragment if it is a leaf fragment, or set up a fragment manager if it is non leaf.
if (fragment.getLeafFragment()) {
bee.addFragmentRunner(fragmentExecutor);
} else {
// isIntermediate, store for incoming data.
final NonRootFragmentManager manager = new NonRootFragmentManager(fragment, fragmentExecutor, statusReporter);
drillbitContext.getWorkBus().addFragmentManager(manager);
}
} catch (final ExecutionSetupException ex) {
throw new UserRpcException(drillbitContext.getEndpoint(), "Failed to create fragment context", ex);
} catch (final Exception e) {
throw new UserRpcException(drillbitContext.getEndpoint(), "Failure while trying to start remote fragment", e);
} catch (final OutOfMemoryError t) {
if (t.getMessage().startsWith("Direct buffer")) {
throw new UserRpcException(drillbitContext.getEndpoint(), "Out of direct memory while trying to start remote fragment", t);
} else {
throw t;
}
}
}
Aggregations