Class AbstractFunctionHandler<IN,​OUT>

  • Direct Known Subclasses:
    JsonBasedFunctionHandler

    public abstract class AbstractFunctionHandler<IN,​OUT>
    extends java.lang.Object
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      protected step.functions.io.Output<OUT> delegate​(java.lang.String branchName, java.lang.String functionHandlerClassname, step.functions.io.Input<IN> input)
      Delegate the execution of the function to the AbstractFunctionHandler specified in the arguments in the context of the specified branch
      protected step.functions.io.Output<OUT> delegate​(java.lang.String functionHandlerClassname, step.functions.io.Input<IN> input)
      Delegate the execution of the function to the AbstractFunctionHandler specified in the arguments in the context of the default branch
      protected step.grid.contextbuilder.ApplicationContextBuilder.ApplicationContext getCurrentContext()  
      protected step.grid.contextbuilder.ApplicationContextBuilder.ApplicationContext getCurrentContext​(java.lang.String branch)  
      protected step.grid.filemanager.FileVersionId getFileVersionId​(java.lang.String properyName, java.util.Map<java.lang.String,​java.lang.String> properties)  
      protected FunctionHandlerFactory getFunctionHandlerFactory()  
      abstract java.lang.Class<IN> getInputPayloadClass()  
      abstract java.lang.Class<OUT> getOutputPayloadClass()  
      protected java.util.Map<java.lang.String,​java.lang.String> getProperties()  
      protected step.grid.agent.tokenpool.TokenReservationSession getTokenReservationSession()  
      protected step.grid.agent.tokenpool.TokenSession getTokenSession()  
      protected abstract step.functions.io.Output<OUT> handle​(step.functions.io.Input<IN> input)  
      void initialize()  
      protected java.util.Map<java.lang.String,​java.lang.String> mergeAllProperties​(step.functions.io.Input<?> input)  
      protected void pushLocalApplicationContext​(java.lang.ClassLoader classLoader, java.lang.String resourceName)
      Push a new context based on a local file (jar or zip) to the default branch.
      protected void pushLocalApplicationContext​(java.lang.String branch, java.lang.ClassLoader classLoader, java.lang.String resourceName)
      Push a new context based on a local file (jar or zip) to the branch specified as argument.
      protected void pushLocalFolderApplicationContext​(java.io.File libFolder)
      Push a new context based on a local folder containing a list of jars to the master branch.
      protected void pushLocalFolderApplicationContext​(java.lang.String branch, java.io.File libFolder)
      Push a new context based on a local folder containing a list of jars to the branch specified as argument.
      protected void pushRemoteApplicationContext​(java.lang.String branch, java.lang.String fileId, java.util.Map<java.lang.String,​java.lang.String> properties)
      Push a new remote context to the branch specified as argument.
      protected void pushRemoteApplicationContext​(java.lang.String fileId, java.util.Map<java.lang.String,​java.lang.String> properties)
      Push a new remote context to the default branch.
      protected java.io.File retrieveFileVersion​(java.lang.String properyName, java.util.Map<java.lang.String,​java.lang.String> properties)  
      protected <T> T runInContext​(java.lang.String branch, java.util.concurrent.Callable<T> callable)
      Executes the callable in the current context of the branch specified as argument
      protected <T> T runInContext​(java.util.concurrent.Callable<T> callable)
      Executes the callable using the ClassLoader associated to the current ApplicationContextBuilder.ApplicationContext as context classloader
      protected void setApplicationContextBuilder​(step.grid.contextbuilder.ApplicationContextBuilder applicationContextBuilder)  
      protected void setFileManagerClient​(step.grid.filemanager.FileManagerClient fileManagerClient)  
      protected void setFunctionHandlerFactory​(FunctionHandlerFactory functionHandlerFactory)  
      protected void setProperties​(java.util.Map<java.lang.String,​java.lang.String> properties)  
      protected void setTokenReservationSession​(step.grid.agent.tokenpool.TokenReservationSession tokenReservationSession)  
      protected void setTokenSession​(step.grid.agent.tokenpool.TokenSession tokenSession)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • AbstractFunctionHandler

        public AbstractFunctionHandler()
    • Method Detail

      • setFunctionHandlerFactory

        protected void setFunctionHandlerFactory​(FunctionHandlerFactory functionHandlerFactory)
      • setApplicationContextBuilder

        protected void setApplicationContextBuilder​(step.grid.contextbuilder.ApplicationContextBuilder applicationContextBuilder)
      • setFileManagerClient

        protected void setFileManagerClient​(step.grid.filemanager.FileManagerClient fileManagerClient)
      • setProperties

        protected void setProperties​(java.util.Map<java.lang.String,​java.lang.String> properties)
      • getProperties

        protected java.util.Map<java.lang.String,​java.lang.String> getProperties()
      • getTokenSession

        protected step.grid.agent.tokenpool.TokenSession getTokenSession()
      • setTokenSession

        protected void setTokenSession​(step.grid.agent.tokenpool.TokenSession tokenSession)
      • getTokenReservationSession

        protected step.grid.agent.tokenpool.TokenReservationSession getTokenReservationSession()
      • setTokenReservationSession

        protected void setTokenReservationSession​(step.grid.agent.tokenpool.TokenReservationSession tokenReservationSession)
      • initialize

        public void initialize()
      • getCurrentContext

        protected step.grid.contextbuilder.ApplicationContextBuilder.ApplicationContext getCurrentContext()
        Returns:
        the current ApplicationContextBuilder.ApplicationContext of the default branch
      • getCurrentContext

        protected step.grid.contextbuilder.ApplicationContextBuilder.ApplicationContext getCurrentContext​(java.lang.String branch)
        Parameters:
        branch -
        Returns:
        the current ApplicationContextBuilder.ApplicationContext of the branch specified in the argument
      • runInContext

        protected <T> T runInContext​(java.util.concurrent.Callable<T> callable)
                              throws java.lang.Exception
        Executes the callable using the ClassLoader associated to the current ApplicationContextBuilder.ApplicationContext as context classloader
        Parameters:
        callable - the callable to be executed in the current ApplicationContextBuilder.ApplicationContext
        Returns:
        the result of the callable
        Throws:
        java.lang.Exception
      • runInContext

        protected <T> T runInContext​(java.lang.String branch,
                                     java.util.concurrent.Callable<T> callable)
                              throws java.lang.Exception
        Executes the callable in the current context of the branch specified as argument
        Parameters:
        branch - the name of the branch to be used for execution
        callable - the callable to be executed in the current ApplicationContextBuilder.ApplicationContext
        Returns:
        the result of the callable
        Throws:
        java.lang.Exception
      • pushLocalApplicationContext

        protected void pushLocalApplicationContext​(java.lang.ClassLoader classLoader,
                                                   java.lang.String resourceName)
                                            throws step.grid.contextbuilder.ApplicationContextBuilderException
        Push a new context based on a local file (jar or zip) to the default branch. See ApplicationContextBuilder for details
        Parameters:
        classLoader - the classloader to be used to search the file
        resourceName - the name of the resource to be pushed
        Throws:
        step.grid.contextbuilder.ApplicationContextBuilderException
      • pushLocalApplicationContext

        protected void pushLocalApplicationContext​(java.lang.String branch,
                                                   java.lang.ClassLoader classLoader,
                                                   java.lang.String resourceName)
                                            throws step.grid.contextbuilder.ApplicationContextBuilderException
        Push a new context based on a local file (jar or zip) to the branch specified as argument. See ApplicationContextBuilder for details
        Parameters:
        branch - the name of the branch on which the context has to be pushed
        classLoader - the classloader to be used to search the file
        resourceName - the name of the resource to be pushed
        Throws:
        step.grid.contextbuilder.ApplicationContextBuilderException
      • pushLocalFolderApplicationContext

        protected void pushLocalFolderApplicationContext​(java.io.File libFolder)
                                                  throws step.grid.contextbuilder.ApplicationContextBuilderException
        Push a new context based on a local folder containing a list of jars to the master branch. See ApplicationContextBuilder for details
        Parameters:
        libFolder - the folder containing the jars to be pushed to the context
        Throws:
        step.grid.contextbuilder.ApplicationContextBuilderException
      • pushLocalFolderApplicationContext

        protected void pushLocalFolderApplicationContext​(java.lang.String branch,
                                                         java.io.File libFolder)
                                                  throws step.grid.contextbuilder.ApplicationContextBuilderException
        Push a new context based on a local folder containing a list of jars to the branch specified as argument. See ApplicationContextBuilder for details
        Parameters:
        branch - the name of the branch on which the context has to be pushed
        libFolder - the folder containing the jars to be pushed to the context
        Throws:
        step.grid.contextbuilder.ApplicationContextBuilderException
      • pushRemoteApplicationContext

        protected void pushRemoteApplicationContext​(java.lang.String fileId,
                                                    java.util.Map<java.lang.String,​java.lang.String> properties)
                                             throws step.grid.contextbuilder.ApplicationContextBuilderException
        Push a new remote context to the default branch. See ApplicationContextBuilder for details
        Parameters:
        fileId - the id of the remote file (jar or folder) to be pushed
        properties -
        Throws:
        step.grid.contextbuilder.ApplicationContextBuilderException
      • pushRemoteApplicationContext

        protected void pushRemoteApplicationContext​(java.lang.String branch,
                                                    java.lang.String fileId,
                                                    java.util.Map<java.lang.String,​java.lang.String> properties)
                                             throws step.grid.contextbuilder.ApplicationContextBuilderException
        Push a new remote context to the branch specified as argument. See ApplicationContextBuilder for details
        Parameters:
        branch - the name of the branch on which the context has to be pushed
        fileId - the id of the remote file (jar or folder) to be pushed
        properties -
        Throws:
        step.grid.contextbuilder.ApplicationContextBuilderException
      • delegate

        protected step.functions.io.Output<OUT> delegate​(java.lang.String branchName,
                                                         java.lang.String functionHandlerClassname,
                                                         step.functions.io.Input<IN> input)
                                                  throws java.lang.Exception
        Delegate the execution of the function to the AbstractFunctionHandler specified in the arguments in the context of the specified branch
        Parameters:
        branchName -
        functionHandlerClassname -
        input -
        Returns:
        Throws:
        java.lang.Exception
      • delegate

        protected step.functions.io.Output<OUT> delegate​(java.lang.String functionHandlerClassname,
                                                         step.functions.io.Input<IN> input)
                                                  throws java.lang.Exception
        Delegate the execution of the function to the AbstractFunctionHandler specified in the arguments in the context of the default branch
        Parameters:
        functionHandlerClassname -
        input -
        Returns:
        Throws:
        java.lang.Exception
      • retrieveFileVersion

        protected java.io.File retrieveFileVersion​(java.lang.String properyName,
                                                   java.util.Map<java.lang.String,​java.lang.String> properties)
                                            throws step.grid.filemanager.FileManagerException
        Throws:
        step.grid.filemanager.FileManagerException
      • getFileVersionId

        protected step.grid.filemanager.FileVersionId getFileVersionId​(java.lang.String properyName,
                                                                       java.util.Map<java.lang.String,​java.lang.String> properties)
      • handle

        protected abstract step.functions.io.Output<OUT> handle​(step.functions.io.Input<IN> input)
                                                         throws java.lang.Exception
        Throws:
        java.lang.Exception
      • mergeAllProperties

        protected java.util.Map<java.lang.String,​java.lang.String> mergeAllProperties​(step.functions.io.Input<?> input)
      • getInputPayloadClass

        public abstract java.lang.Class<IN> getInputPayloadClass()
      • getOutputPayloadClass

        public abstract java.lang.Class<OUT> getOutputPayloadClass()