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 TypeMethodDescriptionvoid
claimJob
(@NotBlank String id, @Valid AgentClientMetadata agentClientMetadata) Set a job identified byid
to be owned by the agent identified byagentClientMetadata
.dryRunJobSpecificationResolution
(@Valid JobRequest jobRequest) Run the job specification resolution algorithm on the given input but save nothing in the system.getAgentProperties
(@Valid AgentClientMetadata agentMetadata) Provide configuration properties for an agent that is beginning to execute a job.getJobSpecification
(@NotBlank String id) Get a job specification if has been resolved.getJobStatus
(@NotBlank String id) Retrieve the status of the job identified withid
.void
handshake
(@Valid AgentClientMetadata agentMetadata) Shake hands and allow a client or reject it based on the suppliedAgentClientMetadata
.reserveJobId
(@Valid JobRequest jobRequest, @Valid AgentClientMetadata agentClientMetadata) Reserve a job id and persist job details in the database based on the suppliedJobRequest
.resolveJobSpecification
(@NotBlank String id) Resolve the job specification for job identified by the given id.void
updateJobArchiveStatus
(@NotBlank String id, ArchiveStatus newArchiveStatus) Update the archive status status of the job identified withid
to benewStatus
.void
updateJobStatus
(@NotBlank String id, JobStatus currentStatus, JobStatus newStatus, String newStatusMessage) Update the status of the job identified withid
to benewStatus
provided that the current status of the job matchesnewStatus
.
-
Method Details
-
handshake
Shake hands and allow a client or reject it based on the suppliedAgentClientMetadata
.- Parameters:
agentMetadata
- The metadata about the agent starting to run a given job- Throws:
GenieAgentRejectedException
- If the server rejects the client based on its metadatajavax.validation.ConstraintViolationException
- If the arguments fail validation
-
getAgentProperties
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 JobRequest jobRequest, @Valid @Valid AgentClientMetadata agentClientMetadata) Reserve a job id and persist job details in the database based on the suppliedJobRequest
.- Parameters:
jobRequest
- The job request containing all the metadata needed to reserve a job idagentClientMetadata
- The metadata about the agent driving this job request- Returns:
- The unique id of the job which was saved in the database
- Throws:
GenieIdAlreadyExistsException
- If the id requested along with the job request is already in usejavax.validation.ConstraintViolationException
- If the arguments fail validation
-
resolveJobSpecification
JobSpecification resolveJobSpecification(@NotBlank @NotBlank String id) throws GenieJobResolutionException, 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:
GenieJobResolutionException
- On error resolving the job given the input parameters and system statejavax.validation.ConstraintViolationException
- If the arguments fail validationGenieJobResolutionRuntimeException
- If job resolution fails due to a runtime error (as opposed to unsatisfiable constraints)
-
getJobSpecification
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:
GenieJobNotFoundException
- If the job has not yet had its ID reserved and/or can't be foundGenieJobSpecificationNotFoundException
- If the job exists but the specification hasn't been resolved or saved yetjavax.validation.ConstraintViolationException
- If the arguments fail validation
-
dryRunJobSpecificationResolution
JobSpecification dryRunJobSpecificationResolution(@Valid @Valid JobRequest jobRequest) throws 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:
GenieJobResolutionException
- On error resolving the job given the input parameters and system statejavax.validation.ConstraintViolationException
- If the arguments fail validation
-
claimJob
Set a job identified byid
to be owned by the agent identified byagentClientMetadata
. The job status in the system will be set toJobStatus.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:
GenieJobNotFoundException
- if no job with the givenid
existsGenieJobAlreadyClaimedException
- if the job with the givenid
already has been claimedGenieInvalidStatusException
- if the current job status is notJobStatus.RESOLVED
javax.validation.ConstraintViolationException
- If the arguments fail validation
-
updateJobStatus
void updateJobStatus(@NotBlank @NotBlank String id, JobStatus currentStatus, JobStatus newStatus, @Nullable String newStatusMessage) Update the status of the job identified withid
to benewStatus
provided that the current status of the job matchesnewStatus
. Optionally a status message can be provided to provide more details to users. If thenewStatus
isJobStatus.RUNNING
the start time will be set. If thenewStatus
is a member ofJobStatus.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 hasnewStatus
- The new status the caller would like to update the status tonewStatusMessage
- An optional status message to associate with this change- Throws:
GenieJobNotFoundException
- if no job with the givenid
existsGenieInvalidStatusException
- if the current status of the job identified byid
in the system doesn't match the suppliedcurrentStatus
. Also if thecurrentStatus
equals thenewStatus
.javax.validation.ConstraintViolationException
- If the arguments fail validation
-
getJobStatus
Retrieve the status of the job identified withid
.- Parameters:
id
- The id of the job to look up.- Returns:
- the current status of the job, as seen by this node
- Throws:
GenieJobNotFoundException
- if no job with the givenid
existsjavax.validation.ConstraintViolationException
- If the arguments fail validation
-
updateJobArchiveStatus
Update the archive status status of the job identified withid
to benewStatus
. 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:
GenieJobNotFoundException
- if no job with the givenid
existsjavax.validation.ConstraintViolationException
- If the arguments fail validation
-