Search in sources :

Example 26 with StoragePluginConfig

use of org.apache.drill.common.logical.StoragePluginConfig in project drill by apache.

the class StoragePluginStoreImpl method initPluginsSystemTable.

/**
 * <ol>
 *   <li>Initializes persistent store for storage plugins.</li>
 *   <li>Since storage plugins names are case-insensitive in Drill, to ensure backward compatibility,
 *   re-writes those not stored in lower case with lower case names, for duplicates issues warning. </li>
 *   <li>Wraps plugin system table into case insensitive wrapper.</li>
 * </ol>
 *
 * @param context drillbit context
 * @param lpPersistence deserialization mapper provider
 * @return persistent store for storage plugins
 */
private PersistentStore<StoragePluginConfig> initPluginsSystemTable(DrillbitContext context, LogicalPlanPersistence lpPersistence) {
    try {
        PersistentStore<StoragePluginConfig> pluginSystemTable = context.getStoreProvider().getOrCreateStore(PersistentStoreConfig.newJacksonBuilder(lpPersistence.getMapper(), StoragePluginConfig.class).name(StoragePluginRegistryImpl.PSTORE_NAME).build());
        Iterator<Entry<String, StoragePluginConfig>> storedPlugins = pluginSystemTable.getAll();
        while (storedPlugins.hasNext()) {
            Entry<String, StoragePluginConfig> entry = storedPlugins.next();
            String pluginName = entry.getKey();
            if (!pluginName.equals(pluginName.toLowerCase())) {
                logger.debug("Replacing plugin name {} with its lower case equivalent.", pluginName);
                pluginSystemTable.delete(pluginName);
                if (!pluginSystemTable.putIfAbsent(pluginName.toLowerCase(), entry.getValue())) {
                    logger.warn("Duplicated storage plugin name [{}] is found. Duplicate is deleted from persistent storage.", pluginName);
                }
            }
        }
        return new CaseInsensitivePersistentStore<>(pluginSystemTable);
    } catch (StoreException e) {
        throw new DrillRuntimeException("Failure while reading and loading storage plugin configuration.");
    }
}
Also used : Entry(java.util.Map.Entry) CaseInsensitivePersistentStore(org.apache.drill.exec.store.sys.CaseInsensitivePersistentStore) StoragePluginConfig(org.apache.drill.common.logical.StoragePluginConfig) DrillRuntimeException(org.apache.drill.common.exceptions.DrillRuntimeException) StoreException(org.apache.drill.exec.exception.StoreException)

Example 27 with StoragePluginConfig

use of org.apache.drill.common.logical.StoragePluginConfig in project drill by apache.

the class StoragePluginRegistryImpl method upgradeStore.

/**
 * Upgrade an existing persistent plugin config store with
 * updates available from each locator.
 */
private void upgradeStore() {
    StoragePlugins upgraded = new StoragePlugins();
    for (ConnectorLocator locator : locators) {
        StoragePlugins locatorPlugins = locator.updatedPlugins();
        if (upgraded != null) {
            upgraded.putAll(locatorPlugins);
        }
    }
    if (upgraded.isEmpty()) {
        return;
    }
    for (Map.Entry<String, StoragePluginConfig> newPlugin : upgraded) {
        StoragePluginConfig oldPluginConfig = getStoredConfig(newPlugin.getKey());
        if (oldPluginConfig != null) {
            copyPluginStatus(oldPluginConfig, newPlugin.getValue());
        }
        pluginStore.put(newPlugin.getKey(), newPlugin.getValue());
    }
}
Also used : StoragePlugins(org.apache.drill.exec.planner.logical.StoragePlugins) StoragePluginConfig(org.apache.drill.common.logical.StoragePluginConfig) HashMap(java.util.HashMap) Map(java.util.Map) IdentityHashMap(java.util.IdentityHashMap)

Example 28 with StoragePluginConfig

use of org.apache.drill.common.logical.StoragePluginConfig in project drill by apache.

the class StoragePluginRegistryImpl method putFormatPlugin.

@Override
public void putFormatPlugin(String pluginName, String formatName, FormatPluginConfig formatConfig) throws PluginException {
    pluginName = validateName(pluginName);
    formatName = validateName(formatName);
    StoragePluginConfig orig = requireStoredConfig(pluginName);
    if (!(orig instanceof FileSystemConfig)) {
        throw new PluginException("Format plugins can be added only to the file system plugin: " + pluginName);
    }
    FileSystemConfig copy = (FileSystemConfig) copyConfig(orig);
    if (formatConfig == null) {
        copy.getFormats().remove(formatName);
    } else {
        copy.getFormats().put(formatName, formatConfig);
    }
    put(pluginName, copy);
}
Also used : StoragePluginConfig(org.apache.drill.common.logical.StoragePluginConfig) FileSystemConfig(org.apache.drill.exec.store.dfs.FileSystemConfig)

Aggregations

StoragePluginConfig (org.apache.drill.common.logical.StoragePluginConfig)28 Test (org.junit.Test)15 FileSystemConfig (org.apache.drill.exec.store.dfs.FileSystemConfig)12 StoragePlugins (org.apache.drill.exec.planner.logical.StoragePlugins)9 OperatorFixture (org.apache.drill.test.OperatorFixture)6 BaseTest (org.apache.drill.test.BaseTest)5 ClusterFixture (org.apache.drill.test.ClusterFixture)5 ClusterFixtureBuilder (org.apache.drill.test.ClusterFixtureBuilder)5 HashMap (java.util.HashMap)4 JdbcTest (org.apache.drill.categories.JdbcTest)4 LogicalPlan (org.apache.drill.common.logical.LogicalPlan)4 PlanProperties (org.apache.drill.common.logical.PlanProperties)4 Project (org.apache.drill.common.logical.data.Project)4 Scan (org.apache.drill.common.logical.data.Scan)4 Store (org.apache.drill.common.logical.data.Store)4 InfoSchemaStoragePlugin (org.apache.drill.exec.store.ischema.InfoSchemaStoragePlugin)4 IOException (java.io.IOException)3 Map (java.util.Map)3 ExecutionSetupException (org.apache.drill.common.exceptions.ExecutionSetupException)3 PluginException (org.apache.drill.exec.store.StoragePluginRegistry.PluginException)3