public interface StoragePluginRegistry extends Iterable<Map.Entry<String,StoragePlugin>>, AutoCloseable
Modifier and Type | Interface and Description |
---|---|
static class |
StoragePluginRegistry.PluginEncodingException
Indicates an error when decoding a plugin from JSON.
|
static class |
StoragePluginRegistry.PluginException |
static class |
StoragePluginRegistry.PluginFilter |
static class |
StoragePluginRegistry.PluginNotFoundException
Indicates the requested plugin was not found.
|
Modifier and Type | Field and Description |
---|---|
static String |
PSTORE_NAME |
Modifier and Type | Method and Description |
---|---|
Set<String> |
availablePlugins()
Returns the set of available plugin names.
|
StoragePluginConfig |
copyConfig(StoragePluginConfig config)
Copy the given storage plugin config so it may be modified.
|
StoragePluginConfig |
copyConfig(String name)
Copy a stored config so that it can be modified.
|
StoragePluginConfig |
decode(String json)
Return a config decoded from JSON.
|
Map<String,StoragePluginConfig> |
enabledConfigs()
Returns a copy of the set of enabled stored plugin configurations.
|
String |
encode(StoragePluginConfig config) |
String |
encode(String name)
Return a config encoded as JSON.
|
StoragePluginConfig |
getDefinedConfig(String name)
Retrieve an available configuration.
|
FormatPlugin |
getFormatPlugin(StoragePluginConfig storageConfig,
FormatPluginConfig formatConfig)
Deprecated.
use
resolveFormat(StoragePluginConfig, FormatPluginConfig, Class)
which provides type safety. Retained for compatibility with older plugins |
FormatPlugin |
getFormatPluginByConfig(StoragePluginConfig storageConfig,
FormatPluginConfig formatConfig)
Get the Format plugin for the FileSystemPlugin associated with the provided
storage config and format config.
|
StoragePlugin |
getPlugin(StoragePluginConfig config)
Deprecated.
use
resolve(StoragePluginConfig, Class) which provides
type safety. Retained for compatibility with older plugins |
StoragePlugin |
getPlugin(String name)
Get a plugin by name.
|
StoragePlugin |
getPluginByConfig(StoragePluginConfig config)
Get a plugin by configuration.
|
SchemaFactory |
getSchemaFactory()
Get the Schema factory associated with this storage plugin registry.
|
StoragePluginConfig |
getStoredConfig(String name)
Return a plugin from persistent storage.
|
void |
init()
Initialize the storage plugin registry.
|
com.fasterxml.jackson.databind.ObjectMapper |
mapper()
Object mapper to read/write the JSON form of a plugin.
|
void |
put(String name,
StoragePluginConfig config)
Store a plugin by name and configuration.
|
void |
putFormatPlugin(String pluginName,
String formatName,
FormatPluginConfig formatConfig)
Safe way to add or remove a format plugin config from a stored file
system configuration.
|
void |
putJson(String name,
String json)
Put a storage plugin config from JSON.
|
void |
remove(String name)
Remove a plugin by name
|
<T extends StoragePlugin> |
resolve(StoragePluginConfig storageConfig,
Class<T> desired) |
<T extends FormatPlugin> |
resolveFormat(StoragePluginConfig storageConfig,
FormatPluginConfig formatConfig,
Class<T> desired)
Resolve a storage plugin given a storage plugin config.
|
void |
setEnabled(String name,
boolean enabled)
Set the plugin to the requested enabled state.
|
Map<String,StoragePluginConfig> |
storedConfigs()
Returns a set of all stored plugin configurations,
directly from the persistent store.
|
Map<String,StoragePluginConfig> |
storedConfigs(StoragePluginRegistry.PluginFilter filter)
Return a possibly-filtered set of plugins from the persistent
store.
|
void |
validatedPut(String name,
StoragePluginConfig config)
Like
put(String, StoragePluginConfig) , but forces instantiation of the
plugin to verify that the configuration is valid at this moment in time. |
forEach, iterator, spliterator
close
static final String PSTORE_NAME
void init()
void put(String name, StoragePluginConfig config) throws StoragePluginRegistry.PluginException
put()
mimics normal runtime operation.name
- The name of the pluginconfig
- The plugin configurationStoragePluginRegistry.PluginException
- if plugin cannot be createdvoid validatedPut(String name, StoragePluginConfig config) throws StoragePluginRegistry.PluginException
put(String, StoragePluginConfig)
, but forces instantiation of the
plugin to verify that the configuration is valid at this moment in time.void setEnabled(String name, boolean enabled) throws StoragePluginRegistry.PluginException
#verifiedPut()
.
Use this method when changing state. Do not obtain the config and change the state directly, doing so will make the plugin config inconsistent with the internal state.
name
- name of the pluginenabled
- true
to enable the plugin, false
to disableStoragePluginRegistry.PluginNotFoundException
- if the plugin is not foundStoragePluginRegistry.PluginException
- if the plugin name is not valid or
if enabling a plugin and the plugin is not validStoragePlugin getPlugin(String name) throws StoragePluginRegistry.PluginException, UserException
name
- The name of the pluginStoragePluginRegistry.PluginException
- if plugin cannot be obtainedUserException
StoragePlugin getPluginByConfig(StoragePluginConfig config) throws StoragePluginRegistry.PluginException
config
- The configuration for the plugin.StoragePluginRegistry.PluginException
- if plugin cannot be obtained@Deprecated StoragePlugin getPlugin(StoragePluginConfig config) throws ExecutionSetupException
resolve(StoragePluginConfig, Class)
which provides
type safety. Retained for compatibility with older pluginsExecutionSetupException
StoragePluginConfig getStoredConfig(String name)
String encode(String name) throws StoragePluginRegistry.PluginException
StoragePluginRegistry.PluginException
- if the plugin is undefinedString encode(StoragePluginConfig config)
StoragePluginConfig decode(String json) throws StoragePluginRegistry.PluginEncodingException
StoragePluginRegistry.PluginEncodingException
- if the JSON is invalidvoid putJson(String name, String json) throws StoragePluginRegistry.PluginException
IOException
- if the JSON is invalidStoragePluginRegistry.PluginException
- if the underlying
validatedPut(String, StoragePluginConfig)
failsStoragePluginConfig copyConfig(String name) throws StoragePluginRegistry.PluginException
Never modify a config stored in the registry! Configs are keyed by name and value; getting a config, then modifying it, will cause the value maps to become out of sync.
name
- name of the storage plugin config to copyStoragePluginRegistry.PluginException
- if the name is undefinedStoragePluginConfig copyConfig(StoragePluginConfig config)
config
- the storage plugin config to copyStoragePluginConfig getDefinedConfig(String name)
void remove(String name) throws StoragePluginRegistry.PluginException
name
- The name of the storage plugin to removeStoragePluginRegistry.PluginException
Map<String,StoragePluginConfig> storedConfigs()
Map<String,StoragePluginConfig> storedConfigs(StoragePluginRegistry.PluginFilter filter)
Map<String,StoragePluginConfig> enabledConfigs()
Set<String> availablePlugins()
void putFormatPlugin(String pluginName, String formatName, FormatPluginConfig formatConfig) throws StoragePluginRegistry.PluginException
pluginName
- name of the file system storage plugin config to
modifyformatName
- name of the format plugin to modifyformatConfig
- if null, removes the plugin, if non-null updates
the format plugin config with this valueStoragePluginRegistry.PluginException
- if the storage plugin is undefined or
is not a file format pluginFormatPlugin getFormatPluginByConfig(StoragePluginConfig storageConfig, FormatPluginConfig formatConfig) throws StoragePluginRegistry.PluginException
storageConfig
- The storage config for the associated FileSystemPluginformatConfig
- The format config for the associated FormatPluginStoragePluginRegistry.PluginException
- if plugin cannot be obtained@Deprecated FormatPlugin getFormatPlugin(StoragePluginConfig storageConfig, FormatPluginConfig formatConfig) throws ExecutionSetupException
resolveFormat(StoragePluginConfig, FormatPluginConfig, Class)
which provides type safety. Retained for compatibility with older pluginsExecutionSetupException
SchemaFactory getSchemaFactory()
com.fasterxml.jackson.databind.ObjectMapper mapper()
<T extends StoragePlugin> T resolve(StoragePluginConfig storageConfig, Class<T> desired)
<T extends FormatPlugin> T resolveFormat(StoragePluginConfig storageConfig, FormatPluginConfig formatConfig, Class<T> desired)
T
- the required type of the pluginstorageConfig
- storage plugin configformatConfig
- format plugin configdesired
- desired target classIllegalStateException
- if the plugin is unknown or of the wrong
format - errors which should never occur in normal operationCopyright © 1970 The Apache Software Foundation. All rights reserved.