@Validated @Transactional public class AgentJobServiceImpl extends java.lang.Object implements AgentJobService
AgentJobService
.Constructor and Description |
---|
AgentJobServiceImpl(JobPersistenceService jobPersistenceService,
JobResolverService jobResolverService,
AgentFilterService agentFilterService,
io.micrometer.core.instrument.MeterRegistry meterRegistry)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
claimJob(@NotBlank java.lang.String id,
@Valid AgentClientMetadata agentClientMetadata)
Set a job identified by
id to be owned by the agent identified by agentClientMetadata . |
JobSpecification |
dryRunJobSpecificationResolution(@Valid JobRequest jobRequest)
Run the job specification resolution algorithm on the given input but save nothing in the system.
|
JobSpecification |
getJobSpecification(@NotBlank java.lang.String id)
Get a job specification if has been resolved.
|
void |
handshake(@Valid AgentClientMetadata agentClientMetadata)
Shake hands and allow a client or reject it based on the supplied
AgentClientMetadata . |
java.lang.String |
reserveJobId(@Valid JobRequest jobRequest,
@Valid AgentClientMetadata agentClientMetadata)
Reserve a job id and persist job details in the database based on the supplied
JobRequest . |
JobSpecification |
resolveJobSpecification(@NotBlank java.lang.String id)
Resolve the job specification for job identified by the given id.
|
void |
updateJobStatus(@NotBlank java.lang.String id,
JobStatus currentStatus,
JobStatus newStatus,
java.lang.String newStatusMessage)
Update the status of the job identified with
id to be newStatus provided that the current status
of the job matches newStatus . |
public AgentJobServiceImpl(JobPersistenceService jobPersistenceService, JobResolverService jobResolverService, AgentFilterService agentFilterService, io.micrometer.core.instrument.MeterRegistry meterRegistry)
jobPersistenceService
- The persistence service to usejobResolverService
- The specification service to useagentFilterService
- The agent filter service to usemeterRegistry
- The metrics registry to usepublic void handshake(@Valid @Valid AgentClientMetadata agentClientMetadata) throws GenieAgentRejectedException
AgentClientMetadata
.handshake
in interface AgentJobService
agentClientMetadata
- The metadata about the agent starting to run a given jobGenieAgentRejectedException
- If the server rejects the client based on its metadatapublic java.lang.String reserveJobId(@Valid @Valid JobRequest jobRequest, @Valid @Valid AgentClientMetadata agentClientMetadata)
JobRequest
.reserveJobId
in interface AgentJobService
jobRequest
- The job request containing all the metadata needed to reserve a job idagentClientMetadata
- The metadata about the agent driving this job requestpublic JobSpecification resolveJobSpecification(@NotBlank @NotBlank java.lang.String id) throws GenieJobResolutionException
resolveJobSpecification
in interface AgentJobService
id
- The id of the job to resolve the specification for. Must already have a reserved an id in the databaseGenieJobResolutionException
- On error resolving the job given the input parameters and system state@Transactional(readOnly=true) public JobSpecification getJobSpecification(@NotBlank @NotBlank java.lang.String id)
getJobSpecification
in interface AgentJobService
id
- the id of the job to retrieve the specification for@Transactional(readOnly=true) public JobSpecification dryRunJobSpecificationResolution(@Valid @Valid JobRequest jobRequest) throws GenieJobResolutionException
dryRunJobSpecificationResolution
in interface AgentJobService
jobRequest
- The job request containing all the metadata needed to resolve a job specificationGenieJobResolutionException
- On error resolving the job given the input parameters and system statepublic void claimJob(@NotBlank @NotBlank java.lang.String id, @Valid @Valid AgentClientMetadata agentClientMetadata)
id
to be owned by the agent identified by agentClientMetadata
. The
job status in the system will be set to JobStatus.CLAIMED
claimJob
in interface AgentJobService
id
- The id of the job to claim. Must exist in the system.agentClientMetadata
- The metadata about the client claiming the jobpublic void updateJobStatus(@NotBlank @NotBlank java.lang.String id, JobStatus currentStatus, JobStatus newStatus, @Nullable java.lang.String newStatusMessage)
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.updateJobStatus
in interface AgentJobService
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