Search in sources :

Example 36 with ExecutionSetupException

use of org.apache.drill.common.exceptions.ExecutionSetupException in project drill by apache.

the class PersistentStoreRegistry method newPStoreProvider.

@SuppressWarnings("unchecked")
public PersistentStoreProvider newPStoreProvider() throws ExecutionSetupException {
    try {
        String storeProviderClassName = config.getString(ExecConstants.SYS_STORE_PROVIDER_CLASS);
        logger.info("Using the configured PStoreProvider class: '{}'.", storeProviderClassName);
        Class<? extends PersistentStoreProvider> storeProviderClass = (Class<? extends PersistentStoreProvider>) Class.forName(storeProviderClassName);
        Constructor<? extends PersistentStoreProvider> c = storeProviderClass.getConstructor(PersistentStoreRegistry.class);
        return new CachingPersistentStoreProvider(c.newInstance(this));
    } catch (ConfigException.Missing | ClassNotFoundException | NoSuchMethodException | SecurityException | InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
        logger.error(e.getMessage(), e);
        throw new ExecutionSetupException("A System Table provider was either not specified or could not be found or instantiated", e);
    }
}
Also used : ExecutionSetupException(org.apache.drill.common.exceptions.ExecutionSetupException) CachingPersistentStoreProvider(org.apache.drill.exec.store.sys.store.provider.CachingPersistentStoreProvider) InvocationTargetException(java.lang.reflect.InvocationTargetException) CachingPersistentStoreProvider(org.apache.drill.exec.store.sys.store.provider.CachingPersistentStoreProvider)

Example 37 with ExecutionSetupException

use of org.apache.drill.common.exceptions.ExecutionSetupException in project drill by apache.

the class TestScanOperExecBasics method testNoReader.

/**
 * Pathological case that a scan operator is provided no readers.
 * It will throw a user exception because the downstream operators
 * can't handle this case so we choose to stop the show early to
 * avoid getting into a strange state.
 */
@Test
public void testNoReader() {
    // Create the scan operator
    ScanFixture scanFixture = simpleFixture();
    ScanOperatorExec scan = scanFixture.scanOp;
    try {
        scan.buildSchema();
    } catch (UserException e) {
        // Expected
        assertTrue(e.getCause() instanceof ExecutionSetupException);
    }
    // Must close the DAG (context and scan operator) even on failures
    scanFixture.close();
}
Also used : ExecutionSetupException(org.apache.drill.common.exceptions.ExecutionSetupException) ScanFixture(org.apache.drill.exec.physical.impl.scan.ScanTestUtils.ScanFixture) UserException(org.apache.drill.common.exceptions.UserException) Test(org.junit.Test)

Example 38 with ExecutionSetupException

use of org.apache.drill.common.exceptions.ExecutionSetupException in project drill by apache.

the class ParquetRecordReader method setup.

/**
 * Prepare the Parquet reader. First determine the set of columns to read (the schema
 * for this read.) Then, create a state object to track the read across calls to
 * the reader <tt>next()</tt> method. Finally, create one of three readers to
 * read batches depending on whether this scan is for only fixed-width fields,
 * contains at least one variable-width field, or is a "mock" scan consisting
 * only of null fields (fields in the SELECT clause but not in the Parquet file.)
 */
@Override
public void setup(OperatorContext operatorContext, OutputMutator output) throws ExecutionSetupException {
    this.operatorContext = operatorContext;
    ParquetSchema schema = new ParquetSchema(fragmentContext.getOptions(), rowGroupIndex, footer, isStarQuery() ? null : getColumns());
    batchSizerMgr = new RecordBatchSizerManager(fragmentContext.getOptions(), schema, numRecordsToRead, new RecordBatchStatsContext(fragmentContext, operatorContext));
    logger.debug("Reading {} records from row group({}) in file {}.", numRecordsToRead, rowGroupIndex, hadoopPath.toUri().getPath());
    try {
        schema.buildSchema();
        batchSizerMgr.setup();
        readState = new ReadState(schema, batchSizerMgr, parquetReaderStats, numRecordsToRead, useAsyncColReader);
        readState.buildReader(this, output);
    } catch (Exception e) {
        throw handleAndRaise("Failure in setting up reader", e);
    }
    ColumnReader<?> firstColumnStatus = readState.getFirstColumnReader();
    if (firstColumnStatus == null) {
        batchReader = new BatchReader.MockBatchReader(readState);
    } else if (schema.allFieldsFixedLength()) {
        batchReader = new BatchReader.FixedWidthReader(readState);
    } else {
        batchReader = new BatchReader.VariableWidthReader(readState);
    }
}
Also used : RecordBatchSizerManager(org.apache.drill.exec.store.parquet.columnreaders.batchsizing.RecordBatchSizerManager) RecordBatchStatsContext(org.apache.drill.exec.util.record.RecordBatchStats.RecordBatchStatsContext) OutOfMemoryException(org.apache.drill.exec.exception.OutOfMemoryException) ExecutionSetupException(org.apache.drill.common.exceptions.ExecutionSetupException)

