Interface AgentJobService


  • @Validated
    public interface AgentJobService
    Agent side job specification service for resolving and retrieving job specifications from the server.
    Since:
    4.0.0
    • Method Detail

      • handshake

        void handshake​(@Valid
                       @Valid AgentClientMetadata agentClientMetadata)
                throws HandshakeException
        Perform server handshake. Before going any further, ensure the server is reachable and that this agent is compatible with it.
        Parameters:
        agentClientMetadata - metadata about the client making this request
        Throws:
        HandshakeException - if the server rejects this client
      • configure

        java.util.Map<java.lang.String,​java.lang.String> configure​(@Valid
                                                                         @Valid AgentClientMetadata agentClientMetadata)
                                                                  throws ConfigureException
        Obtain server-provided configuration properties.
        Parameters:
        agentClientMetadata - metadata about the client making this request
        Returns:
        a map of properties
        Throws:
        ConfigureException - if the server properties cannot be obtained
      • reserveJobId

        java.lang.String reserveJobId​(@Valid
                                      @Valid AgentJobRequest jobRequest,
                                      @Valid
                                      @Valid AgentClientMetadata agentClientMetadata)
                               throws JobReservationException,
                                      JobIdUnavailableException
        Request a given job id to be reserved for this job, send along the job details, to be persisted by the server. The request may or may not contain a job id.
        Parameters:
        jobRequest - the job parameters and agent metadata
        agentClientMetadata - metadata about the client making this request
        Returns:
        the job id assigned by the server (matches the one in the request, if one was present)
        Throws:
        JobReservationException - if the server failed to fulfill this request
        JobIdUnavailableException - if the id requested has already been used
      • resolveJobSpecification

        JobSpecification resolveJobSpecification​(@NotBlank
                                                 @NotBlank java.lang.String id)
                                          throws JobSpecificationResolutionException
        Given the parameters supplied by the job request attempt to resolve a job specification on the server.
        Parameters:
        id - The id of the job to resolve a job specification for
        Returns:
        The job specification
        Throws:
        JobSpecificationResolutionException - if the specification cannot be resolved
      • claimJob

        void claimJob​(@NotBlank
                      @NotBlank java.lang.String jobId,
                      @Valid
                      @Valid AgentClientMetadata agentClientMetadata)
               throws JobReservationException
        Claim a given job, telling the server that this agent is about to begin execution.
        Parameters:
        jobId - the id of the job
        agentClientMetadata - metadata for the agent claiming this job
        Throws:
        JobReservationException - When the the claim request fails is invalid (reasons include: job already claimed, invalid job ID, failure to reach the server
      • changeJobStatus

        void changeJobStatus​(@NotBlank
                             @NotBlank java.lang.String jobId,
                             JobStatus currentJobStatus,
                             JobStatus newJobStatus,
                             java.lang.String message)
                      throws ChangeJobStatusException
        Notify the server of a change of job status.
        Parameters:
        jobId - the id of the job
        currentJobStatus - the expected current status of the job
        newJobStatus - the new status of the job
        message - an optional message tha accompanies this change of status
        Throws:
        ChangeJobStatusException - when the agent fails to update the job status
      • getJobStatus

        JobStatus getJobStatus​(@NotBlank
                               @NotBlank java.lang.String jobId)
                        throws GetJobStatusException
        Retrieve the current job status for the given job id.
        Parameters:
        jobId - the id of the job
        Returns:
        the job status seen by the server
        Throws:
        GetJobStatusException - when the agent fails to retrieve the job status
      • changeJobArchiveStatus

        void changeJobArchiveStatus​(@NotBlank
                                    @NotBlank java.lang.String jobId,
                                    ArchiveStatus archiveStatus)
                             throws ChangeJobArchiveStatusException
        Notify the server of a change of job files archive status.
        Parameters:
        jobId - the id of the job
        archiveStatus - the new archive status of the job
        Throws:
        ChangeJobArchiveStatusException - when the agent fails to update the job archive status