use of org.apache.drill.common.logical.StoragePluginConfig in project drill by axbaretto.
the class StoragePluginRegistryImpl method getPlugin.
@Override
public StoragePlugin getPlugin(String name) throws ExecutionSetupException {
StoragePlugin plugin = plugins.get(name);
if (name.equals(SYS_PLUGIN) || name.equals(INFORMATION_SCHEMA_PLUGIN)) {
return plugin;
}
// since we lazily manage the list of plugins per server, we need to update this once we know that it is time.
StoragePluginConfig config = this.pluginSystemTable.get(name);
if (config == null) {
if (plugin != null) {
plugins.remove(name);
}
return null;
} else {
if (plugin == null || !plugin.getConfig().equals(config) || plugin.getConfig().isEnabled() != config.isEnabled()) {
plugin = createOrUpdate(name, config, false);
}
return plugin;
}
}
use of org.apache.drill.common.logical.StoragePluginConfig in project drill by axbaretto.
the class JdbcDataTest method testProjectFilterSubqueryPlan.
@Test
public void testProjectFilterSubqueryPlan() throws Exception {
LogicalPlan plan = withModel(MODEL, "DONUTS").sql("select d['name'] as name, d['xx'] as xx from (\n" + " select _MAP['donuts'] as d from donuts)\n" + "where cast(d['ppu'] as double) > 0.6").logicalPlan();
PlanProperties planProperties = plan.getProperties();
Assert.assertEquals("optiq", planProperties.generator.type);
Assert.assertEquals("na", planProperties.generator.info);
Assert.assertEquals(1, planProperties.version);
Assert.assertEquals(PlanProperties.PlanType.APACHE_DRILL_LOGICAL, planProperties.type);
Map<String, StoragePluginConfig> seConfigs = plan.getStorageEngines();
StoragePluginConfig config = seConfigs.get("donuts-json");
// Assert.assertTrue(config != null && config instanceof ClasspathRSE.ClasspathRSEConfig);
config = seConfigs.get("queue");
// Assert.assertTrue(config != null && config instanceof QueueRSE.QueueRSEConfig);
Scan scan = findOnlyOperator(plan, Scan.class);
Assert.assertEquals("donuts-json", scan.getStorageEngine());
Filter filter = findOnlyOperator(plan, Filter.class);
Assert.assertTrue(filter.getInput() instanceof Scan);
Project[] projects = Iterables.toArray(findOperator(plan, Project.class), Project.class);
Assert.assertEquals(2, projects.length);
Assert.assertEquals(1, projects[0].getSelections().size());
Assert.assertEquals(Filter.class, projects[0].getInput().getClass());
Assert.assertEquals(2, projects[1].getSelections().size());
Assert.assertEquals(Project.class, projects[1].getInput().getClass());
Store store = findOnlyOperator(plan, Store.class);
Assert.assertEquals("queue", store.getStorageEngine());
Assert.assertEquals("output sink", store.getMemo());
Assert.assertEquals(Project.class, store.getInput().getClass());
}
use of org.apache.drill.common.logical.StoragePluginConfig in project drill by apache.
the class PluginBootstrapLoaderImpl method loadFormatPlugins.
/**
* Loads format plugins from the given URL and adds the formats to the
* specified storage plugins
*
* @param url
* URL to the format plugins bootstrap file
* @param bootstrapPlugins
* a collection with loaded storage plugins. New formats will be
* added to them
* @param pluginURLMap
* a map to store correspondence between storage plugins and
* bootstrap files in which they are defined. Used for logging
* @throws IOException
* if failed to retrieve a plugin from a bootstrap file
*/
private void loadFormatPlugins(URL url, StoragePlugins bootstrapPlugins, Map<String, URL> pluginURLMap) throws IOException {
StoragePlugins plugins = getPluginsFromResource(url);
for (Entry<String, StoragePluginConfig> sourceEntry : plugins) {
String pluginName = sourceEntry.getKey();
StoragePluginConfig sourcePlugin = sourceEntry.getValue();
if (!(sourcePlugin instanceof FileSystemConfig)) {
logger.warn("Formats are only supported by File System plugins. Source name '{}' is of type '{}'.", pluginName, sourcePlugin.getClass().getName());
continue;
}
StoragePluginConfig targetPlugin = bootstrapPlugins.getConfig(pluginName);
if (targetPlugin == null) {
logger.warn("No boostrap storage plugin matches the name '{}'", pluginName);
continue;
}
if (!(targetPlugin instanceof FileSystemConfig)) {
logger.warn("Formats are only supported by File System plugins. Source name '{}' " + "is of type '{}' but the bootstrap plugin of that name is of type '{}.", pluginName, sourcePlugin.getClass().getName(), targetPlugin.getClass().getName());
continue;
}
FileSystemConfig targetFsConfig = (FileSystemConfig) targetPlugin;
FileSystemConfig sourceFsConfig = (FileSystemConfig) sourcePlugin;
sourceFsConfig.getFormats().forEach((formatName, formatValue) -> {
FormatPluginConfig oldPluginConfig = targetFsConfig.getFormats().putIfAbsent(formatName, formatValue);
if (oldPluginConfig != null) {
logger.warn("Duplicate format instance '{}' defined in '{}' and '{}', ignoring the later one.", formatName, pluginURLMap.get(pluginName), url);
}
});
}
}
use of org.apache.drill.common.logical.StoragePluginConfig in project drill by apache.
the class PluginBootstrapLoaderImpl method loadStoragePlugins.
/**
* Loads storage plugins from the given URL
*
* @param url
* URL to the storage plugins bootstrap file
* @param bootstrapPlugins
* a collection where the plugins should be loaded to
* @param pluginURLMap
* a map to store correspondence between storage plugins and
* bootstrap files in which they are defined. Used for logging
* @throws IOException
* if failed to retrieve a plugin from a bootstrap file
*/
private void loadStoragePlugins(URL url, StoragePlugins bootstrapPlugins, Map<String, URL> pluginURLMap) throws IOException {
StoragePlugins plugins = getPluginsFromResource(url);
plugins.forEach(plugin -> {
StoragePluginConfig oldPluginConfig = bootstrapPlugins.putIfAbsent(plugin.getKey(), plugin.getValue());
if (oldPluginConfig != null) {
logger.warn("Duplicate plugin instance '[{}]' defined in [{}, {}], ignoring the later one.", plugin.getKey(), pluginURLMap.get(plugin.getKey()), url);
} else {
pluginURLMap.put(plugin.getKey(), url);
}
});
}
use of org.apache.drill.common.logical.StoragePluginConfig in project drill by apache.
the class StoragePluginRegistryImpl method loadEnabledPlugins.
/**
* Initializes {@link #pluginCache} with currently enabled plugins
* defined in the persistent store.
*
* @return {@code true} if the persistent store contained plugins
* (and thus was initialized, and should perhaps be upgraded), or
* {@code false} if no plugins were found and this this is a new store
* which should be initialized. Avoids the need to check persistent
* store contents twice
*/
private boolean loadEnabledPlugins() {
Iterator<Entry<String, StoragePluginConfig>> allPlugins = pluginStore.load();
int count = 0;
while (allPlugins.hasNext()) {
count++;
Entry<String, StoragePluginConfig> plugin = allPlugins.next();
String name = plugin.getKey();
StoragePluginConfig config = plugin.getValue();
if (!config.isEnabled()) {
continue;
}
try {
pluginCache.put(createPluginEntry(name, config, PluginType.STORED));
} catch (Exception e) {
logger.error("Failure while setting up StoragePlugin with name: '{}', disabling.", name, e);
config.setEnabled(false);
pluginStore.put(name, config);
}
}
// If found at least one entry then this is an existing registry.
return count > 0;
}
Aggregations