java.lang.Object
org.gcube.vremanagement.executor.plugin.Plugin
All Implemented Interfaces:
org.gcube.smartgears.plugins.ServicePlugin, PluginDefinition

public abstract class Plugin extends Object implements PluginDefinition, org.gcube.smartgears.plugins.ServicePlugin
This class represent the contract for a plugin runnable by the executor.
Author:
Luca Frosini (ISTI - CNR)
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
    Property name for plugin description
    static final String
    Property name for plugin group ID
    protected int
    Current iteration number of the plugin execution
    static final String
    Property name for plugin artifact ID (name)
    Interface for reporting execution progress percentage
    static final String
    Suffix for plugin properties files
    protected Properties
    Plugin configuration properties
    protected UUID
    Unique identifier for this plugin execution instance
    static final String
    Property name for plugin version
  • Constructor Summary

    Constructors
    Constructor
    Description
    Default constructor for Plugin.
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns the configuration of the plugin: the content of <name>.yaml in the directory of the plugin (WEB-INF/lib/plugins/<name>/), read by SmartGears when the service starts and given by the Smart Executor at every execution.
    This method is used by executor to retrieve the Plugin human oriented description.
    This method is used by executor to retrieve the Plugin group It will be published on the IS instance created by the executor
    int
     
    This method is used by executor to retrieve the Plugin name It will be published on the IS instance created by the executor
    This method is used by the Executor to get a key-value Map to be published on IS , so a client which want to launch a Plugin only under certain condition can query the IS to obtain its own filtered list.
     
    This method is used by executor to retrieve the plugin version.
    abstract void
    Launch the plugin with the provided input.
    protected abstract void
    This function is used to correctly stop the plugin
    The plugin answers at /plugins/<its name> of the Smart Executor, where it is launched and its executions are read: SmartGears names the requests under that path with the plugin.
    void
    Sets the configuration of the plugin; called by the Smart Executor.
    void
    setIterationNumber(int iterationNumber)
     
    protected void
    Sets the percentage evolution for the current plugin execution.
    void
     
    void
    setUUID(UUID uuid)
     
    void
    Invoke onStop() function to allow the plugin to safely stop the execution

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface org.gcube.smartgears.plugins.ServicePlugin

    authenticated, configure, contexts, documentation
  • Field Details

    • PLUGIN_PROPERTIES_SUFFIX_FILENAME

      public static final String PLUGIN_PROPERTIES_SUFFIX_FILENAME
      Suffix for plugin properties files
      See Also:
    • GROUP_PROPERTY

      public static final String GROUP_PROPERTY
      Property name for plugin group ID
      See Also:
    • NAME_PROPERTY

      public static final String NAME_PROPERTY
      Property name for plugin artifact ID (name)
      See Also:
    • VERSION_PROPERTY

      public static final String VERSION_PROPERTY
      Property name for plugin version
      See Also:
    • DESCRIPTION_PROPERTY

      public static final String DESCRIPTION_PROPERTY
      Property name for plugin description
      See Also:
    • properties

      protected Properties properties
      Plugin configuration properties
    • uuid

      protected UUID uuid
      Unique identifier for this plugin execution instance
    • iterationNumber

      protected int iterationNumber
      Current iteration number of the plugin execution
    • percentageSetter

      protected PercentageSetter percentageSetter
      Interface for reporting execution progress percentage
  • Constructor Details

    • Plugin

      public Plugin()
      Default constructor for Plugin. Initializes the plugin with default settings and percentage setter.
  • Method Details

    • getGroup

      public String getGroup()
      Description copied from interface: PluginDefinition
      This method is used by executor to retrieve the Plugin group It will be published on the IS instance created by the executor
      Specified by:
      getGroup in interface PluginDefinition
      Returns:
      the plugin group.
    • getName

      public String getName()
      Description copied from interface: PluginDefinition
      This method is used by executor to retrieve the Plugin name It will be published on the IS instance created by the executor
      Specified by:
      getName in interface PluginDefinition
      Returns:
      the plugin name.
    • getVersion

      public String getVersion()
      Description copied from interface: PluginDefinition
      This method is used by executor to retrieve the plugin version. It will be published on the IS instance created by the executor
      Specified by:
      getVersion in interface PluginDefinition
      Returns:
      the plugin version.
    • getDescription

      public String getDescription()
      Description copied from interface: PluginDefinition
      This method is used by executor to retrieve the Plugin human oriented description. It will be published on the IS instance created by the executor
      Specified by:
      getDescription in interface PluginDefinition
      Returns:
      the plugin description.
    • getSupportedCapabilities

      public Map<String,String> getSupportedCapabilities()
      Description copied from interface: PluginDefinition
      This method is used by the Executor to get a key-value Map to be published on IS , so a client which want to launch a Plugin only under certain condition can query the IS to obtain its own filtered list.
      Specified by:
      getSupportedCapabilities in interface PluginDefinition
      Returns:
      the Map with the supported capabilities
    • path

      public Optional<String> path()
      The plugin answers at /plugins/<its name> of the Smart Executor, where it is launched and its executions are read: SmartGears names the requests under that path with the plugin.
      Specified by:
      path in interface org.gcube.smartgears.plugins.ServicePlugin
      Returns:
      /plugins/ followed by the name of the plugin
    • setPercentageSetter

      public void setPercentageSetter(PercentageSetter percentageSetter)
      Parameters:
      percentageSetter - the percentageSetter to set
    • setPercentageEvolution

      protected void setPercentageEvolution(Integer integer)
      Sets the percentage evolution for the current plugin execution.
      Parameters:
      integer - the completion percentage (0-100)
    • getConfiguration

      public Map<String,Object> getConfiguration()
      Returns the configuration of the plugin: the content of <name>.yaml in the directory of the plugin (WEB-INF/lib/plugins/<name>/), read by SmartGears when the service starts and given by the Smart Executor at every execution. A plugin never looks for its configuration in the classpath, which the plugins of a node share.
      Returns:
      the configuration, unmodifiable; empty until the Smart Executor gives it
    • setConfiguration

      public void setConfiguration(Map<String,Object> configuration)
      Sets the configuration of the plugin; called by the Smart Executor.
      Parameters:
      configuration - the content of <name>.yaml
    • getUUID

      public UUID getUUID()
      Returns:
      the uuid
    • setUUID

      public void setUUID(UUID uuid)
      Parameters:
      uuid - the uuid to set
    • getIterationNumber

      public int getIterationNumber()
      Returns:
      the Iteration Number
    • setIterationNumber

      public void setIterationNumber(int iterationNumber)
      Parameters:
      iterationNumber - the iterationNumner to set
    • launch

      public abstract void launch(Map<String,Object> inputs) throws Exception
      Launch the plugin with the provided input.
      Parameters:
      inputs - the input parameters for the plugin execution
      Throws:
      Exception - if the launch fails
    • onStop

      protected abstract void onStop() throws Exception
      This function is used to correctly stop the plugin
      Throws:
      Exception - if the stop operation fails
    • stop

      public void stop() throws Exception
      Invoke onStop() function to allow the plugin to safely stop the execution
      Throws:
      Exception - if the stop operation fails