Search in sources :

Example 1 with FragmentSetupException

use of org.apache.drill.exec.exception.FragmentSetupException in project drill by apache.

the class ExchangeRemoverMaterializer method visitStore.

@Override
public PhysicalOperator visitStore(Store store, IndexedFragmentNode iNode) throws ExecutionSetupException {
    PhysicalOperator child = store.getChild().accept(this, iNode);
    iNode.addAllocation(store);
    try {
        PhysicalOperator o = store.getSpecificStore(child, iNode.getMinorFragmentId());
        return o;
    } catch (PhysicalOperatorSetupException e) {
        throw new FragmentSetupException("Failure while generating a specific Store materialization.", e);
    }
}
Also used : PhysicalOperator(org.apache.drill.exec.physical.base.PhysicalOperator) PhysicalOperatorSetupException(org.apache.drill.exec.physical.PhysicalOperatorSetupException) FragmentSetupException(org.apache.drill.exec.exception.FragmentSetupException)

Example 2 with FragmentSetupException

use of org.apache.drill.exec.exception.FragmentSetupException in project drill by apache.

the class TestBitRpc method testConnectionBackpressure.

@Test
public void testConnectionBackpressure(@Injectable WorkerBee bee, @Injectable final WorkEventBus workBus) throws Exception {
    DrillConfig config1 = DrillConfig.create();
    final BootStrapContext c = new BootStrapContext(config1, ClassPathScanner.fromPrescan(config1));
    DrillConfig config2 = DrillConfig.create();
    BootStrapContext c2 = new BootStrapContext(config2, ClassPathScanner.fromPrescan(config2));
    final FragmentContext fcon = new MockUp<FragmentContext>() {

        BufferAllocator getAllocator() {
            return c.getAllocator();
        }
    }.getMockInstance();
    final FragmentManager fman = new MockUp<FragmentManager>() {

        int v = 0;

        @Mock
        boolean handle(IncomingDataBatch batch) throws FragmentSetupException, IOException {
            try {
                v++;
                if (v % 10 == 0) {
                    System.out.println("sleeping.");
                    Thread.sleep(3000);
                }
            } catch (InterruptedException e) {
            }
            RawFragmentBatch rfb = batch.newRawFragmentBatch(c.getAllocator());
            rfb.sendOk();
            rfb.release();
            return true;
        }

        public FragmentContext getFragmentContext() {
            return fcon;
        }
    }.getMockInstance();
    new NonStrictExpectations() {

        {
            workBus.getFragmentManagerIfExists((FragmentHandle) any);
            result = fman;
            workBus.getFragmentManager((FragmentHandle) any);
            result = fman;
        }
    };
    int port = 1234;
    DataConnectionConfig config = new DataConnectionConfig(c.getAllocator(), c, new DataServerRequestHandler(workBus, bee));
    DataServer server = new DataServer(config);
    port = server.bind(port, true);
    DrillbitEndpoint ep = DrillbitEndpoint.newBuilder().setAddress("localhost").setDataPort(port).build();
    DataConnectionManager manager = new DataConnectionManager(ep, config);
    DataTunnel tunnel = new DataTunnel(manager);
    AtomicLong max = new AtomicLong(0);
    for (int i = 0; i < 40; i++) {
        long t1 = System.currentTimeMillis();
        tunnel.sendRecordBatch(new TimingOutcome(max), new FragmentWritableBatch(false, QueryId.getDefaultInstance(), 1, 1, 1, 1, getRandomBatch(c.getAllocator(), 5000)));
        System.out.println(System.currentTimeMillis() - t1);
    // System.out.println("sent.");
    }
    System.out.println(String.format("Max time: %d", max.get()));
    assertTrue(max.get() > 2700);
    Thread.sleep(5000);
}
Also used : FragmentContext(org.apache.drill.exec.ops.FragmentContext) FragmentWritableBatch(org.apache.drill.exec.record.FragmentWritableBatch) Mock(mockit.Mock) DrillbitEndpoint(org.apache.drill.exec.proto.CoordinationProtos.DrillbitEndpoint) DrillConfig(org.apache.drill.common.config.DrillConfig) RawFragmentBatch(org.apache.drill.exec.record.RawFragmentBatch) FragmentSetupException(org.apache.drill.exec.exception.FragmentSetupException) IOException(java.io.IOException) DrillbitEndpoint(org.apache.drill.exec.proto.CoordinationProtos.DrillbitEndpoint) BufferAllocator(org.apache.drill.exec.memory.BufferAllocator) FragmentManager(org.apache.drill.exec.work.fragment.FragmentManager) AtomicLong(java.util.concurrent.atomic.AtomicLong) BootStrapContext(org.apache.drill.exec.server.BootStrapContext) NonStrictExpectations(mockit.NonStrictExpectations) ExecTest(org.apache.drill.exec.ExecTest) Test(org.junit.Test)

Example 3 with FragmentSetupException

use of org.apache.drill.exec.exception.FragmentSetupException in project drill by apache.

the class IncomingBuffers method batchArrived.

