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