Example 39 with ExecutionSetupException

use of org.apache.drill.common.exceptions.ExecutionSetupException in project drill by apache.

the class MockRecordReader method setup.

@Override
public void setup(OperatorContext context, OutputMutator output) throws ExecutionSetupException {
    try {
        final int estimateRowSize = getEstimatedRecordSize(config.getTypes());
        if (config.getTypes() == null) {
            return;
        }
        valueVectors = new ValueVector[config.getTypes().length];
        batchRecordCount = 250000 / estimateRowSize;
        for (int i = 0; i < config.getTypes().length; i++) {
            final MajorType type = config.getTypes()[i].getMajorType();
            final MaterializedField field = getVector(config.getTypes()[i].getName(), type);
            final Class<? extends ValueVector> vvClass = TypeHelper.getValueVectorClass(field.getType().getMinorType(), field.getDataMode());
            valueVectors[i] = output.addField(field, vvClass);
        }
    } catch (SchemaChangeException e) {
        throw new ExecutionSetupException("Failure while setting up fields", e);
    }
}
Also used : ExecutionSetupException(org.apache.drill.common.exceptions.ExecutionSetupException) SchemaChangeException(org.apache.drill.exec.exception.SchemaChangeException) MajorType(org.apache.drill.common.types.TypeProtos.MajorType) MaterializedField(org.apache.drill.exec.record.MaterializedField)

Example 40 with ExecutionSetupException

use of org.apache.drill.common.exceptions.ExecutionSetupException in project drill by apache.

the class ControlMessageHandler method startNewFragment.

/**
 * Start a new fragment on this node. These fragments can be leaf or intermediate fragments
 * which are scheduled by remote or local Foreman node.
 * @param fragment
 * @throws UserRpcException
 */
public void startNewFragment(final PlanFragment fragment, final DrillbitContext drillbitContext) throws UserRpcException {
    logger.debug("Received remote fragment start instruction: {}", fragment);
    try {
        final FragmentContextImpl fragmentContext = new FragmentContextImpl(drillbitContext, fragment, drillbitContext.getFunctionImplementationRegistry());
        final FragmentStatusReporter statusReporter = new FragmentStatusReporter(fragmentContext);
        final FragmentExecutor fragmentExecutor = new FragmentExecutor(fragmentContext, fragment, statusReporter);
        // 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()) {
            bee.addFragmentRunner(fragmentExecutor);
        } else {
            // isIntermediate, store for incoming data.
            final NonRootFragmentManager manager = new NonRootFragmentManager(fragment, fragmentExecutor, statusReporter);
            drillbitContext.getWorkBus().addFragmentManager(manager);
        }
    } catch (final ExecutionSetupException ex) {
        throw new UserRpcException(drillbitContext.getEndpoint(), "Failed to create fragment context", ex);
    } 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 : ExecutionSetupException(org.apache.drill.common.exceptions.ExecutionSetupException) NonRootFragmentManager(org.apache.drill.exec.work.fragment.NonRootFragmentManager) UserRpcException(org.apache.drill.exec.rpc.UserRpcException) FragmentStatusReporter(org.apache.drill.exec.work.fragment.FragmentStatusReporter) FragmentContextImpl(org.apache.drill.exec.ops.FragmentContextImpl) FragmentExecutor(org.apache.drill.exec.work.fragment.FragmentExecutor) UserRpcException(org.apache.drill.exec.rpc.UserRpcException) RpcException(org.apache.drill.exec.rpc.RpcException) ExecutionSetupException(org.apache.drill.common.exceptions.ExecutionSetupException)

Aggregations

ExecutionSetupException (org.apache.drill.common.exceptions.ExecutionSetupException)94 IOException (java.io.IOException)43 ScanBatch (org.apache.drill.exec.physical.impl.ScanBatch)26 SchemaPath (org.apache.drill.common.expression.SchemaPath)25 RecordReader (org.apache.drill.exec.store.RecordReader)24 SchemaChangeException (org.apache.drill.exec.exception.SchemaChangeException)22 LinkedList (java.util.LinkedList)16 Map (java.util.Map)14 MaterializedField (org.apache.drill.exec.record.MaterializedField)13 ExecutionException (java.util.concurrent.ExecutionException)10 DrillRuntimeException (org.apache.drill.common.exceptions.DrillRuntimeException)10 OperatorContext (org.apache.drill.exec.ops.OperatorContext)8 UserException (org.apache.drill.common.exceptions.UserException)7 MajorType (org.apache.drill.common.types.TypeProtos.MajorType)7 JobConf (org.apache.hadoop.mapred.JobConf)7 HashMap (java.util.HashMap)6 List (java.util.List)6 OutOfMemoryException (org.apache.drill.exec.exception.OutOfMemoryException)6 VectorContainerWriter (org.apache.drill.exec.vector.complex.impl.VectorContainerWriter)6 Path (org.apache.hadoop.fs.Path)6