Search in sources :

Example 66 with ExecutionSetupException

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

the class StoragePluginRegistryImpl method createPlugins.

@SuppressWarnings("resource")
private Map<String, StoragePlugin> createPlugins() throws DrillbitStartupException {
    try {
        /*
       * Check if the storage plugins system table has any entries. If not, load the boostrap-storage-plugin file into
       * the system table.
       */
        if (!pluginSystemTable.getAll().hasNext()) {
            // bootstrap load the config since no plugins are stored.
            logger.info("No storage plugin instances configured in persistent store, loading bootstrap configuration.");
            Collection<URL> urls = ClassPathScanner.forResource(ExecConstants.BOOTSTRAP_STORAGE_PLUGINS_FILE, false);
            if (urls != null && !urls.isEmpty()) {
                logger.info("Loading the storage plugin configs from URLs {}.", urls);
                Map<String, URL> pluginURLMap = Maps.newHashMap();
                for (URL url : urls) {
                    String pluginsData = Resources.toString(url, Charsets.UTF_8);
                    StoragePlugins plugins = lpPersistence.getMapper().readValue(pluginsData, StoragePlugins.class);
                    for (Map.Entry<String, StoragePluginConfig> config : plugins) {
                        if (!definePluginConfig(config.getKey(), config.getValue())) {
                            logger.warn("Duplicate plugin instance '{}' defined in [{}, {}], ignoring the later one.", config.getKey(), pluginURLMap.get(config.getKey()), url);
                            continue;
                        }
                        pluginURLMap.put(config.getKey(), url);
                    }
                }
            } else {
                throw new IOException("Failure finding " + ExecConstants.BOOTSTRAP_STORAGE_PLUGINS_FILE);
            }
        }
        Map<String, StoragePlugin> activePlugins = new HashMap<String, StoragePlugin>();
        for (Map.Entry<String, StoragePluginConfig> entry : Lists.newArrayList(pluginSystemTable.getAll())) {
            String name = entry.getKey();
            StoragePluginConfig config = entry.getValue();
            if (config.isEnabled()) {
                try {
                    StoragePlugin plugin = create(name, config);
                    activePlugins.put(name, plugin);
                } catch (ExecutionSetupException e) {
                    logger.error("Failure while setting up StoragePlugin with name: '{}', disabling.", name, e);
                    config.setEnabled(false);
                    pluginSystemTable.put(name, config);
                }
            }
        }
        activePlugins.put(INFORMATION_SCHEMA_PLUGIN, new InfoSchemaStoragePlugin(new InfoSchemaConfig(), context, INFORMATION_SCHEMA_PLUGIN));
        activePlugins.put(SYS_PLUGIN, new SystemTablePlugin(SystemTablePluginConfig.INSTANCE, context, SYS_PLUGIN));
        return activePlugins;
    } catch (IOException e) {
        logger.error("Failure setting up storage plugins.  Drillbit exiting.", e);
        throw new IllegalStateException(e);
    }
}
Also used : ExecutionSetupException(org.apache.drill.common.exceptions.ExecutionSetupException) HashMap(java.util.HashMap) SystemTablePlugin(org.apache.drill.exec.store.sys.SystemTablePlugin) IOException(java.io.IOException) URL(java.net.URL) InfoSchemaStoragePlugin(org.apache.drill.exec.store.ischema.InfoSchemaStoragePlugin) StoragePlugins(org.apache.drill.exec.planner.logical.StoragePlugins) StoragePluginConfig(org.apache.drill.common.logical.StoragePluginConfig) InfoSchemaStoragePlugin(org.apache.drill.exec.store.ischema.InfoSchemaStoragePlugin) HashMap(java.util.HashMap) Map(java.util.Map) InfoSchemaConfig(org.apache.drill.exec.store.ischema.InfoSchemaConfig)

Example 67 with ExecutionSetupException

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

the class Foreman method runFragment.

/**
 * This is a helper method to run query based on the list of PlanFragment that were planned
 * at some point of time
 * @param fragmentsList fragment list
 * @throws ExecutionSetupException
 */
