Search in sources :

Example 1 with Controller

use of org.apache.drill.exec.rpc.control.Controller in project drill by axbaretto.

the class QueryManager method unpauseExecutingFragments.

/**
 * Sends a resume signal to all fragments, regardless of their state, since the fragment might have paused before
 * sending any message. Resume all fragments through the control tunnel.
 */
void unpauseExecutingFragments(final DrillbitContext drillbitContext) {
    @SuppressWarnings("resource") final Controller controller = drillbitContext.getController();
    for (final FragmentData data : fragmentDataSet) {
        final DrillbitEndpoint endpoint = data.getEndpoint();
        final FragmentHandle handle = data.getHandle();
        controller.getTunnel(endpoint).unpauseFragment(new SignalListener(endpoint, handle, SignalListener.Signal.UNPAUSE), handle);
    }
}
Also used : DrillbitEndpoint(org.apache.drill.exec.proto.CoordinationProtos.DrillbitEndpoint) FragmentHandle(org.apache.drill.exec.proto.ExecProtos.FragmentHandle) Controller(org.apache.drill.exec.rpc.control.Controller)

Example 2 with Controller

use of org.apache.drill.exec.rpc.control.Controller in project drill by apache.

the class QueryManager method cancelExecutingFragments.

/**
 * Stop all fragments with currently *known* active status (active as in SENDING, AWAITING_ALLOCATION, RUNNING).
 *
 * For the actual cancel calls for intermediate and leaf fragments, see
 * {@link org.apache.drill.exec.work.batch.ControlMessageHandler#cancelFragment}
 * (1) Root fragment: pending or running, send the cancel signal through a tunnel.
 * (2) Intermediate fragment: pending or running, send the cancel signal through a tunnel (for local and remote
 *    fragments). The actual cancel is done by delegating the cancel to the work bus.
 * (3) Leaf fragment: running, send the cancel signal through a tunnel. The cancel is done directly.
 */
void cancelExecutingFragments(final DrillbitContext drillbitContext) {
    final Controller controller = drillbitContext.getController();
    for (final FragmentData data : fragmentDataSet) {
        switch(data.getState()) {
            case SENDING:
            case AWAITING_ALLOCATION:
            case RUNNING:
                final FragmentHandle handle = data.getHandle();
                final DrillbitEndpoint endpoint = data.getEndpoint();
                // TODO is the CancelListener redundant? Does the FragmentStatusListener get notified of the same?
                controller.getTunnel(endpoint).cancelFragment(new SignalListener(endpoint, handle, SignalListener.Signal.CANCEL), handle);
                break;
            case FINISHED:
            case CANCELLATION_REQUESTED:
            case CANCELLED:
            case FAILED:
                // nothing to do
                break;
        }
    }
}
Also used : DrillbitEndpoint(org.apache.drill.exec.proto.CoordinationProtos.DrillbitEndpoint) FragmentHandle(org.apache.drill.exec.proto.ExecProtos.FragmentHandle) Controller(org.apache.drill.exec.rpc.control.Controller)

Example 3 with Controller

use of org.apache.drill.exec.rpc.control.Controller in project drill by apache.

the class QueryManager method unpauseExecutingFragments.

/**
 * Sends a resume signal to all fragments, regardless of their state, since the fragment might have paused before
 * sending any message. Resume all fragments through the control tunnel.
 */
void unpauseExecutingFragments(final DrillbitContext drillbitContext) {
    final Controller controller = drillbitContext.getController();
    for (final FragmentData data : fragmentDataSet) {
        final DrillbitEndpoint endpoint = data.getEndpoint();
        final FragmentHandle handle = data.getHandle();
        controller.getTunnel(endpoint).unpauseFragment(new SignalListener(endpoint, handle, SignalListener.Signal.UNPAUSE), handle);
    }
}
Also used : DrillbitEndpoint(org.apache.drill.exec.proto.CoordinationProtos.DrillbitEndpoint) FragmentHandle(org.apache.drill.exec.proto.ExecProtos.FragmentHandle) Controller(org.apache.drill.exec.rpc.control.Controller)

