Class ClassicConnectorLocator
- All Implemented Interfaces:
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.
Plugin Implementations
This class manages plugin implementation classes (AKA "connectors") which must derive fromStoragePlugin. 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:
- Interfaces or abstract classes
- Those that do not have the constructor described above.
- System plugins with the
SystemPluginannotation. - Private test plugins with the
PrivatePluginannotation.
Config Properties
ExecConstants.PRIVATE_CONNECTORS(drill.exec.storage.private_connectors)- An optional list of private plugin class names. Private plugins
are valid instances of
StoragePluginwhich have thePrivatePluginannotation and so are not automatically loaded.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionRead bootstrap storage pluginsExecConstants.BOOTSTRAP_STORAGE_PLUGINS_FILEand format pluginsExecConstants.BOOTSTRAP_FORMAT_PLUGINS_FILEfiles for the first fresh install of Drill.voidclose()Set<Class<? extends StoragePluginConfig>> 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) create(String name, StoragePluginConfig pluginConfig) Creates plugin instance with the givennameand configurationpluginConfig.Classic storage plugins do not provide default configurations.voidinit()Initialize the locator.Enumerate the intrinsic plugins.voidIfupdatedPlugins()returned non-null, then the registry will call this method after successful update of the persistent store.booleanstorable()Identify plugins to be added to an existing system, typically on the first run after an upgrade.
-
Constructor Details
-
ClassicConnectorLocator
-
-
Method Details
-
init
public void init()Description copied from interface:ConnectorLocatorInitialize the locator. Must be called before the locator is used.- Specified by:
initin interfaceConnectorLocator
-
constuctorsFor
public static Map<Class<? extends StoragePluginConfig>,Constructor<? extends StoragePlugin>> constuctorsFor(Class<? extends StoragePlugin> plugin) -
configClasses
Description copied from interface:ConnectorLocatorReturn the set of known storage plugin configuration classes for which the user can create configs. Excludes system plugin configs. Used to map config classes to this locator to create plugin instances.- Specified by:
configClassesin interfaceConnectorLocator- Returns:
- the unuordered set of storage plugin configuration classes available from this locator. Can be null if this locator offers only system plugins
-
get
Classic storage plugins do not provide default configurations.- Specified by:
getin interfaceConnectorLocator- Parameters:
name- the name of a connector class (not the name of a plugin (configuration)- Returns:
- a plugin with default configuration, or null if this locator does not support such plugins
-
intrinsicPlugins
Description copied from interface:ConnectorLocatorEnumerate the intrinsic plugins. An intrinsic plugin is one which takes no configuration and which therefore cannot be disabled, and thus is always available. Example: Drill's system plugins. For an intrinsic plugin, the plugin name is also the name of the configuration.- Specified by:
intrinsicPluginsin interfaceConnectorLocator- Returns:
- map of intrinsic plugins which require no configuration
-
bootstrapPlugins
Read bootstrap storage pluginsExecConstants.BOOTSTRAP_STORAGE_PLUGINS_FILEand format pluginsExecConstants.BOOTSTRAP_FORMAT_PLUGINS_FILEfiles for the first fresh install of Drill.- Specified by:
bootstrapPluginsin interfaceConnectorLocator- Returns:
- bootstrap storage plugins
- Throws:
IOException- if a read error occurs
-
updatedPlugins
Description copied from interface:ConnectorLocatorIdentify plugins to be added to an existing system, typically on the first run after an upgrade.TODO: 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.
- Specified by:
updatedPluginsin interfaceConnectorLocator- Returns:
- the set of plugin configurations to refresh in the persistent store, or null if none to update
-
onUpgrade
public void onUpgrade()Description copied from interface:ConnectorLocatorIfupdatedPlugins()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.- Specified by:
onUpgradein interfaceConnectorLocator
-
create
public StoragePlugin create(String name, StoragePluginConfig pluginConfig) throws ExecutionSetupException Creates plugin instance with the givennameand configurationpluginConfig. The plugin need to be present in a list of available plugins and be enabled in the configuration- Specified by:
createin interfaceConnectorLocator- Parameters:
name- name of the pluginpluginConfig- plugin configuration- Returns:
- plugin client or
nullif plugin is disabled - Throws:
ExecutionSetupException- for all errors
-
storable
public boolean storable()- Specified by:
storablein interfaceConnectorLocator- Returns:
- true if configs for this locator should be persisted, false if these are ad-hoc or otherwise per-run connectors
-
connectorClassFor
public Class<? extends StoragePlugin> connectorClassFor(Class<? extends StoragePluginConfig> configClass) Description copied from interface:ConnectorLocatorGiven a configuration class, return the corresponding connector (plugin) class.- Specified by:
connectorClassForin interfaceConnectorLocator
-
close
public void close()- Specified by:
closein interfaceConnectorLocator
-