private void runFragment(List<PlanFragment> fragmentsList) throws ExecutionSetupException {
    // need to set QueryId, MinorFragment for incoming Fragments
    PlanFragment rootFragment = null;
    boolean isFirst = true;
    final List<PlanFragment> planFragments = Lists.newArrayList();
    for (PlanFragment myFragment : fragmentsList) {
        final FragmentHandle handle = myFragment.getHandle();
        // though we have new field in the FragmentHandle - parentQueryId
        // it can not be used until every piece of code that creates handle is using it, as otherwise
        // comparisons on that handle fail that causes fragment runtime failure
        final FragmentHandle newFragmentHandle = FragmentHandle.newBuilder().setMajorFragmentId(handle.getMajorFragmentId()).setMinorFragmentId(handle.getMinorFragmentId()).setQueryId(queryId).build();
        final PlanFragment newFragment = PlanFragment.newBuilder(myFragment).setHandle(newFragmentHandle).build();
        if (isFirst) {
            rootFragment = newFragment;
            isFirst = false;
        } else {
            planFragments.add(newFragment);
        }
    }
    assert rootFragment != null;
    final FragmentRoot rootOperator;
    try {
        rootOperator = drillbitContext.getPlanReader().readFragmentRoot(rootFragment.getFragmentJson());
    } catch (IOException e) {
        throw new ExecutionSetupException(String.format("Unable to parse FragmentRoot from fragment: %s", rootFragment.getFragmentJson()));
    }
    queryRM.setCost(rootOperator.getCost());
    fragmentsRunner.setFragmentsInfo(planFragments, rootFragment, rootOperator);
    startQueryProcessing();
}
Also used : ExecutionSetupException(org.apache.drill.common.exceptions.ExecutionSetupException) FragmentRoot(org.apache.drill.exec.physical.base.FragmentRoot) FragmentHandle(org.apache.drill.exec.proto.ExecProtos.FragmentHandle) IOException(java.io.IOException) PlanFragment(org.apache.drill.exec.proto.BitControl.PlanFragment)

Example 68 with ExecutionSetupException

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

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
 */
private 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)

Example 69 with ExecutionSetupException

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

the class MongoScanBatchCreator method getBatch.

@Override
public ScanBatch getBatch(ExecutorFragmentContext context, MongoSubScan subScan, List<RecordBatch> children) throws ExecutionSetupException {
    Preconditions.checkArgument(children.isEmpty());
    List<RecordReader> readers = new LinkedList<>();
    List<SchemaPath> columns = null;
    for (MongoSubScan.MongoSubScanSpec scanSpec : subScan.getChunkScanSpecList()) {
        try {
            if ((columns = subScan.getColumns()) == null) {
                columns = GroupScan.ALL_COLUMNS;
            }
            readers.add(new MongoRecordReader(scanSpec, columns, context, subScan.getMongoStoragePlugin()));
        } catch (Exception e) {
            logger.error("MongoRecordReader creation failed for subScan:  " + subScan + ".");
            logger.error(e.getMessage(), e);
            throw new ExecutionSetupException(e);
        }
    }
    logger.info("Number of record readers initialized : " + readers.size());
    return new ScanBatch(subScan, context, readers);
}
Also used : ExecutionSetupException(org.apache.drill.common.exceptions.ExecutionSetupException) SchemaPath(org.apache.drill.common.expression.SchemaPath) RecordReader(org.apache.drill.exec.store.RecordReader) ScanBatch(org.apache.drill.exec.physical.impl.ScanBatch) LinkedList(java.util.LinkedList) ExecutionSetupException(org.apache.drill.common.exceptions.ExecutionSetupException)

Example 70 with ExecutionSetupException

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

the class KuduRecordReader method setup.

@Override
public void setup(OperatorContext context, OutputMutator output) throws ExecutionSetupException {
    this.output = output;
    this.context = context;
    try {
        KuduTable table = client.openTable(scanSpec.getTableName());
        KuduScannerBuilder builder = client.newScannerBuilder(table);
        if (!isStarQuery()) {
            List<String> colNames = Lists.newArrayList();
            for (SchemaPath p : this.getColumns()) {
                colNames.add(p.getRootSegmentPath());
            }
            builder.setProjectedColumnNames(colNames);
        }
        context.getStats().startWait();
        try {
            scanner = builder.lowerBoundRaw(scanSpec.getStartKey()).exclusiveUpperBoundRaw(scanSpec.getEndKey()).build();
        } finally {
            context.getStats().stopWait();
        }
    } catch (Exception e) {
        throw new ExecutionSetupException(e);
    }
}
Also used : ExecutionSetupException(org.apache.drill.common.exceptions.ExecutionSetupException) KuduScannerBuilder(org.apache.kudu.client.KuduScanner.KuduScannerBuilder) SchemaPath(org.apache.drill.common.expression.SchemaPath) KuduTable(org.apache.kudu.client.KuduTable) UserException(org.apache.drill.common.exceptions.UserException) ExecutionSetupException(org.apache.drill.common.exceptions.ExecutionSetupException) SchemaChangeException(org.apache.drill.exec.exception.SchemaChangeException)

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