public boolean batchArrived(final IncomingDataBatch incomingBatch) throws FragmentSetupException, IOException {
    // Otherwise we would leak memory.
    try (AutoCloseableLock lock = sharedIncomingBatchLock.open()) {
        if (closed) {
            return false;
        }
        if (incomingBatch.getHeader().getIsLastBatch()) {
            streamsRemaining.decrementAndGet();
        }
        final int sendMajorFragmentId = incomingBatch.getHeader().getSendingMajorFragmentId();
        DataCollector collector = collectorMap.get(sendMajorFragmentId);
        if (collector == null) {
            throw new FragmentSetupException(String.format("We received a major fragment id that we were not expecting.  The id was %d. %s", sendMajorFragmentId, Arrays.toString(collectorMap.values().toArray())));
        }
        synchronized (collector) {
            final RawFragmentBatch newRawFragmentBatch = incomingBatch.newRawFragmentBatch(context.getAllocator());
            boolean decrementedToZero = collector.batchArrived(incomingBatch.getHeader().getSendingMinorFragmentId(), newRawFragmentBatch);
            newRawFragmentBatch.release();
            // we should only return true if remaining required has been decremented and is currently equal to zero.
            return decrementedToZero;
        }
    }
}
Also used : RawFragmentBatch(org.apache.drill.exec.record.RawFragmentBatch) AutoCloseableLock(org.apache.drill.common.concurrent.AutoCloseableLock) FragmentSetupException(org.apache.drill.exec.exception.FragmentSetupException)

Example 4 with FragmentSetupException

use of org.apache.drill.exec.exception.FragmentSetupException in project drill by apache.

the class Materializer method visitStore.

@Override
public PhysicalOperator visitStore(Store store, IndexedFragmentNode iNode) throws ExecutionSetupException {
    PhysicalOperator child = store.getChild().accept(this, iNode);
    iNode.addAllocation(store);
    try {
        PhysicalOperator o = store.getSpecificStore(child, iNode.getMinorFragmentId());
        o.setOperatorId(Short.MAX_VALUE & store.getOperatorId());
        //      logger.debug("New materialized store node {} with child {}", o, child);
        return o;
    } catch (PhysicalOperatorSetupException e) {
        throw new FragmentSetupException("Failure while generating a specific Store materialization.");
    }
}
Also used : PhysicalOperator(org.apache.drill.exec.physical.base.PhysicalOperator) PhysicalOperatorSetupException(org.apache.drill.exec.physical.PhysicalOperatorSetupException) FragmentSetupException(org.apache.drill.exec.exception.FragmentSetupException)

Example 5 with FragmentSetupException

use of org.apache.drill.exec.exception.FragmentSetupException in project drill by apache.

the class DataServerRequestHandler method handle.

@Override
public void handle(DataServerConnection connection, int rpcType, ByteBuf pBody, ByteBuf dBody, ResponseSender sender) throws RpcException {
    assert rpcType == BitData.RpcType.REQ_RECORD_BATCH_VALUE;
    final FragmentRecordBatch fragmentBatch = RpcBus.get(pBody, FragmentRecordBatch.PARSER);
    final AckSender ack = new AckSender(sender);
    // increment so we don't get false returns.
    ack.increment();
    try {
        final IncomingDataBatch batch = new IncomingDataBatch(fragmentBatch, (DrillBuf) dBody, ack);
        final int targetCount = fragmentBatch.getReceivingMinorFragmentIdCount();
        // randomize who gets first transfer (and thus ownership) so memory usage is balanced when we're sharing amongst
        // multiple fragments.
        final int firstOwner = ThreadLocalRandom.current().nextInt(targetCount);
        submit(batch, firstOwner, targetCount);
        submit(batch, 0, firstOwner);
    } catch (IOException | FragmentSetupException e) {
        logger.error("Failure while getting fragment manager. {}", QueryIdHelper.getQueryIdentifiers(fragmentBatch.getQueryId(), fragmentBatch.getReceivingMajorFragmentId(), fragmentBatch.getReceivingMinorFragmentIdList()), e);
        ack.clear();
        sender.send(new Response(BitData.RpcType.ACK, Acks.FAIL));
    } finally {
        // decrement the extra reference we grabbed at the top.
        ack.sendOk();
    }
}
Also used : Response(org.apache.drill.exec.rpc.Response) FragmentSetupException(org.apache.drill.exec.exception.FragmentSetupException) FragmentRecordBatch(org.apache.drill.exec.proto.BitData.FragmentRecordBatch) IOException(java.io.IOException)

Aggregations

FragmentSetupException (org.apache.drill.exec.exception.FragmentSetupException)5 IOException (java.io.IOException)2 PhysicalOperatorSetupException (org.apache.drill.exec.physical.PhysicalOperatorSetupException)2 PhysicalOperator (org.apache.drill.exec.physical.base.PhysicalOperator)2 RawFragmentBatch (org.apache.drill.exec.record.RawFragmentBatch)2 AtomicLong (java.util.concurrent.atomic.AtomicLong)1 Mock (mockit.Mock)1 NonStrictExpectations (mockit.NonStrictExpectations)1 AutoCloseableLock (org.apache.drill.common.concurrent.AutoCloseableLock)1 DrillConfig (org.apache.drill.common.config.DrillConfig)1 ExecTest (org.apache.drill.exec.ExecTest)1 BufferAllocator (org.apache.drill.exec.memory.BufferAllocator)1 FragmentContext (org.apache.drill.exec.ops.FragmentContext)1 FragmentRecordBatch (org.apache.drill.exec.proto.BitData.FragmentRecordBatch)1 DrillbitEndpoint (org.apache.drill.exec.proto.CoordinationProtos.DrillbitEndpoint)1 FragmentWritableBatch (org.apache.drill.exec.record.FragmentWritableBatch)1 Response (org.apache.drill.exec.rpc.Response)1 BootStrapContext (org.apache.drill.exec.server.BootStrapContext)1 FragmentManager (org.apache.drill.exec.work.fragment.FragmentManager)1 Test (org.junit.Test)1