Package org.apache.drill.exec.store
Class PluginHandle
java.lang.Object
org.apache.drill.exec.store.PluginHandle
Represents a storage plugin, defined by a (name, config) pair. The config
implies a connector definition, including a way to create the plugin
instance (
StoragePlugin
. Storage plugins are created lazily to avoid
long Drillbit start times. Plugin creation is synchronized as is closing.
A handle has a type used to determine which operations are allowed on the handle. For example, inrinsic (system) plugins cannot be deleted or disabled.
Caveats
Note that race conditions are still possible:- User 1 submits a query that refers to plugin p. The registry creates an instance of plugin p and returns it. The planner proceeds to use it.
- User 2 disables p, causing its entry to be updated in persistent storage (but not yet in this entry)
- User 3 submits a query that refers to plugin p. The registry notices that the plugin is now disabled, removes it from the plugin list and closes the plugin.
- User 1 suffers a failure when the planner references the now-closed plugin p.
-
Constructor Summary
ConstructorDescriptionPluginHandle
(String name, StoragePluginConfig config, ConnectorHandle connector) PluginHandle
(String name, StoragePluginConfig config, ConnectorHandle connector, org.apache.drill.exec.store.PluginHandle.PluginType type) PluginHandle
(StoragePlugin plugin, ConnectorHandle connector, org.apache.drill.exec.store.PluginHandle.PluginType type) -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Close the plugin.config()
boolean
boolean
boolean
isStored()
name()
plugin()
Retrieve the storage plugin instance, creating it if needed.toString()
transfer
(org.apache.drill.exec.store.PluginHandle.PluginType type) Atomically transfer the plugin instance, if any, to a new handle of the given type.
-
Constructor Details
-
PluginHandle
-
PluginHandle
public PluginHandle(String name, StoragePluginConfig config, ConnectorHandle connector, org.apache.drill.exec.store.PluginHandle.PluginType type) -
PluginHandle
public PluginHandle(StoragePlugin plugin, ConnectorHandle connector, org.apache.drill.exec.store.PluginHandle.PluginType type)
-
-
Method Details
-
name
-
config
-
isStored
public boolean isStored() -
isIntrinsic
public boolean isIntrinsic() -
plugin
Retrieve the storage plugin instance, creating it if needed. Creation can take time if the plugin creates a connection to another system, especially if that system suffers timeouts.- Returns:
- the initialized storage plugin
- Throws:
UserException
- if the storage plugin creation failed due to class errors (unlikely) or external system errors (more likely)
-
hasInstance
public boolean hasInstance() -
close
public void close()Close the plugin. Can occur when the handle is evicted from the loading cache where we must not throw an exception. Also called on shutdown. -
transfer
Atomically transfer the plugin instance, if any, to a new handle of the given type. Avoids race conditions when transferring a plugin from/to ephemeral storage and the plugin cache, since those two caches are not synchronized as a whole. Ensures that only one of the threads in a race condition will transfer the actual plugin instance.By definition, a plugin becomes disabled if it moves to ephemeral, enabled if it moves from ephemeral into stored status.
-
toString
-