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);
}
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;
}
}
}
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);
}
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);
}
Aggregations