Search in sources :

Example 6 with DrillbitContext

use of org.apache.drill.exec.server.DrillbitContext in project drill by apache.

the class QueryTestUtil method restoreScalarReplacementOption.

/**
   * Restore the original scalar replacement option returned from
   * setupScalarReplacementOption().
   *
   * <p>This also flushes the compiled code cache.
   *
   * @param drillbit the drillbit
   * @param srOption the scalar replacement option value to use
   */
public static void restoreScalarReplacementOption(final Drillbit drillbit, final OptionValue srOption) {
    @SuppressWarnings("resource") final DrillbitContext drillbitContext = drillbit.getContext();
    @SuppressWarnings("resource") final OptionManager optionManager = drillbitContext.getOptionManager();
    optionManager.setOption(srOption);
    // flush the code cache
    drillbitContext.getCompiler().flushCache();
}
Also used : DrillbitContext(org.apache.drill.exec.server.DrillbitContext) OptionManager(org.apache.drill.exec.server.options.OptionManager)

Example 7 with DrillbitContext

use of org.apache.drill.exec.server.DrillbitContext in project drill by apache.

the class TestDynamicUDFSupport method spyFunctionImplementationRegistry.

private FunctionImplementationRegistry spyFunctionImplementationRegistry() {
    DrillbitContext drillbitContext = getDrillbitContext();
    FunctionImplementationRegistry spy = spy(drillbitContext.getFunctionImplementationRegistry());
    Deencapsulation.setField(drillbitContext, "functionRegistry", spy);
    return spy;
}
Also used : DrillbitContext(org.apache.drill.exec.server.DrillbitContext) FunctionImplementationRegistry(org.apache.drill.exec.expr.fn.FunctionImplementationRegistry)

Example 8 with DrillbitContext

use of org.apache.drill.exec.server.DrillbitContext 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;
        }
    }
}
Also used : DrillbitContext(org.apache.drill.exec.server.DrillbitContext) ControlTunnel(org.apache.drill.exec.rpc.control.ControlTunnel) NonRootFragmentManager(org.apache.drill.exec.work.fragment.NonRootFragmentManager) UserRpcException(org.apache.drill.exec.rpc.UserRpcException) FragmentContext(org.apache.drill.exec.ops.FragmentContext) FragmentStatusReporter(org.apache.drill.exec.work.fragment.FragmentStatusReporter) FragmentExecutor(org.apache.drill.exec.work.fragment.FragmentExecutor) UserRpcException(org.apache.drill.exec.rpc.UserRpcException) RpcException(org.apache.drill.exec.rpc.RpcException)

Example 9 with DrillbitContext

use of org.apache.drill.exec.server.DrillbitContext in project drill by apache.

the class WorkManager method start.

public void start(final DrillbitEndpoint endpoint, final Controller controller, final DataConnectionCreator data, final ClusterCoordinator coord, final PersistentStoreProvider provider, final PersistentStoreProvider profilesProvider) {
    dContext = new DrillbitContext(endpoint, bContext, coord, controller, data, workBus, provider, profilesProvider);
    statusThread.start();
    DrillMetrics.register("drill.fragments.running", new Gauge<Integer>() {

        @Override
        public Integer getValue() {
            return runningFragments.size();
        }
    });
}
Also used : DrillbitContext(org.apache.drill.exec.server.DrillbitContext)

Example 10 with DrillbitContext

use of org.apache.drill.exec.server.DrillbitContext in project drill by apache.

the class RunRootExec method main.

public static void main(String[] args) throws Exception {
    String path = args[0];
    int iterations = Integer.parseInt(args[1]);
    Drillbit bit = new Drillbit(c, RemoteServiceSet.getLocalServiceSet(), ClassPathScanner.fromPrescan(c));
    bit.run();
    DrillbitContext bitContext = bit.getContext();
    PhysicalPlanReader reader = bitContext.getPlanReader();
    PhysicalPlan plan = reader.readPhysicalPlan(Files.toString(new File(path), Charsets.UTF_8));
    FunctionImplementationRegistry registry = bitContext.getFunctionImplementationRegistry();
    FragmentContext context = new FragmentContext(bitContext, PlanFragment.getDefaultInstance(), null, registry);
    SimpleRootExec exec;
    for (int i = 0; i < iterations; i++) {
        Stopwatch w = Stopwatch.createStarted();
        System.out.println("STARTITER:" + i);
        exec = new SimpleRootExec(ImplCreator.getExec(context, (FragmentRoot) plan.getSortedOperators(false).iterator().next()));
        while (exec.next()) {
            for (ValueVector v : exec) {
                v.clear();
            }
        }
        System.out.println("ENDITER: " + i);
        System.out.println("TIME: " + w.elapsed(TimeUnit.MILLISECONDS) + "ms");
        exec.close();
    }
    context.close();
    bit.close();
}
Also used : DrillbitContext(org.apache.drill.exec.server.DrillbitContext) ValueVector(org.apache.drill.exec.vector.ValueVector) SimpleRootExec(org.apache.drill.exec.physical.impl.SimpleRootExec) PhysicalPlan(org.apache.drill.exec.physical.PhysicalPlan) FragmentContext(org.apache.drill.exec.ops.FragmentContext) Drillbit(org.apache.drill.exec.server.Drillbit) PhysicalPlanReader(org.apache.drill.exec.planner.PhysicalPlanReader) Stopwatch(com.google.common.base.Stopwatch) File(java.io.File) FunctionImplementationRegistry(org.apache.drill.exec.expr.fn.FunctionImplementationRegistry)

Aggregations

DrillbitContext (org.apache.drill.exec.server.DrillbitContext)17 Test (org.junit.Test)8 FunctionImplementationRegistry (org.apache.drill.exec.expr.fn.FunctionImplementationRegistry)5 PhysicalPlanReader (org.apache.drill.exec.planner.PhysicalPlanReader)5 DrillbitEndpoint (org.apache.drill.exec.proto.CoordinationProtos.DrillbitEndpoint)5 Drillbit (org.apache.drill.exec.server.Drillbit)5 RemoteServiceSet (org.apache.drill.exec.server.RemoteServiceSet)5 DrillConfig (org.apache.drill.common.config.DrillConfig)4 FragmentContext (org.apache.drill.exec.ops.FragmentContext)4 PhysicalPlan (org.apache.drill.exec.physical.PhysicalPlan)4 QueryContext (org.apache.drill.exec.ops.QueryContext)3 File (java.io.File)2 IOException (java.io.IOException)2 ZookeeperHelper (org.apache.drill.exec.ZookeeperHelper)2 DrillbitStartupException (org.apache.drill.exec.exception.DrillbitStartupException)2 OutOfMemoryException (org.apache.drill.exec.exception.OutOfMemoryException)2 FragmentRoot (org.apache.drill.exec.physical.base.FragmentRoot)2 PhysicalOperator (org.apache.drill.exec.physical.base.PhysicalOperator)2 Fragment (org.apache.drill.exec.planner.fragment.Fragment)2 PlanningSet (org.apache.drill.exec.planner.fragment.PlanningSet)2