public class ClassicConnectorLocator extends Object implements ConnectorLocator
StoragePlugin. The connector and its configuration class must
reside in Drill's default class loader.
Handles "classic" storage plugin classes which ship with Drill, or are added to Drill's class path.
The plugin registry supports access from multiple threads concurrently.
This locator is therefore immutable after the init() call.
The set of plugin instances and configurations (managed by the registry)
changes during a run, but the set of known plugin classes is fixed.
We sometimes need to add special plugins for testing. Since we cannot add them on the fly, we must add them at (test) startup time via config properties.
StoragePlugin. Each must be configured
via a class derived from StoragePluginConfig. No two connectors
can share a configuration class. Each connector must have exactly one
associated configuration. (Actually, a single connector might handle
multiple configurations, but that seems an obscure use case.)
The constructor of the connector associates the two classes, and must be of the form:
public SomePlugin(SomePluginConfig config,
DrillbitContext context,
String pluginName) {
Classes must be on the class path. Drill often caches the class path:
creating it at build time, then storing it in a file, to be read at
run time. If you are developing a plugin in an IDE, and this class
refuses to find the plugin, you can temporarly force a runtime
class path scan via setting the
ClassPathScanner.IMPLEMENTATIONS_SCAN_CACHE config property
to false. The various test "fixtures" provide an easy way
to set config properties per-test.
This locator ignores four categories of StoragePluginConfig
classes:
SystemPlugin annotation.PrivatePlugin
annotation.ExecConstants.PRIVATE_CONNECTORS
(drill.exec.storage.private_connectors)StoragePlugin which have the
PrivatePlugin annotation and so are not automatically
loaded.| Constructor and Description |
|---|
ClassicConnectorLocator(PluginRegistryContext context) |
| Modifier and Type | Method and Description |
|---|---|
StoragePlugins |
bootstrapPlugins()
Read bootstrap storage plugins
ExecConstants.BOOTSTRAP_STORAGE_PLUGINS_FILE and format plugins
ExecConstants.BOOTSTRAP_FORMAT_PLUGINS_FILE files for the first
fresh install of Drill. |
void |
close() |
Set<Class<? extends StoragePluginConfig>> |
configClasses()
Return the set of known storage plugin configuration classes for which
the user can create configs.
|
Class<? extends StoragePlugin> |
connectorClassFor(Class<? extends StoragePluginConfig> configClass)
Given a configuration class, return the corresponding connector
(plugin) class.
|
static Map<Class<? extends StoragePluginConfig>,Constructor<? extends StoragePlugin>> |
constuctorsFor(Class<? extends StoragePlugin> plugin) |
StoragePlugin |
create(String name,
StoragePluginConfig pluginConfig)
Creates plugin instance with the given
name and configuration pluginConfig. |
StoragePlugin |
get(String name)
Classic storage plugins do not provide default configurations.
|
void |
init()
Initialize the locator.
|
List<StoragePlugin> |
intrinsicPlugins()
Enumerate the intrinsic plugins.
|
void |
onUpgrade()
If
updatedPlugins() returned non-null, then the
registry will call this method after successful update of
the persistent store. |
boolean |
storable() |
StoragePlugins |
updatedPlugins()
Identify plugins to be added to an existing system, typically
on the first run after an upgrade.
|
public ClassicConnectorLocator(PluginRegistryContext context)
public void init()
ConnectorLocatorinit in interface ConnectorLocatorpublic static Map<Class<? extends StoragePluginConfig>,Constructor<? extends StoragePlugin>> constuctorsFor(Class<? extends StoragePlugin> plugin)
public Set<Class<? extends StoragePluginConfig>> configClasses()
ConnectorLocatorconfigClasses in interface ConnectorLocatorpublic StoragePlugin get(String name)
get in interface ConnectorLocatorname - the name of a connector class (not the name of
a plugin (configuration)public List<StoragePlugin> intrinsicPlugins()
ConnectorLocatorintrinsicPlugins in interface ConnectorLocatorpublic StoragePlugins bootstrapPlugins() throws IOException
ExecConstants.BOOTSTRAP_STORAGE_PLUGINS_FILE and format plugins
ExecConstants.BOOTSTRAP_FORMAT_PLUGINS_FILE files for the first
fresh install of Drill.bootstrapPlugins in interface ConnectorLocatorlpPersistence - deserialization mapper providerIOException - if a read error occurspublic StoragePlugins updatedPlugins()
ConnectorLocatorTODO: The current mechanism depends on deleting a file after the first run, which is unreliable. It won't, for example, correctly handle a restored ZK. A better mechanism would store a version number in the persistent store, and pass that version number into this method.
updatedPlugins in interface ConnectorLocatorpublic void onUpgrade()
ConnectorLocatorupdatedPlugins() returned non-null, then the
registry will call this method after successful update of
the persistent store. This method can do any post-update
cleanup, such as deleting the file mentioned above.onUpgrade in interface ConnectorLocatorpublic StoragePlugin create(String name, StoragePluginConfig pluginConfig) throws ExecutionSetupException
name and configuration pluginConfig.
The plugin need to be present in a list of available plugins and be enabled in the configurationcreate in interface ConnectorLocatorname - name of the pluginpluginConfig - plugin configurationnull if plugin is disabledExecutionSetupException - for all errorspublic boolean storable()
storable in interface ConnectorLocatorpublic Class<? extends StoragePlugin> connectorClassFor(Class<? extends StoragePluginConfig> configClass)
ConnectorLocatorconnectorClassFor in interface ConnectorLocatorpublic void close()
close in interface ConnectorLocatorCopyright © 2021 The Apache Software Foundation. All rights reserved.