Interface TaskStorage


  • public interface TaskStorage
    A storage service that is used by the CollectiveExecutor and can be exploited by other services as well.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String KEY_COMPLETION_TIMESTAMP
      Timestamp (long) for the completion of a task.
      static java.lang.String KEY_CONTROLLER_HOST
      The hostname (String) of the Collective Controller.
      static java.lang.String KEY_CONTROLLER_PORT
      The https port (as a String) of the Collective Controller.
      static java.lang.String KEY_CREATION_TIMESTAMP
      Timestamp (long) for the creation of a task.
      static java.lang.String KEY_DELETE_SOURCE
      Kept for backwards compatibility.
      static java.lang.String KEY_ENV_VARS
      A Map of environment variables to be set into the remote session.
      static java.lang.String KEY_FILE_TO_DELETE
      The absolute location (String) of the file to be deleted.
      static java.lang.String KEY_NEED_TO_DELETE_UPLOAD_SOURCE
      A boolean flag indicating if the upload source needs to be deleted after uploaded.
      static java.lang.String KEY_POST_TRANSFER_ACTION
      The raw postTransferAction string from the request header.
      static java.lang.String KEY_POST_TRANSFER_ACTION_ARRAY
      The postTransferActions array is the array of actions to perform, as specified by the postTransferAction header.
      static java.lang.String KEY_POST_TRANSFER_ACTION_OPTIONS
      The raw postTransferActionOptions string from the request header.
      static java.lang.String KEY_POST_TRANSFER_ACTION_OPTIONS_ARRAY
      The postTransferActionOptions array is the array of action options, as specified by the postTransferActionOption header.
      static java.lang.String KEY_PRE_TRANSFER_ACTION_ARRAY
      The preTransferActions array is the array of actions to perform, as specified by the preTransferAction header.
      static java.lang.String KEY_PRE_TRANSFER_ACTION_OPTIONS_ARRAY
      The preTransferActionOptions array is the array of action options, as specified by the preTransferActionOption header.
      static java.lang.String KEY_RECURSIVE_DELETE
      A boolean flag indicating if the delete operation of the task should be recursive.
      static java.lang.String KEY_STATUS
      The current status (String) of the task.
      static java.lang.String KEY_TRANSFER_CREDENTIALS
      Transfer credentials is a Map with attributes from the CollectiveRegistrationMBean.
      static java.lang.String KEY_UPLOAD_EXPANSION_FILENAME
      The name (String) of the uploaded + expanded archive.
      static java.lang.String KEY_UPLOAD_FROM_FILE
      An absolute location (String) of the source file that will be uploaded.
      static java.lang.String KEY_UPLOAD_TO_DIR
      An absolute location (String) of the target upload directory.
      static java.lang.String KEY_USER
      The current user (String) of the task.
      static java.lang.String STATUS_FAILED
      The completion status of a task or a host is failed
      static java.lang.String STATUS_IN_PROGRESS
      The status of a task or host is in progress
      static java.lang.String STATUS_PARTIAL_SUCCEEDED
      The status of a task or host has some successful and failed steps
      static java.lang.String STATUS_PENDING
      The initial status of a task or a host
      static java.lang.String STATUS_SUCCEEDED
      The successful completion status of a task or a host
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      void addHostResult​(java.lang.String token, java.lang.String hostName, CommandResult commandResult)
      Add a result record to the specified task and host
      java.lang.String createTask​(java.lang.String[] hostNames, java.util.Map<java.lang.String,​java.lang.Object> properties)
      Create a new task in the task storage
      java.util.List<CommandResult> getHostResult​(java.lang.String token, java.lang.String hostName)
      Get a list of CommandResult object from a given task and host
      java.lang.String getHostStatus​(java.lang.String token, java.lang.String hostName)
      Get the overall status of a host.
      java.lang.String[] getTaskHostNames​(java.lang.String token)
      Get all the host names of a given task
      java.util.Set<java.lang.String> getTaskPropertyKeys​(java.lang.String token)
      Get all the property keys of a given task
      java.lang.Object getTaskPropertyValue​(java.lang.String token, java.lang.String key)
      Get the property value of a given task and key
      java.lang.String getTaskStatus​(java.lang.String token)
      Get the overall status of a task.
      java.util.Set<java.lang.String> getTaskTokens​(java.util.Set<java.util.Map.Entry<java.lang.String,​java.util.List<java.lang.String>>> filter)
      Get all task identifiers in the task storage
      void startWorking​(java.lang.String token, java.lang.String hostName)
      Declare the start of work for a given task and host.
      void stopWorking​(java.lang.String token, java.lang.String hostName)
      Signal the completion of the work for a given task and host.
      void stopWorking​(java.lang.String token, java.lang.String hostName, java.lang.String status)
      Signal the completion of the work for a given task and host.
    • Field Detail

      • STATUS_PENDING

        static final java.lang.String STATUS_PENDING
        The initial status of a task or a host
        See Also:
        Constant Field Values
      • STATUS_SUCCEEDED

        static final java.lang.String STATUS_SUCCEEDED
        The successful completion status of a task or a host
        See Also:
        Constant Field Values
      • STATUS_FAILED

        static final java.lang.String STATUS_FAILED
        The completion status of a task or a host is failed
        See Also:
        Constant Field Values
      • STATUS_IN_PROGRESS

        static final java.lang.String STATUS_IN_PROGRESS
        The status of a task or host is in progress
        See Also:
        Constant Field Values
      • STATUS_PARTIAL_SUCCEEDED

        static final java.lang.String STATUS_PARTIAL_SUCCEEDED
        The status of a task or host has some successful and failed steps
        See Also:
        Constant Field Values
      • KEY_TRANSFER_CREDENTIALS

        static final java.lang.String KEY_TRANSFER_CREDENTIALS
        Transfer credentials is a Map with attributes from the CollectiveRegistrationMBean. Only credentials (user name, password, keys) are defined. The host and port attributes are not supported. Value could be null.
        See Also:
        Constant Field Values
      • KEY_ENV_VARS

        static final java.lang.String KEY_ENV_VARS
        A Map of environment variables to be set into the remote session.
        See Also:
        Constant Field Values
      • KEY_POST_TRANSFER_ACTION

        static final java.lang.String KEY_POST_TRANSFER_ACTION
        The raw postTransferAction string from the request header.
        See Also:
        Constant Field Values
      • KEY_PRE_TRANSFER_ACTION_ARRAY

        static final java.lang.String KEY_PRE_TRANSFER_ACTION_ARRAY
        The preTransferActions array is the array of actions to perform, as specified by the preTransferAction header. The array is the already parsed set of actions to perform. Value will be a non-null array, but may be empty.
        See Also:
        Constant Field Values
      • KEY_POST_TRANSFER_ACTION_ARRAY

        static final java.lang.String KEY_POST_TRANSFER_ACTION_ARRAY
        The postTransferActions array is the array of actions to perform, as specified by the postTransferAction header. The array is the already parsed set of actions to perform. Value will be a non-null array, but may be empty.
        See Also:
        Constant Field Values
      • KEY_POST_TRANSFER_ACTION_OPTIONS

        static final java.lang.String KEY_POST_TRANSFER_ACTION_OPTIONS
        The raw postTransferActionOptions string from the request header.
        See Also:
        Constant Field Values
      • KEY_PRE_TRANSFER_ACTION_OPTIONS_ARRAY

        static final java.lang.String KEY_PRE_TRANSFER_ACTION_OPTIONS_ARRAY
        The preTransferActionOptions array is the array of action options, as specified by the preTransferActionOption header. The array is the already parsed set of action options to perform. If there were no options specified, the value will be null. If options are specified, the length will be validated.
        See Also:
        Constant Field Values
      • KEY_POST_TRANSFER_ACTION_OPTIONS_ARRAY

        static final java.lang.String KEY_POST_TRANSFER_ACTION_OPTIONS_ARRAY
        The postTransferActionOptions array is the array of action options, as specified by the postTransferActionOption header. The array is the already parsed set of action options to perform. If there were no options specified, the value will be null. If options are specified, the length will be validated.
        See Also:
        Constant Field Values
      • KEY_CREATION_TIMESTAMP

        static final java.lang.String KEY_CREATION_TIMESTAMP
        Timestamp (long) for the creation of a task.
        See Also:
        Constant Field Values
      • KEY_COMPLETION_TIMESTAMP

        static final java.lang.String KEY_COMPLETION_TIMESTAMP
        Timestamp (long) for the completion of a task.
        See Also:
        Constant Field Values
      • KEY_UPLOAD_FROM_FILE

        static final java.lang.String KEY_UPLOAD_FROM_FILE
        An absolute location (String) of the source file that will be uploaded.
        See Also:
        Constant Field Values
      • KEY_UPLOAD_TO_DIR

        static final java.lang.String KEY_UPLOAD_TO_DIR
        An absolute location (String) of the target upload directory.
        See Also:
        Constant Field Values
      • KEY_NEED_TO_DELETE_UPLOAD_SOURCE

        static final java.lang.String KEY_NEED_TO_DELETE_UPLOAD_SOURCE
        A boolean flag indicating if the upload source needs to be deleted after uploaded.
        See Also:
        Constant Field Values
      • KEY_UPLOAD_EXPANSION_FILENAME

        static final java.lang.String KEY_UPLOAD_EXPANSION_FILENAME
        The name (String) of the uploaded + expanded archive.
        See Also:
        Constant Field Values
      • KEY_CONTROLLER_HOST

        static final java.lang.String KEY_CONTROLLER_HOST
        The hostname (String) of the Collective Controller.
        See Also:
        Constant Field Values
      • KEY_CONTROLLER_PORT

        static final java.lang.String KEY_CONTROLLER_PORT
        The https port (as a String) of the Collective Controller.
        See Also:
        Constant Field Values
      • KEY_USER

        static final java.lang.String KEY_USER
        The current user (String) of the task.
        See Also:
        Constant Field Values
      • KEY_STATUS

        static final java.lang.String KEY_STATUS
        The current status (String) of the task.
        See Also:
        Constant Field Values
      • KEY_RECURSIVE_DELETE

        static final java.lang.String KEY_RECURSIVE_DELETE
        A boolean flag indicating if the delete operation of the task should be recursive.
        See Also:
        Constant Field Values
      • KEY_FILE_TO_DELETE

        static final java.lang.String KEY_FILE_TO_DELETE
        The absolute location (String) of the file to be deleted.
        See Also:
        Constant Field Values
    • Method Detail

      • createTask

        java.lang.String createTask​(java.lang.String[] hostNames,
                                    java.util.Map<java.lang.String,​java.lang.Object> properties)
        Create a new task in the task storage
        Parameters:
        hostNames - An array of host names to run this task on
        properties - Properties of the task
        Returns:
        An unique task identifier in String
      • getTaskTokens

        java.util.Set<java.lang.String> getTaskTokens​(java.util.Set<java.util.Map.Entry<java.lang.String,​java.util.List<java.lang.String>>> filter)
        Get all task identifiers in the task storage
        Parameters:
        filter - A set of filter entries, or null for no filtering.
        Returns:
        A set of task identifiers in String
      • getTaskPropertyKeys

        java.util.Set<java.lang.String> getTaskPropertyKeys​(java.lang.String token)
        Get all the property keys of a given task
        Parameters:
        token - Task identifier
        Returns:
        A set of keys in String
      • getTaskHostNames

        java.lang.String[] getTaskHostNames​(java.lang.String token)
        Get all the host names of a given task
        Parameters:
        token - Task identifier
        Returns:
        An array of host names to run this task on
      • getTaskPropertyValue

        java.lang.Object getTaskPropertyValue​(java.lang.String token,
                                              java.lang.String key)
        Get the property value of a given task and key
        Parameters:
        token - Task identifier
        key - The key of the property
        Returns:
        The value of the property
      • getTaskStatus

        java.lang.String getTaskStatus​(java.lang.String token)
        Get the overall status of a task. A task may be run on many hosts. Each host will have its own overall status. The status of a task represents the overall result of a task.
        Parameters:
        token - Task identifier
        Returns:
        The status in String
      • getHostStatus

        java.lang.String getHostStatus​(java.lang.String token,
                                       java.lang.String hostName)
        Get the overall status of a host. A task may contain more than one step. The status of a host represents the overall status of all steps involved.
        Parameters:
        token - Task identifier
        hostName - Host name
        Returns:
        The status in String
      • addHostResult

        void addHostResult​(java.lang.String token,
                           java.lang.String hostName,
                           CommandResult commandResult)
        Add a result record to the specified task and host
        Parameters:
        token - Task identifier
        hostName - Host name
        commandResult - The CommandResult object which holds the result
      • getHostResult

        java.util.List<CommandResult> getHostResult​(java.lang.String token,
                                                    java.lang.String hostName)
        Get a list of CommandResult object from a given task and host
        Parameters:
        token - Task identifier
        hostName - Host name
        Returns:
        A list of CommandResult object
      • startWorking

        void startWorking​(java.lang.String token,
                          java.lang.String hostName)
        Declare the start of work for a given task and host. This method should be called before adding result for the given task and host. This method will change the status of the host to STATUS_IN_PROGRESS.
        Parameters:
        token - Task identifier
        hostName - Host name
      • stopWorking

        void stopWorking​(java.lang.String token,
                         java.lang.String hostName)
        Signal the completion of the work for a given task and host. This method should be called after adding the last result for the given task and host. This method will change the status of the host to STATUS_SUCCEEDED.
        Parameters:
        token - Task identifier
        hostName - Host name
      • stopWorking

        void stopWorking​(java.lang.String token,
                         java.lang.String hostName,
                         java.lang.String status)
        Signal the completion of the work for a given task and host. This method should be called after adding the last result for the given task and host.
        Parameters:
        token - Task identifier
        hostName - Host name
        status - The completion status of the host. If null is specified, the status will be changed to STATUS_SUCCEEDED.