Example 4 with Controller

use of org.apache.drill.exec.rpc.control.Controller in project drill by apache.

the class FragmentStatusReporterTest method setUp.

@Before
public void setUp() throws Exception {
    final FragmentContextImpl context = mock(FragmentContextImpl.class);
    Controller controller = mock(Controller.class);
    // Create Foreman Endpoint and it's tunnel
    DrillbitEndpoint foremanEndpoint = DrillbitEndpoint.newBuilder().setAddress("10.0.0.2").build();
    foremanTunnel = mock(ControlTunnel.class);
    when(context.getController()).thenReturn(controller);
    when(controller.getTunnel(foremanEndpoint)).thenReturn(foremanTunnel);
    when(context.getStats()).thenReturn(mock(FragmentStats.class));
    when(context.getHandle()).thenReturn(FragmentHandle.getDefaultInstance());
    when(context.getAllocator()).thenReturn(mock(BufferAllocator.class));
    when(context.getForemanEndpoint()).thenReturn(foremanEndpoint);
    statusReporter = new FragmentStatusReporter(context);
}
Also used : ControlTunnel(org.apache.drill.exec.rpc.control.ControlTunnel) DrillbitEndpoint(org.apache.drill.exec.proto.CoordinationProtos.DrillbitEndpoint) FragmentContextImpl(org.apache.drill.exec.ops.FragmentContextImpl) FragmentStats(org.apache.drill.exec.ops.FragmentStats) Controller(org.apache.drill.exec.rpc.control.Controller) BufferAllocator(org.apache.drill.exec.memory.BufferAllocator) Before(org.junit.Before)

Example 5 with Controller

use of org.apache.drill.exec.rpc.control.Controller in project drill by apache.

the class Foreman method sendRemoteFragments.

/**
   * Send all the remote fragments belonging to a single target drillbit in one request.
   *
   * @param assignment the drillbit assigned to these fragments
   * @param fragments the set of fragments
   * @param latch the countdown latch used to track the requests to all endpoints
   * @param fragmentSubmitFailures the submission failure counter used to track the requests to all endpoints
   */
private void sendRemoteFragments(final DrillbitEndpoint assignment, final Collection<PlanFragment> fragments, final CountDownLatch latch, final FragmentSubmitFailures fragmentSubmitFailures) {
    @SuppressWarnings("resource") final Controller controller = drillbitContext.getController();
    final InitializeFragments.Builder fb = InitializeFragments.newBuilder();
    for (final PlanFragment planFragment : fragments) {
        fb.addFragment(planFragment);
    }
    final InitializeFragments initFrags = fb.build();
    logger.debug("Sending remote fragments to \nNode:\n{} \n\nData:\n{}", assignment, initFrags);
    final FragmentSubmitListener listener = new FragmentSubmitListener(assignment, initFrags, latch, fragmentSubmitFailures);
    controller.getTunnel(assignment).sendFragments(listener, initFrags);
}
Also used : InitializeFragments(org.apache.drill.exec.proto.BitControl.InitializeFragments) Controller(org.apache.drill.exec.rpc.control.Controller) PlanFragment(org.apache.drill.exec.proto.BitControl.PlanFragment)

Aggregations

Controller (org.apache.drill.exec.rpc.control.Controller)9 DrillbitEndpoint (org.apache.drill.exec.proto.CoordinationProtos.DrillbitEndpoint)6 FragmentHandle (org.apache.drill.exec.proto.ExecProtos.FragmentHandle)4 InitializeFragments (org.apache.drill.exec.proto.BitControl.InitializeFragments)3 PlanFragment (org.apache.drill.exec.proto.BitControl.PlanFragment)3 BufferAllocator (org.apache.drill.exec.memory.BufferAllocator)2 FragmentContextImpl (org.apache.drill.exec.ops.FragmentContextImpl)2 FragmentStats (org.apache.drill.exec.ops.FragmentStats)2 ControlTunnel (org.apache.drill.exec.rpc.control.ControlTunnel)2 Before (org.junit.Before)2