Interface AgentJobService

All Known Implementing Classes:
AgentJobServiceImpl

@Validated public interface AgentJobService
A Service to collect the logic for implementing calls from the Agent when a job is launched via the CLI.
Since:
4.0.0
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    claimJob(@NotBlank String id, @Valid com.netflix.genie.common.internal.dtos.AgentClientMetadata agentClientMetadata)
    Set a job identified by id to be owned by the agent identified by agentClientMetadata.
    com.netflix.genie.common.internal.dtos.JobSpecification
    dryRunJobSpecificationResolution(@Valid com.netflix.genie.common.internal.dtos.JobRequest jobRequest)
    Run the job specification resolution algorithm on the given input but save nothing in the system.
    getAgentProperties(@Valid com.netflix.genie.common.internal.dtos.AgentClientMetadata agentMetadata)
    Provide configuration properties for an agent that is beginning to execute a job.
    com.netflix.genie.common.internal.dtos.JobSpecification
    Get a job specification if has been resolved.
    com.netflix.genie.common.internal.dtos.JobStatus
    getJobStatus(@NotBlank String id)
    Retrieve the status of the job identified with id.
    void
    handshake(@Valid com.netflix.genie.common.internal.dtos.AgentClientMetadata agentMetadata)
    Shake hands and allow a client or reject it based on the supplied AgentClientMetadata.
    reserveJobId(@Valid com.netflix.genie.common.internal.dtos.JobRequest jobRequest, @Valid com.netflix.genie.common.internal.dtos.AgentClientMetadata agentClientMetadata)
    Reserve a job id and persist job details in the database based on the supplied JobRequest.
    com.netflix.genie.common.internal.dtos.JobSpecification
    Resolve the job specification for job identified by the given id.
    void
    updateJobArchiveStatus(@NotBlank String id, com.netflix.genie.common.internal.dtos.ArchiveStatus newArchiveStatus)
    Update the archive status status of the job identified with id to be newStatus.
    void
    updateJobStatus(@NotBlank String id, com.netflix.genie.common.internal.dtos.JobStatus currentStatus, com.netflix.genie.common.internal.dtos.JobStatus newStatus, String newStatusMessage)
    Update the status of the job identified with id to be newStatus provided that the current status of the job matches newStatus.
  • Method Details

    • handshake

      void handshake(@Valid @Valid com.netflix.genie.common.internal.dtos.AgentClientMetadata agentMetadata)
      Shake hands and allow a client or reject it based on the supplied AgentClientMetadata.
      Parameters:
      agentMetadata - The metadata about the agent starting to run a given job
      Throws:
      com.netflix.genie.common.internal.exceptions.unchecked.GenieAgentRejectedException - If the server rejects the client based on its metadata
      javax.validation.ConstraintViolationException - If the arguments fail validation
    • getAgentProperties

      Map<String,String> getAgentProperties(@Valid @Valid com.netflix.genie.common.internal.dtos.AgentClientMetadata agentMetadata)
      Provide configuration properties for an agent that is beginning to execute a job.
      Parameters:
      agentMetadata - The metadata about the agent starting to run a given job
      Returns:
      a map of properties for the agent
      Throws:
      javax.validation.ConstraintViolationException - If the arguments fail validation
    • reserveJobId

      String reserveJobId(@Valid @Valid com.netflix.genie.common.internal.dtos.JobRequest jobRequest, @Valid @Valid com.netflix.genie.common.internal.dtos.AgentClientMetadata agentClientMetadata)
      Reserve a job id and persist job details in the database based on the supplied JobRequest.
      Parameters:
      jobRequest - The job request containing all the metadata needed to reserve a job id
      agentClientMetadata - The metadata about the agent driving this job request
      Returns:
      The unique id of the job which was saved in the database
      Throws:
      com.netflix.genie.common.internal.exceptions.unchecked.GenieIdAlreadyExistsException - If the id requested along with the job request is already in use
      javax.validation.ConstraintViolationException - If the arguments fail validation
    • resolveJobSpecification

      com.netflix.genie.common.internal.dtos.JobSpecification resolveJobSpecification(@NotBlank @NotBlank String id) throws com.netflix.genie.common.internal.exceptions.checked.GenieJobResolutionException, com.netflix.genie.common.internal.exceptions.unchecked.GenieJobResolutionRuntimeException
      Resolve the job specification for job identified by the given id. This method will persist the job specification details to the database.
      Parameters:
      id - The id of the job to resolve the specification for. Must already have a reserved an id in the database
      Returns:
      The job specification if one could be resolved
      Throws:
      com.netflix.genie.common.internal.exceptions.checked.GenieJobResolutionException - On error resolving the job given the input parameters and system state
      javax.validation.ConstraintViolationException - If the arguments fail validation
      com.netflix.genie.common.internal.exceptions.unchecked.GenieJobResolutionRuntimeException - If job resolution fails due to a runtime error (as opposed to unsatisfiable constraints)
    • getJobSpecification

      com.netflix.genie.common.internal.dtos.JobSpecification getJobSpecification(@NotBlank @NotBlank String id)
      Get a job specification if has been resolved.
      Parameters:
      id - the id of the job to retrieve the specification for
      Returns:
      The job specification for the job
      Throws:
      com.netflix.genie.common.internal.exceptions.unchecked.GenieJobNotFoundException - If the job has not yet had its ID reserved and/or can't be found
      com.netflix.genie.common.internal.exceptions.unchecked.GenieJobSpecificationNotFoundException - If the job exists but the specification hasn't been resolved or saved yet
      javax.validation.ConstraintViolationException - If the arguments fail validation
    • dryRunJobSpecificationResolution

      com.netflix.genie.common.internal.dtos.JobSpecification dryRunJobSpecificationResolution(@Valid @Valid com.netflix.genie.common.internal.dtos.JobRequest jobRequest) throws com.netflix.genie.common.internal.exceptions.checked.GenieJobResolutionException
      Run the job specification resolution algorithm on the given input but save nothing in the system.
      Parameters:
      jobRequest - The job request containing all the metadata needed to resolve a job specification
      Returns:
      The job specification that would have been resolved for the given input
      Throws:
      com.netflix.genie.common.internal.exceptions.checked.GenieJobResolutionException - On error resolving the job given the input parameters and system state
      javax.validation.ConstraintViolationException - If the arguments fail validation
    • claimJob

      void claimJob(@NotBlank @NotBlank String id, @Valid @Valid com.netflix.genie.common.internal.dtos.AgentClientMetadata agentClientMetadata)
      Set a job identified by id to be owned by the agent identified by agentClientMetadata. The job status in the system will be set to JobStatus.CLAIMED
      Parameters:
      id - The id of the job to claim. Must exist in the system.
      agentClientMetadata - The metadata about the client claiming the job
      Throws:
      com.netflix.genie.common.internal.exceptions.unchecked.GenieJobNotFoundException - if no job with the given id exists
      com.netflix.genie.common.internal.exceptions.unchecked.GenieJobAlreadyClaimedException - if the job with the given id already has been claimed
      com.netflix.genie.common.internal.exceptions.unchecked.GenieInvalidStatusException - if the current job status is not JobStatus.RESOLVED
      javax.validation.ConstraintViolationException - If the arguments fail validation
    • updateJobStatus

      void updateJobStatus(@NotBlank @NotBlank String id, com.netflix.genie.common.internal.dtos.JobStatus currentStatus, com.netflix.genie.common.internal.dtos.JobStatus newStatus, @Nullable String newStatusMessage)
      Update the status of the job identified with id to be newStatus provided that the current status of the job matches newStatus. Optionally a status message can be provided to provide more details to users. If the newStatus is JobStatus.RUNNING the start time will be set. If the newStatus is a member of JobStatus.getFinishedStatuses() and the job had a started time set the finished time of the job will be set.
      Parameters:
      id - The id of the job to update status for. Must exist in the system.
      currentStatus - The status the caller to this API thinks the job currently has
      newStatus - The new status the caller would like to update the status to
      newStatusMessage - An optional status message to associate with this change
      Throws:
      com.netflix.genie.common.internal.exceptions.unchecked.GenieJobNotFoundException - if no job with the given id exists
      com.netflix.genie.common.internal.exceptions.unchecked.GenieInvalidStatusException - if the current status of the job identified by id in the system doesn't match the supplied currentStatus. Also if the currentStatus equals the newStatus.
      javax.validation.ConstraintViolationException - If the arguments fail validation
    • getJobStatus

      com.netflix.genie.common.internal.dtos.JobStatus getJobStatus(@NotBlank @NotBlank String id)
      Retrieve the status of the job identified with id.
      Parameters:
      id - The id of the job to look up.
      Returns:
      the current status of the job, as seen by this node
      Throws:
      com.netflix.genie.common.internal.exceptions.unchecked.GenieJobNotFoundException - if no job with the given id exists
      javax.validation.ConstraintViolationException - If the arguments fail validation
    • updateJobArchiveStatus

      void updateJobArchiveStatus(@NotBlank @NotBlank String id, com.netflix.genie.common.internal.dtos.ArchiveStatus newArchiveStatus)
      Update the archive status status of the job identified with id to be newStatus. Notice this is a 'blind write', the currently persisted value will always be overwritten.
      Parameters:
      id - The id of the job to update status for. Must exist in the system.
      newArchiveStatus - The new archive status the caller would like to update the status to
      Throws:
      com.netflix.genie.common.internal.exceptions.unchecked.GenieJobNotFoundException - if no job with the given id exists
      javax.validation.ConstraintViolationException - If the arguments fail validation