Search in sources :

Example 6 with Controller

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

the class FragmentsRunner 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 node: {}\nData: {}", 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)

Example 7 with Controller

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

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) {
    @SuppressWarnings("resource") 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 8 with Controller

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

the class FragmentStatusReporterTest method setUp.

@Before
public void setUp() throws Exception {
    context = mock(FragmentContextImpl.class);
    Controller controller = mock(Controller.class);
    // Create 2 different endpoint such that foremanEndpoint is different than
    // localEndpoint
    DrillbitEndpoint localEndpoint = DrillbitEndpoint.newBuilder().setAddress("10.0.0.1").build();
    DrillbitEndpoint foremanEndpoint = DrillbitEndpoint.newBuilder().setAddress("10.0.0.2").build();
    foremanTunnel = mock(ControlTunnel.class);
    when(context.getEndpoint()).thenReturn(localEndpoint);
    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 9 with Controller

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

the class FragmentsRunner method sendRemoteFragments.

/**
 * Send all the remote fragments belonging to a single target drillbit in one request. If the assignment
 * DrillbitEndpoint is local Drillbit then {@link Controller#getTunnel(DrillbitEndpoint)} takes care of submitting it
 * locally without actually creating a Control Connection to itself.
 *
 * @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) {
    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 node: {}\nData: {}", 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