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()
ConnectorLocator
init
in interface ConnectorLocator
public static Map<Class<? extends StoragePluginConfig>,Constructor<? extends StoragePlugin>> constuctorsFor(Class<? extends StoragePlugin> plugin)
public Set<Class<? extends StoragePluginConfig>> configClasses()
ConnectorLocator
configClasses
in interface ConnectorLocator
public StoragePlugin get(String name)
get
in interface ConnectorLocator
name
- the name of a connector class (not the name of
a plugin (configuration)public List<StoragePlugin> intrinsicPlugins()
ConnectorLocator
intrinsicPlugins
in interface ConnectorLocator
public 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 ConnectorLocator
IOException
- if a read error occurspublic StoragePlugins updatedPlugins()
ConnectorLocator
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.
updatedPlugins
in interface ConnectorLocator
public void onUpgrade()
ConnectorLocator
updatedPlugins()
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 ConnectorLocator
public 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 ConnectorLocator
name
- name of the pluginpluginConfig
- plugin configurationnull
if plugin is disabledExecutionSetupException
- for all errorspublic boolean storable()
storable
in interface ConnectorLocator
public Class<? extends StoragePlugin> connectorClassFor(Class<? extends StoragePluginConfig> configClass)
ConnectorLocator
connectorClassFor
in interface ConnectorLocator
public void close()
close
in interface ConnectorLocator
Copyright © 1970 The Apache Software Foundation. All rights reserved.