-
Notifications
You must be signed in to change notification settings - Fork 129
Design of Commandline utility for plugin management in BDRE
BDRE as it ships currently will be called 'minimal BDRE'. And all feature additions upon it, would be done via plugins. 'minimal BDRE' is itself treated as a plugin. So all the future plugins to be developed will be dependent on minimal BDRE.
Three more metadata tables are to be added to the currently existing tables in BDRE. They are:
This table contains all the plugins that are currently installed. Hence 'minimal BDRE' is an automatic entry in this table.
This table contains the dependency information if any for each of the plugins present in the INSTALLED_PLUGINS table. There can be multiple entries corresponding to a plugin which denotes that a plugin can have multiple dependencies('minimal BDRE' is one of them). Although, dependency_id is unique.
This table contains information pertaining to a plugin. Each plugin is composed of two distinct components
- A plugin descriptor (plugin.json)
- A directory titled 'Files'. This directory contains files ranging from deploy/execution scripts, Java Source Files to JSPs. While installing a plugin, BDRE scans this table to get the information regarding the components of the plugin. For example, if a plugin contains a workflow-designer jsp fragment, a row in this corresponds to the path of this jsp fragment file. So when the workflow-designer pages is rendered, it can exactly know where to locate a particular jsp fragment by looking up this table under the config-group 'wfd-jsp-frag'. One more example would be to load Java classes during run time. So when necessary, the code would fetch the necessary classes to be loaded for a given program, by checking the plugin_config table (eg:workflow-generator has to fetch a new ActionNode class by checking the plugin_config for properties with a config group of 'wgen-action-node'. Each such property contains the class name as key and corresponding jar path as value). The config-group column in the table can take the following values for each plugin for example: 'wfd-jsp-frag','deploy-script','exec-script','action-node','locale-properties','ddls',etc.
{
"plugin-details": {
"plugin-name": "plg-name",
"plugin-version":"x.x.x",
"uninstallable":true
},
"plugin-dependency": {
"dependencies": ["minimal BDRE"]
},
"plugin-config": {
"wfd-jsp-frag": "~/bdre/plugins/md-ui/jsps/views/teradata.jsp",
"deploy-script": "~/bdre/plugins/bdre-scripts/deployment/teradata-deploy-script.sh",
"exec-script": "~/bdre/plugins/+bdre-scripts/execution/teradata-exec-script.sh"
},
"install": {
"fs": [{
"action": "FILECOPY",
"src": "somefile/in/the/plugin/archive",
"dest": "~/bdre/plugins/md-ui/jsps/views/xx",
"chmod": "777",
"replace": true
}, {
"action": "LIBINSTALL",
"src": "somejar/in/the/plugin/archive2",
"dest": "~/bdre/plugins/lib/",
"chmod": "666",
"replace": false
}, {
"action": "SCP",
"src": "somefile/in/the/plugin/archive2/",
"dest": "remote-ip/home/xxuser",
"chmod": "666",
"replace": false
}, {
"action": "FILECOPY",
"src": "somefile/in/the/plugin/archive3",
"dest": "~/bdre/bdre-scripts/execution/",
"chmod": "666",
"replace": false
}],
"metadata": [{
"action": "INSERT",
"tableName": "PROCESS_TYPE",
"data": [
"1,'rec1',0",
"2,'rec2',0"
]
},{
"action": "INSERTORUPDATE",
"tableName": "WORKFLOW_TYPE",
"data": [
"1,'rec1',0",
"2,'rec2',0"
]
}]
},
"uninstall": {}
}
java –cp plugin-loader.jar com.wipro.ats.bdre.plugin.InstallerMain pluginName-pluginVersion.zip plugin-loader.jar contains following classes:
- com.wipro.ats.bdre.plugin.Installer
- com.wipro.ats.bdre.plugin.InstallerMain
- com.wipro.ats.bdre.plugin.UninstallerMain
- com.wipro.ats.bdre.plugin.PluginDescriptor
com.wipro.ats.bdre.plugin.Installer contains the following methods:
-
public boolean installDependencyCheck(PluginDescriptorObject pdObj) This method reads the plugin descriptor object and finds if all the corresponding dependencies are installed already. Returns true if all dependencies are installed and false otherwise.
-
public boolean executeInstall(PluginDescriptorObject pdObj) This method reads the install field of plugin descriptor object and executes the corresponding actions. Returns true if install is successful.
-
public void persistToMetadata(PluginDescriptorObject pdObj) This method reads the plugin descriptor object and parses the information and writes to the database tables INSTALLED_PLUGINS,PLUGIN_DEPENDENCY,PLUGIN_CONFIG
-
public boolean uninstallDependencyCheck(PluginDescriptorObject pdObj) This method reads the plugin descriptor object and finds if any of the corresponding dependencies are installed (entry in INSTALLED_PLUGINS indicates plugin is installed) . Returns false if any of the dependencies are installed and true otherwise.
-
public boolean executeUninstall(String pluginUniqueId) This method reads the uninstall field of plugin descriptor object and executes the corresponding actions. Returns true if uninstall is successful.
-
public boolean resetMetadata(String pluginUniqueId) This method reads the pluginDescriptor object and removes any metadata entries corresponding to the uninstalled plugin in INSTALLED_PLUGINS,PLUGIN_DEPENDENCY,PLUGIN_CONFIG tables.
com.wipro.ats.bdre.plugin.InstallerMain has the following logic:
- Takes path to the plugin zip file as a parameter.
- Extract the zip to ~/bdre/plugins/pluginName-pluginVersion (pluginName-pluginVersion is the plugin-unique-id in INSTALLED_PLUGINS).
- Verify the existence of the plugin-descriptor.json and error out if it doesn't exist.
- Read the content of the json and use jackson/gson api to deserialize it to PluginDescriptor object
- if(installer.installDependencyCheck(pluginDescriptor)){ boolean installSuccess = installer.executeInstall(pluginDescriptor); if(installSuccess) installer.persistToMetadata(pluginDescriptor);}
com.wipro.ats.bdre.plugin.UninstallerMain has the following logic:
- Take the plugin-unique-id as a parameter.
- Verify that the plugin directory exists inside ~/bdre/plugins by checking with the plugin-unique-id as directory name and errors out otherwise.
- Verify the existence of the plugin-descriptor.json and error out if it doesn't exist.
- Read the content of the json and use jackson/gson api to deserialize it to PluginDescriptor object
- if(uninstaller.uninstallDependencyCheck(pluginDescriptor)){ boolean uninstallSuccess = uninstaller.executeUninstall(pluginDescriptor); if(uninstallSuccess) uninstaller.resetMetadata(plugin-unique-id); }