Interface TaskStorage


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

    • STATUS_PENDING

      static final String STATUS_PENDING
      The initial status of a task or a host
      See Also:
    • STATUS_SUCCEEDED

      static final String STATUS_SUCCEEDED
      The successful completion status of a task or a host
      See Also:
    • STATUS_FAILED

      static final String STATUS_FAILED
      The completion status of a task or a host is failed
      See Also:
    • STATUS_IN_PROGRESS

      static final String STATUS_IN_PROGRESS
      The status of a task or host is in progress
      See Also:
    • STATUS_PARTIAL_SUCCEEDED

      static final String STATUS_PARTIAL_SUCCEEDED
      The status of a task or host has some successful and failed steps
      See Also:
    • KEY_TRANSFER_CREDENTIALS

      static final String KEY_TRANSFER_CREDENTIALS
      Transfer credentials is a Map<String,String> 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:
    • KEY_ENV_VARS

      static final String KEY_ENV_VARS
      A Map<String,String> of environment variables to be set into the remote session.
      See Also:
    • KEY_POST_TRANSFER_ACTION

      static final String KEY_POST_TRANSFER_ACTION
      The raw postTransferAction string from the request header.
      See Also:
    • KEY_PRE_TRANSFER_ACTION_ARRAY

      static final 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:
    • KEY_POST_TRANSFER_ACTION_ARRAY

      static final 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:
    • KEY_POST_TRANSFER_ACTION_OPTIONS

      static final String KEY_POST_TRANSFER_ACTION_OPTIONS
      The raw postTransferActionOptions string from the request header.
      See Also:
    • KEY_PRE_TRANSFER_ACTION_OPTIONS_ARRAY

      static final 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:
    • KEY_POST_TRANSFER_ACTION_OPTIONS_ARRAY

      static final 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:
    • KEY_CREATION_TIMESTAMP

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

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

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

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

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

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

      static final String KEY_CONTROLLER_HOST
      The hostname (String) of the Collective Controller.
      See Also:
    • KEY_CONTROLLER_PORT

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

      static final String KEY_USER
      The current user (String) of the task.
      See Also:
    • KEY_STATUS

      static final String KEY_STATUS
      The current status (String) of the task.
      See Also:
    • KEY_RECURSIVE_DELETE

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

      static final String KEY_FILE_TO_DELETE
      The absolute location (String) of the file to be deleted.
      See Also:
    • KEY_DELETE_SOURCE

      static final String KEY_DELETE_SOURCE
      Kept for backwards compatibility. Use KEY_NEED_TO_DELETE_UPLOAD_SOURCE.
      See Also:
  • Method Details

    • createTask

      String createTask(String[] hostNames, Map<String,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

      Set<String> getTaskTokens(Set<Map.Entry<String,List<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

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

      String[] getTaskHostNames(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

      Object getTaskPropertyValue(String token, 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

      String getTaskStatus(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

      String getHostStatus(String token, 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(String token, 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

      List<CommandResult> getHostResult(String token, 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(String token, 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(String token, 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(String token, String hostName, 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.