Interface PersistenceService
- All Known Implementing Classes:
JpaPersistenceServiceImpl
@Validated
public interface PersistenceService
Service API for all Genie persistence related operations.
- Since:
- 4.0.0
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addApplicationsForCommand
(@NotBlank String id, @NotEmpty List<@NotBlank String> applicationIds) Add applications for the command.void
addClusterCriterionForCommand
(String id, @Valid Criterion criterion) Add a newCriterion
to the existing list of cluster criteria for the command identified by id.void
addClusterCriterionForCommand
(String id, @Valid Criterion criterion, @jakarta.validation.constraints.Min(0L) int priority) Add a newCriterion
to the existing list of cluster criteria for the command identified by id.<R extends CommonResource>
voidaddConfigsToResource
(@NotBlank String id, Set<@Size(max=1024) String> configs, Class<R> resourceClass) Add configuration files to the existing set for a resource.<R extends CommonResource>
voidaddDependenciesToResource
(@NotBlank String id, Set<@Size(max=1024) String> dependencies, Class<R> resourceClass) Add dependency files to the existing set for a resource.<R extends CommonResource>
voidaddTagsToResource
(@NotBlank String id, Set<@Size(max=255) String> tags, Class<R> resourceClass) Add tags to the existing set for a resource.void
claimJob
(@NotBlank String id, @Valid AgentClientMetadata agentClientMetadata) Set a job identified byid
to be owned by the agent identified byagentClientMetadata
.void
Delete all applications from the system.void
Delete all clusters from database.void
Delete all commands from the system.void
deleteApplication
(@NotBlank String id) Delete anApplication
from the system.void
deleteCluster
(@NotBlank String id) Delete aCluster
by id.void
deleteCommand
(@NotBlank String id) Delete aCommand
from system.long
deleteJobsCreatedBefore
(@NotNull Instant creationThreshold, @NotNull Set<JobStatus> excludeStatuses, @jakarta.validation.constraints.Min(1L) int batchSize) This method will delete a chunk of jobs whose creation time is earlier than the given date.long
deleteUnusedApplications
(@NotNull Instant createdThreshold, @jakarta.validation.constraints.Min(1L) int batchSize) Delete any unused applications that were created before the given time.long
deleteUnusedClusters
(Set<ClusterStatus> deleteStatuses, @NotNull Instant clusterCreatedThreshold, @jakarta.validation.constraints.Min(1L) int batchSize) Delete all clusters that are in one of the given states, aren't attached to any jobs and were created before the given time.long
deleteUnusedCommands
(Set<CommandStatus> deleteStatuses, @NotNull Instant commandCreatedThreshold, @jakarta.validation.constraints.Min(1L) int batchSize) Bulk delete commands from the database where their status is in deleteStatuses they were created before commandCreatedThreshold and they aren't attached to any jobs still in the database.long
deleteUnusedFiles
(@NotNull Instant createdThresholdLowerBound, @NotNull Instant createdThresholdUpperBound, @jakarta.validation.constraints.Min(1L) int batchSize) Delete all files from the database that aren't referenced which were created between the supplied threshold bounds.long
deleteUnusedTags
(@NotNull Instant createdThresholdLowerBound, @NotNull Instant createdThresholdUpperBound, @jakarta.validation.constraints.Min(1L) int batchSize) Delete all tags from the database that aren't referenced which were created between the supplied threshold bounds.org.springframework.data.domain.Page<Application>
findApplications
(String name, String user, Set<ApplicationStatus> statuses, Set<String> tags, String type, org.springframework.data.domain.Pageable page) Find applications which match the given filter criteria.org.springframework.data.domain.Page<Cluster>
findClusters
(String name, Set<ClusterStatus> statuses, Set<String> tags, Instant minUpdateTime, Instant maxUpdateTime, org.springframework.data.domain.Pageable page) Find andCluster
s that match the given parameters.findClustersMatchingAnyCriterion
(@NotEmpty Set<@Valid Criterion> criteria, boolean addDefaultStatus) findClustersMatchingCriterion
(@Valid Criterion criterion, boolean addDefaultStatus) org.springframework.data.domain.Page<Command>
findCommands
(String name, String user, Set<CommandStatus> statuses, Set<String> tags, org.springframework.data.domain.Pageable page) Find commands matching the given filter criteria.findCommandsMatchingCriterion
(@Valid Criterion criterion, boolean addDefaultStatus) org.springframework.data.domain.Page<JobSearchResult>
findJobs
(String id, String name, String user, Set<JobStatus> statuses, Set<String> tags, String clusterName, String clusterId, String commandName, String commandId, Instant minStarted, Instant maxStarted, Instant minFinished, Instant maxFinished, String grouping, String groupingInstance, @NotNull org.springframework.data.domain.Pageable page) Find jobs which match the given filter criteria.long
getActiveJobCountForUser
(@NotBlank String user) Get the count of 'active' jobs for a given user across all instances.Get the set of active jobs.getApplication
(@NotBlank String id) Get the application metadata for given id.Get the applications for a given command.getCluster
(@NotBlank String id) Get theCluster
identified by the given id.For the given command id return the ClusterCriterion
in priority order that is currently associated with this command if any.getClustersForCommand
(@NotBlank String id, Set<ClusterStatus> statuses) Get all the clusters the command with given id is associated with.getCommand
(@NotBlank String id) Get the metadata for theCommand
identified by the id.getCommandsForApplication
(@NotBlank String id, Set<CommandStatus> statuses) Get all the commands the application with given id is associated with.<R extends CommonResource>
Set<String>getConfigsForResource
(@NotBlank String id, Class<R> resourceClass) Get the set of configuration files associated with the resource with the given id.<R extends CommonResource>
Set<String>getDependenciesForResource
(@NotBlank String id, Class<R> resourceClass) Get the set of dependency files associated with the resource with the given id.getFinishedJob
(@NotBlank String id) Get a DTO representing a finished job.getHostJobInformation
(@NotBlank String hostname) Get all the aggregate metadata information about jobs running on a given hostname.Get job information for given job id.getJobApplications
(@NotBlank String id) Get the applications the job used or is currently using.getJobArchiveLocation
(@NotBlank String id) Get the location a job directory was archived to if at all.getJobArchiveStatus
(@NotBlank String id) Get the archive status for a job with the givenid
.getJobCluster
(@NotBlank String id) Get the cluster the job used or is using.getJobCommand
(@NotBlank String id) Get the command the job used or is using.getJobExecution
(@NotBlank String id) Get job execution for given job id.getJobMetadata
(@NotBlank String id) Get the metadata about a job.getJobRequest
(@NotBlank String id) Get the original request for a job.getJobSpecification
(@NotBlank String id) Get the saved job specification for the given job.getJobStatus
(@NotBlank String id) Get the status for a job with the givenid
.getJobsWithStatusAndArchiveStatusUpdatedBefore
(@NotEmpty Set<JobStatus> statuses, @NotEmpty Set<ArchiveStatus> archiveStatuses, @NotNull Instant updated) Get the set of jobs (agent only) whose state is instatuses
and archive status is inarchiveStatuses
and last updated beforeupdated
.com.fasterxml.jackson.databind.JsonNode
getLauncherExt
(@NotBlank String id) Get the job requested launcher extension.com.fasterxml.jackson.databind.JsonNode
getRequestedLauncherExt
(@NotBlank String id) Get the command the job used or is using.<R extends CommonResource>
Set<String>getTagsForResource
(@NotBlank String id, Class<R> resourceClass) Get the set of tags associated with the resource with the given id.Get the set of jobs in that have not reached CLAIMED state.long
getUsedMemoryOnHost
(@NotBlank String hostname) Get the amount of memory currently used on the given host by Genie jobs in any of the following states.getUserResourcesSummaries
(Set<JobStatus> statuses, boolean api) Get a map of summaries of resources usage for each user with at least one active job.boolean
Get whether the job with the given ID was submitted via the REST API or other mechanism.void
Remove all theCriterion
currently associated with the command identified by id.<R extends CommonResource>
voidremoveAllConfigsForResource
(@NotBlank String id, Class<R> resourceClass) Remove all configuration files from the resource.<R extends CommonResource>
voidremoveAllDependenciesForResource
(@NotBlank String id, Class<R> resourceClass) Remove all dependency files from the resource.<R extends CommonResource>
voidremoveAllTagsForResource
(@NotBlank String id, Class<R> resourceClass) Remove all tags from the resource.void
removeApplicationForCommand
(@NotBlank String id, @NotBlank String appId) Remove the application from the command.void
removeApplicationsForCommand
(@NotBlank String id) Remove all the applications from the command.void
removeClusterCriterionForCommand
(String id, @jakarta.validation.constraints.Min(0L) int priority) Remove theCriterion
with the given priority from the current list of cluster criteria associated with the command identified by id.<R extends CommonResource>
voidremoveConfigForResource
(@NotBlank String id, @NotBlank String config, Class<R> resourceClass) Remove a configuration file from the given resource.<R extends CommonResource>
voidremoveDependencyForResource
(@NotBlank String id, @NotBlank String dependency, Class<R> resourceClass) Remove a dependency file from the given resource.<R extends CommonResource>
voidremoveTagForResource
(@NotBlank String id, @NotBlank String tag, Class<R> resourceClass) Remove a tag from the given resource.saveApplication
(@Valid ApplicationRequest applicationRequest) Save a new application.saveCluster
(@Valid ClusterRequest clusterRequest) Save aCluster
.saveCommand
(@Valid CommandRequest commandRequest) Save aCommand
in the system based on the givenCommandRequest
.saveJobSubmission
(@Valid JobSubmission jobSubmission) Save the given job submission information in the underlying data store.void
saveResolvedJob
(@NotBlank String id, @Valid ResolvedJob resolvedJob) Save the given resolved details for a job.void
setApplicationsForCommand
(@NotBlank String id, @NotNull List<@NotBlank String> applicationIds) Set the applications for the command.void
setClusterCriteriaForCommand
(String id, List<@Valid Criterion> clusterCriteria) For the command identified by id reset the entire list of cluster criteria to match the contents of clusterCriteria.void
updateApplication
(@NotBlank String id, @Valid Application updateApp) Update anApplication
.void
updateCluster
(@NotBlank String id, @Valid Cluster updateCluster) Update aCluster
with the given information.void
updateCommand
(@NotBlank String id, @Valid Command updateCommand) Update aCommand
.<R extends CommonResource>
voidupdateConfigsForResource
(@NotBlank String id, Set<@Size(max=1024) String> configs, Class<R> resourceClass) Update the set of configuration files associated with the resource with the given id.<R extends CommonResource>
voidupdateDependenciesForResource
(@NotBlank String id, Set<@Size(max=1024) String> dependencies, Class<R> resourceClass) Update the set of dependency files associated with the resource with the given id.void
updateJobArchiveStatus
(@NotBlank(message="No job id entered. Unable to update.") String id, @NotNull(message="Status cannot be null.") ArchiveStatus archiveStatus) Update the status and status message of the job.updateJobStatus
(@NotBlank String id, @NotNull JobStatus currentStatus, @NotNull JobStatus newStatus, String newStatusMessage) Update the status of the job identified withid
to benewStatus
provided that the current status of the job matchesnewStatus
.void
updateLauncherExt
(@NotBlank(message="No job id entered. Unable to update.") String id, @NotNull(message="Status cannot be null.") com.fasterxml.jackson.databind.JsonNode launcherExtension) Update the launcher extension field for this job.void
updateRequestedLauncherExt
(@NotBlank(message="No job id entered. Unable to update.") String id, @NotNull(message="Status cannot be null.") com.fasterxml.jackson.databind.JsonNode launcherExtension) Update the requested launcher extension field for this job.int
updateStatusForUnusedCommands
(CommandStatus desiredStatus, Instant commandCreatedThreshold, Set<CommandStatus> currentStatuses, int batchSize) Update the status of a command to the desiredStatus if its status is in currentStatuses, it was created before commandCreatedThreshold and it hasn't been used in any job.<R extends CommonResource>
voidupdateTagsForResource
(@NotBlank String id, Set<@Size(max=255) String> tags, Class<R> resourceClass) Update the set of tags associated with the resource with the given id.
-
Method Details
-
saveApplication
String saveApplication(@Valid @Valid ApplicationRequest applicationRequest) throws IdAlreadyExistsException Save a new application.- Parameters:
applicationRequest
- TheApplicationRequest
containing the metadata of the application to create- Returns:
- The unique id of the application that was created
- Throws:
IdAlreadyExistsException
- If the ID is already used by another application
-
getApplication
Get the application metadata for given id.- Parameters:
id
- unique id for application configuration to get. Not null/empty.- Returns:
- The
Application
- Throws:
NotFoundException
- if no application with id exists
-
findApplications
org.springframework.data.domain.Page<Application> findApplications(@Nullable String name, @Nullable String user, @Nullable Set<ApplicationStatus> statuses, @Nullable Set<String> tags, @Nullable String type, org.springframework.data.domain.Pageable page) Find applications which match the given filter criteria.- Parameters:
name
- Name of the application. Can be null or empty.user
- The user who created the application. Can be null/emptystatuses
- The statuses of the applications to find. Can be null.tags
- Tags allocated to this applicationtype
- The type of the application to findpage
- The page requested for the search results- Returns:
- The page of found applications
-
updateApplication
void updateApplication(@NotBlank @NotBlank String id, @Valid @Valid Application updateApp) throws NotFoundException, PreconditionFailedException Update anApplication
.- Parameters:
id
- The id of the application to updateupdateApp
- Information to update for the application configuration with- Throws:
NotFoundException
- If noApplication
with id existsPreconditionFailedException
- If id and updateApp id don't match
-
deleteAllApplications
Delete all applications from the system.- Throws:
PreconditionFailedException
- When anyApplication
is still associated with a command
-
deleteApplication
Delete anApplication
from the system.- Parameters:
id
- unique id of the application to delete- Throws:
PreconditionFailedException
- When theApplication
is still used by any command
-
getCommandsForApplication
Set<Command> getCommandsForApplication(@NotBlank @NotBlank String id, @Nullable Set<CommandStatus> statuses) throws NotFoundException Get all the commands the application with given id is associated with.- Parameters:
id
- The id of the application to get the commands for.statuses
- The desired status(es) to filter the associated commands for- Returns:
- The commands the application is used by
- Throws:
NotFoundException
- If noApplication
with id exists
-
deleteUnusedApplications
long deleteUnusedApplications(@NotNull @NotNull Instant createdThreshold, @Min(1L) @jakarta.validation.constraints.Min(1L) int batchSize) Delete any unused applications that were created before the given time. Unused means they aren't linked to any other resources in the Genie system like jobs or commands and therefore referential integrity is maintained.- Parameters:
createdThreshold
- The instant in time that any application had to be created before (exclusive) to be considered for deletion. Presents ability to filter out newly created applications if desired.batchSize
- The maximum number of applications to delete in a single transaction- Returns:
- The number of successfully deleted applications
-
saveCluster
Save aCluster
.- Parameters:
clusterRequest
- The cluster information to save- Returns:
- The id of the saved cluster
- Throws:
IdAlreadyExistsException
- If aCluster
with the given id already exists
-
getCluster
Get theCluster
identified by the given id.- Parameters:
id
- unique id of theCluster
to get- Returns:
- The
Cluster
- Throws:
NotFoundException
- If noCluster
with id exists
-
findClusters
org.springframework.data.domain.Page<Cluster> findClusters(@Nullable String name, @Nullable Set<ClusterStatus> statuses, @Nullable Set<String> tags, @Nullable Instant minUpdateTime, @Nullable Instant maxUpdateTime, org.springframework.data.domain.Pageable page) Find andCluster
s that match the given parameters. Null or empty parameters are ignored.- Parameters:
name
- cluster namestatuses
-ClusterStatus
that clusters must be in to be matchedtags
- tags attached to this clusterminUpdateTime
- min time when cluster was updatedmaxUpdateTime
- max time when cluster was updatedpage
- The page to get- Returns:
- All the clusters matching the criteria
-
updateCluster
void updateCluster(@NotBlank @NotBlank String id, @Valid @Valid Cluster updateCluster) throws NotFoundException, PreconditionFailedException Update aCluster
with the given information.- Parameters:
id
- The id of the cluster to updateupdateCluster
- The information to update the cluster with- Throws:
NotFoundException
- If noCluster
with id existsPreconditionFailedException
- If the id doesn't match the updateCluster id
-
deleteAllClusters
Delete all clusters from database.- Throws:
PreconditionFailedException
- If the cluster is still associated with any job
-
deleteCluster
Delete aCluster
by id.- Parameters:
id
- unique id of the cluster to delete- Throws:
PreconditionFailedException
- If the cluster is still associated with any job
-
deleteUnusedClusters
long deleteUnusedClusters(Set<ClusterStatus> deleteStatuses, @NotNull @NotNull Instant clusterCreatedThreshold, @Min(1L) @jakarta.validation.constraints.Min(1L) int batchSize) Delete all clusters that are in one of the given states, aren't attached to any jobs and were created before the given time.- Parameters:
deleteStatuses
- The set ofClusterStatus
a cluster must be in to be considered for deletion.clusterCreatedThreshold
- The instant in time before which a cluster must have been created to be considered for deletion. Exclusive.batchSize
- The maximum number of clusters to delete in a single transaction- Returns:
- The number of clusters deleted
-
findClustersMatchingCriterion
Set<Cluster> findClustersMatchingCriterion(@Valid @Valid Criterion criterion, boolean addDefaultStatus) - Parameters:
criterion
- TheCriterion
supplied that each cluster needs to completely match to be returnedaddDefaultStatus
- true if the a default status should be added to the suppliedCriterion
if the supplied criterion doesn't already have a status- Returns:
- All the
Cluster
's which matched theCriterion
-
findClustersMatchingAnyCriterion
Set<Cluster> findClustersMatchingAnyCriterion(@NotEmpty @NotEmpty Set<@Valid Criterion> criteria, boolean addDefaultStatus) - Parameters:
criteria
- The set ofCriterion
supplied that a cluster needs to completely match at least one of to be returnedaddDefaultStatus
- true if the a default status should be added to the suppliedCriterion
if the supplied criterion doesn't already have a status- Returns:
- All the
Cluster
's which matched theCriterion
-
saveCommand
Save aCommand
in the system based on the givenCommandRequest
.- Parameters:
commandRequest
- encapsulates the command configuration information to create- Returns:
- The id of the command that was saved
- Throws:
IdAlreadyExistsException
- If there was a conflict on the unique id for the command
-
getCommand
Get the metadata for theCommand
identified by the id.- Parameters:
id
- unique id for command to get. Not null/empty.- Returns:
- The command
- Throws:
NotFoundException
- If noCommand
exists with the given id
-
findCommands
org.springframework.data.domain.Page<Command> findCommands(@Nullable String name, @Nullable String user, @Nullable Set<CommandStatus> statuses, @Nullable Set<String> tags, org.springframework.data.domain.Pageable page) Find commands matching the given filter criteria.- Parameters:
name
- Name of command configuser
- The name of the user who created the configurationstatuses
- The status of the commands to get. Can be null.tags
- tags allocated to this commandpage
- The page of results to get- Returns:
- All the commands matching the specified criteria
-
updateCommand
void updateCommand(@NotBlank @NotBlank String id, @Valid @Valid Command updateCommand) throws NotFoundException, PreconditionFailedException Update aCommand
.- Parameters:
id
- The id of the command configuration to update. Not null or empty.updateCommand
- contains the information to update the command with- Throws:
NotFoundException
- If noCommand
exists with the given idPreconditionFailedException
- When the id doesn't match the id of updateCommand
-
deleteAllCommands
Delete all commands from the system.- Throws:
PreconditionFailedException
- If any constraint is violated trying to delete a command
-
deleteCommand
Delete aCommand
from system.- Parameters:
id
- unique if of the command to delete- Throws:
NotFoundException
- If noCommand
exists with the given id
-
addApplicationsForCommand
void addApplicationsForCommand(@NotBlank @NotBlank String id, @NotEmpty @NotEmpty List<@NotBlank String> applicationIds) throws NotFoundException, PreconditionFailedException Add applications for the command.- Parameters:
id
- The id of the command to add the application file to. Not null/empty/blank.applicationIds
- The ids of the applications to add. Not null.- Throws:
NotFoundException
- If noCommand
exists with the given id or one of the applications doesn't existPreconditionFailedException
- If an application with one of the ids is already associated with the command
-
setApplicationsForCommand
void setApplicationsForCommand(@NotBlank @NotBlank String id, @NotNull @NotNull List<@NotBlank String> applicationIds) throws NotFoundException, PreconditionFailedException Set the applications for the command.- Parameters:
id
- The id of the command to add the application file to. Not null/empty/blank.applicationIds
- The ids of the applications to set. Not null.- Throws:
NotFoundException
- If noCommand
exists with the given id or one of the applications doesn't existPreconditionFailedException
- If there are duplicate application ids in the list
-
getApplicationsForCommand
Get the applications for a given command.- Parameters:
id
- The id of the command to get the application for. Not null/empty/blank.- Returns:
- The applications or exception if none exist.
- Throws:
NotFoundException
- If noCommand
exists with the given id
-
removeApplicationsForCommand
void removeApplicationsForCommand(@NotBlank @NotBlank String id) throws NotFoundException, PreconditionFailedException Remove all the applications from the command.- Parameters:
id
- The id of the command to remove the application from. Not null/empty/blank.- Throws:
NotFoundException
- If noCommand
exists with the given idPreconditionFailedException
- If applications are unable to be removed
-
removeApplicationForCommand
void removeApplicationForCommand(@NotBlank @NotBlank String id, @NotBlank @NotBlank String appId) throws NotFoundException Remove the application from the command.- Parameters:
id
- The id of the command to remove the application from. Not null/empty/blank.appId
- The id of the application to remove. Not null/empty/blank- Throws:
NotFoundException
- If noCommand
exists with the given id
-
getClustersForCommand
Set<Cluster> getClustersForCommand(@NotBlank @NotBlank String id, @Nullable Set<ClusterStatus> statuses) throws NotFoundException Get all the clusters the command with given id is associated with.- Parameters:
id
- The id of the command to get the clusters for.statuses
- The status of the clusters returned- Returns:
- The clusters the command is available on.
- Throws:
NotFoundException
- If noCommand
exists with the given id
-
getClusterCriteriaForCommand
For the given command id return the ClusterCriterion
in priority order that is currently associated with this command if any.- Parameters:
id
- The id of the command to get the criteria for- Returns:
- The cluster criteria in priority order
- Throws:
NotFoundException
- If no command with id exists
-
addClusterCriterionForCommand
void addClusterCriterionForCommand(String id, @Valid @Valid Criterion criterion) throws NotFoundException Add a newCriterion
to the existing list of cluster criteria for the command identified by id. This new criterion will be the lowest priority criterion.- Parameters:
id
- The id of the command to add tocriterion
- The newCriterion
to add- Throws:
NotFoundException
- If no command with id exists
-
addClusterCriterionForCommand
void addClusterCriterionForCommand(String id, @Valid @Valid Criterion criterion, @Min(0L) @jakarta.validation.constraints.Min(0L) int priority) throws NotFoundException Add a newCriterion
to the existing list of cluster criteria for the command identified by id. The priority is the place in the list this new criterion should be placed. A value of 0 indicates it should be placed at the front of the list with the highest possible priority. 1 would be second in the list etc. If priority is > the current size of the cluster criteria list this new criterion will be placed at the end as the lowest priority item.- Parameters:
id
- The id of the command to add tocriterion
- The newCriterion
to addpriority
- The place in the existing cluster criteria list this new criterion should be placed. Min 0.- Throws:
NotFoundException
- If no command with id exists
-
setClusterCriteriaForCommand
void setClusterCriteriaForCommand(String id, List<@Valid Criterion> clusterCriteria) throws NotFoundException For the command identified by id reset the entire list of cluster criteria to match the contents of clusterCriteria.- Parameters:
id
- The id of the command to set the cluster criteria forclusterCriteria
- The priority list ofCriterion
to set- Throws:
NotFoundException
- If no command with id exists
-
removeClusterCriterionForCommand
void removeClusterCriterionForCommand(String id, @Min(0L) @jakarta.validation.constraints.Min(0L) int priority) throws NotFoundException Remove theCriterion
with the given priority from the current list of cluster criteria associated with the command identified by id. A value of 0 for priority will result in the first element in the list being removed, 1 the second element and so on.- Parameters:
id
- The id of the command to remove the criterion frompriority
- The priority of the criterion to remove- Throws:
NotFoundException
- If no command with id exists
-
removeAllClusterCriteriaForCommand
Remove all theCriterion
currently associated with the command identified by id.- Parameters:
id
- The id of the command to remove the criteria from- Throws:
NotFoundException
- If no command with id exists
-
findCommandsMatchingCriterion
-
updateStatusForUnusedCommands
int updateStatusForUnusedCommands(CommandStatus desiredStatus, Instant commandCreatedThreshold, Set<CommandStatus> currentStatuses, int batchSize) Update the status of a command to the desiredStatus if its status is in currentStatuses, it was created before commandCreatedThreshold and it hasn't been used in any job.- Parameters:
desiredStatus
- The new status the matching commands should havecommandCreatedThreshold
- The instant in time which a command must have been created before to be considered for update. ExclusivecurrentStatuses
- The set of current statuses a command must have to be considered for updatebatchSize
- The maximum number of commands to update in a single transaction- Returns:
- The number of commands whose statuses were updated to desiredStatus
-
deleteUnusedCommands
long deleteUnusedCommands(Set<CommandStatus> deleteStatuses, @NotNull @NotNull Instant commandCreatedThreshold, @Min(1L) @jakarta.validation.constraints.Min(1L) int batchSize) Bulk delete commands from the database where their status is in deleteStatuses they were created before commandCreatedThreshold and they aren't attached to any jobs still in the database.- Parameters:
deleteStatuses
- The set of statuses a command must be in in order to be considered for deletioncommandCreatedThreshold
- The instant in time a command must have been created before to be considered for deletion. Exclusive.batchSize
- The maximum number of commands to delete in a single transaction- Returns:
- The number of commands that were deleted
-
getJob
Get job information for given job id.- Parameters:
id
- id of job to look up- Returns:
- the job
- Throws:
GenieException
- if there is an error
-
getJobExecution
Get job execution for given job id.- Parameters:
id
- id of job execution to look up- Returns:
- the job
- Throws:
GenieException
- if there is an error
-
getJobMetadata
Get the metadata about a job.- Parameters:
id
- The id of the job to get metadata for- Returns:
- The metadata for a job
- Throws:
GenieException
- If any error occurs
-
findJobs
org.springframework.data.domain.Page<JobSearchResult> findJobs(@Nullable String id, @Nullable String name, @Nullable String user, @Nullable Set<JobStatus> statuses, @Nullable Set<String> tags, @Nullable String clusterName, @Nullable String clusterId, @Nullable String commandName, @Nullable String commandId, @Nullable Instant minStarted, @Nullable Instant maxStarted, @Nullable Instant minFinished, @Nullable Instant maxFinished, @Nullable String grouping, @Nullable String groupingInstance, @NotNull @NotNull org.springframework.data.domain.Pageable page) Find jobs which match the given filter criteria.- Parameters:
id
- id for jobname
- name of jobuser
- user who submitted jobstatuses
- statuses of jobtags
- tags for the jobclusterName
- name of cluster for jobclusterId
- id of cluster for jobcommandName
- name of the command run in the jobcommandId
- id of the command run in the jobminStarted
- The time which the job had to start after in order to be return (inclusive)maxStarted
- The time which the job had to start before in order to be returned (exclusive)minFinished
- The time which the job had to finish after in order to be return (inclusive)maxFinished
- The time which the job had to finish before in order to be returned (exclusive)grouping
- The job grouping to search forgroupingInstance
- The job grouping instance to search forpage
- Page information of job to get- Returns:
- Metadata information on jobs which match the criteria
-
deleteJobsCreatedBefore
long deleteJobsCreatedBefore(@NotNull @NotNull Instant creationThreshold, @NotNull @NotNull Set<JobStatus> excludeStatuses, @Min(1L) @jakarta.validation.constraints.Min(1L) int batchSize) This method will delete a chunk of jobs whose creation time is earlier than the given date.- Parameters:
creationThreshold
- The instant in time before which all jobs should be deletedexcludeStatuses
- The set of statuses that should be excluded from deletion if a job is in one of these statusesbatchSize
- The maximum number of jobs that should be deleted per query- Returns:
- the number of deleted jobs
-
saveJobSubmission
@Nonnull String saveJobSubmission(@Valid @Valid JobSubmission jobSubmission) throws IdAlreadyExistsException Save the given job submission information in the underlying data store.The job record will be created with initial state of
JobStatus.RESERVED
meaning that the unique id returned by this API has been reserved within Genie and no other job can use it. IfJobSubmission
contains some attachments these attachments will be persisted to a configured storage system (i.e. local disk, S3, etc) and added to the set of dependencies for the job. The underlying attachment storage system must be accessible by the agent process configured by the system. For example if the server is set up to write attachments to local disk but the agent is not running locally but instead on the remote system it will not be able to access those attachments (as dependencies) and fail. SeeAttachmentService
for more information.- Parameters:
jobSubmission
- All the information the system has gathered regarding the job submission from the user either via the API or via the agent CLI- Returns:
- The unique id of the job within the Genie ecosystem
- Throws:
IdAlreadyExistsException
- If the id the user requested already exists in the system for another job
-
getJobRequest
Get the original request for a job.- Parameters:
id
- The unique id of the job to get- Returns:
- The job request if one was found
- Throws:
NotFoundException
- If no job withid
exists
-
saveResolvedJob
void saveResolvedJob(@NotBlank @NotBlank String id, @Valid @Valid ResolvedJob resolvedJob) throws NotFoundException Save the given resolved details for a job. Sets the job status toJobStatus.RESOLVED
.- Parameters:
id
- The id of the jobresolvedJob
- The resolved information for the job- Throws:
NotFoundException
- When the job identified byid
can't be found and the specification can't be saved or one of the resolved cluster, command or applications not longer exist in the system.
-
getJobSpecification
Optional<JobSpecification> getJobSpecification(@NotBlank @NotBlank String id) throws NotFoundException Get the saved job specification for the given job. If the job hasn't had a job specification resolved an emptyOptional
will be returned.- Parameters:
id
- The id of the job- Returns:
- The
JobSpecification
if one is present else an emptyOptional
- Throws:
NotFoundException
- If no job withid
exists
-
claimJob
void claimJob(@NotBlank @NotBlank String id, @Valid @Valid AgentClientMetadata agentClientMetadata) throws NotFoundException, GenieJobAlreadyClaimedException, GenieInvalidStatusException 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:
NotFoundException
- 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
-
updateJobStatus
JobStatus updateJobStatus(@NotBlank @NotBlank String id, @NotNull @NotNull JobStatus currentStatus, @NotNull @NotNull JobStatus newStatus, @Nullable String newStatusMessage) throws NotFoundException 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. If the currentStatus is different from what the source of truth thinks this function will skip the update and just return the current source of truth value.- 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- Returns:
- The job status in the source of truth
- Throws:
NotFoundException
- if no job with the givenid
exists
-
updateJobArchiveStatus
void updateJobArchiveStatus(@NotBlank(message="No job id entered. Unable to update.") @NotBlank(message="No job id entered. Unable to update.") String id, @NotNull(message="Status cannot be null.") @NotNull(message="Status cannot be null.") ArchiveStatus archiveStatus) throws NotFoundException Update the status and status message of the job.- Parameters:
id
- The id of the job to update the status for.archiveStatus
- The updated archive status for the job.- Throws:
NotFoundException
- If no job with the givenid
exists
-
getJobStatus
Get the status for a job with the givenid
.- Parameters:
id
- The id of the job to get status for- Returns:
- The job status
- Throws:
NotFoundException
- If no job with the givenid
exists
-
getJobArchiveStatus
Get the archive status for a job with the givenid
.- Parameters:
id
- The id of the job to get status for- Returns:
- The job archive status
- Throws:
NotFoundException
- If no job with the givenid
exists
-
getJobArchiveLocation
Get the location a job directory was archived to if at all.- Parameters:
id
- The id of the job to get the location for- Returns:
- The archive location or
Optional.empty()
- Throws:
NotFoundException
- When there is no job with idid
-
getFinishedJob
FinishedJob getFinishedJob(@NotBlank @NotBlank String id) throws NotFoundException, GenieInvalidStatusException Get a DTO representing a finished job.- Parameters:
id
- The id of the job to retrieve- Returns:
- the finished job
- Throws:
NotFoundException
- if no job with the givenid
existsGenieInvalidStatusException
- if the current status of the job is not final
-
isApiJob
Get whether the job with the given ID was submitted via the REST API or other mechanism.- Parameters:
id
- The id of the job. Not blank.- Returns:
- true if the job was submitted via the API. false otherwise
- Throws:
NotFoundException
- If no job with id exists
-
getJobCluster
Get the cluster the job used or is using.- Parameters:
id
- The id of the job to get the cluster for- Returns:
- The
Cluster
- Throws:
NotFoundException
- If either the job or the cluster is not found
-
getJobCommand
Get the command the job used or is using.- Parameters:
id
- The id of the job to get the command for- Returns:
- The
Command
- Throws:
NotFoundException
- If either the job or the command is not found
-
getJobApplications
Get the applications the job used or is currently using.- Parameters:
id
- The id of the job to get the applications for- Returns:
- The
Application
s - Throws:
NotFoundException
- If either the job or the applications were not found
-
getActiveJobCountForUser
Get the count of 'active' jobs for a given user across all instances.- Parameters:
user
- The user name- Returns:
- the number of active jobs for a given user
-
getUserResourcesSummaries
Get a map of summaries of resources usage for each user with at least one active job.- Parameters:
statuses
- The set ofJobStatus
a job must be in to be considered in this requestapi
- Whether the job was submitted via the api (true) or the agent cli (false)- Returns:
- a map of user resources summaries, keyed on user name
-
getUsedMemoryOnHost
Get the amount of memory currently used on the given host by Genie jobs in any of the following states.- Parameters:
hostname
- The hostname to get the memory for- Returns:
- The amount of memory being used in MB by all jobs
-
getActiveJobs
Get the set of active jobs.- Returns:
- The set of job ids which currently have a status which is considered active
-
getUnclaimedJobs
Get the set of jobs in that have not reached CLAIMED state.- Returns:
- The set of job ids for jobs which are active but haven't been claimed
-
getHostJobInformation
Get all the aggregate metadata information about jobs running on a given hostname.- Parameters:
hostname
- The hostname the agent is running the job on- Returns:
- A
JobInfoAggregate
containing the metadata information
-
getJobsWithStatusAndArchiveStatusUpdatedBefore
Set<String> getJobsWithStatusAndArchiveStatusUpdatedBefore(@NotEmpty @NotEmpty Set<JobStatus> statuses, @NotEmpty @NotEmpty Set<ArchiveStatus> archiveStatuses, @NotNull @NotNull Instant updated) Get the set of jobs (agent only) whose state is instatuses
and archive status is inarchiveStatuses
and last updated beforeupdated
.- Parameters:
statuses
- the set of job statusesarchiveStatuses
- the set of job archive statusesupdated
- the threshold of last update- Returns:
- a set of job ids
-
updateRequestedLauncherExt
void updateRequestedLauncherExt(@NotBlank(message="No job id entered. Unable to update.") @NotBlank(message="No job id entered. Unable to update.") String id, @NotNull(message="Status cannot be null.") @NotNull(message="Status cannot be null.") com.fasterxml.jackson.databind.JsonNode launcherExtension) throws NotFoundException Update the requested launcher extension field for this job.- Parameters:
id
- The id of the job to update the laucher extension for.launcherExtension
- The updated requested launcher extension JSON blob.- Throws:
NotFoundException
- If no job with the givenid
exists
-
getRequestedLauncherExt
com.fasterxml.jackson.databind.JsonNode getRequestedLauncherExt(@NotBlank @NotBlank String id) throws NotFoundException Get the command the job used or is using.- Parameters:
id
- The id of the job to get the command for- Returns:
- The
JsonNode
passed to the launcher at launch, or aNullNode
if none was saved - Throws:
NotFoundException
- If no job with the givenid
exists
-
updateLauncherExt
void updateLauncherExt(@NotBlank(message="No job id entered. Unable to update.") @NotBlank(message="No job id entered. Unable to update.") String id, @NotNull(message="Status cannot be null.") @NotNull(message="Status cannot be null.") com.fasterxml.jackson.databind.JsonNode launcherExtension) throws NotFoundException Update the launcher extension field for this job.- Parameters:
id
- The id of the job to update the launcher extension for.launcherExtension
- The updated launcher extension JSON blob.- Throws:
NotFoundException
- If no job with the givenid
exists
-
getLauncherExt
com.fasterxml.jackson.databind.JsonNode getLauncherExt(@NotBlank @NotBlank String id) throws NotFoundException Get the job requested launcher extension.- Parameters:
id
- The id of the job to get the command for- Returns:
- The
JsonNode
emitted by the launcher at launch - Throws:
NotFoundException
- If no job with the givenid
exists
-
addConfigsToResource
<R extends CommonResource> void addConfigsToResource(@NotBlank @NotBlank String id, Set<@Size(max=1024) String> configs, Class<R> resourceClass) throws NotFoundException Add configuration files to the existing set for a resource.- Type Parameters:
R
- The resource type that the configs should be associated with- Parameters:
id
- The id of the resource to add the configuration file to. Not null/empty/blank.configs
- The configuration files to add. Max file length is 1024 characters.resourceClass
- The class of the resource- Throws:
NotFoundException
- If no resource of typePersistenceService
with id exists
-
getConfigsForResource
<R extends CommonResource> Set<String> getConfigsForResource(@NotBlank @NotBlank String id, Class<R> resourceClass) throws NotFoundException Get the set of configuration files associated with the resource with the given id.- Type Parameters:
R
- The resource type that the configs are associated with- Parameters:
id
- The id of the resource to get the configuration files for. Not null/empty/blank.resourceClass
- The class of the resource- Returns:
- The set of configuration files as paths
- Throws:
NotFoundException
- If no resource of typePersistenceService
with id exists
-
updateConfigsForResource
<R extends CommonResource> void updateConfigsForResource(@NotBlank @NotBlank String id, Set<@Size(max=1024) String> configs, Class<R> resourceClass) throws NotFoundException Update the set of configuration files associated with the resource with the given id.- Type Parameters:
R
- The resource type that the configs should be associated with- Parameters:
id
- The id of the resource to update the configuration files for. Not null/empty/blank.configs
- The configuration files to replace existing configurations with. Not null/empty.resourceClass
- The class of the resource- Throws:
NotFoundException
- If no resource of typePersistenceService
with id exists
-
removeAllConfigsForResource
<R extends CommonResource> void removeAllConfigsForResource(@NotBlank @NotBlank String id, Class<R> resourceClass) throws NotFoundException Remove all configuration files from the resource.- Type Parameters:
R
- The resource type that the configs should be associated with- Parameters:
id
- The id of the resource to remove the configuration file from. Not null/empty/blank.resourceClass
- The class of the resource- Throws:
NotFoundException
- If no resource of typePersistenceService
with id exists
-
removeConfigForResource
<R extends CommonResource> void removeConfigForResource(@NotBlank @NotBlank String id, @NotBlank @NotBlank String config, Class<R> resourceClass) throws NotFoundException Remove a configuration file from the given resource.- Type Parameters:
R
- The resource type that the configs should be associated with- Parameters:
id
- The id of the resource to remove the configuration file from. Not null/empty/blank.config
- The configuration file to remove. Not null/empty/blank.resourceClass
- The class of the resource- Throws:
NotFoundException
- If no resource of typePersistenceService
with id exists
-
addDependenciesToResource
<R extends CommonResource> void addDependenciesToResource(@NotBlank @NotBlank String id, Set<@Size(max=1024) String> dependencies, Class<R> resourceClass) throws NotFoundException Add dependency files to the existing set for a resource.- Type Parameters:
R
- The resource type that the dependencies should be associated with- Parameters:
id
- The id of the resource to add the dependency file to. Not null/empty/blank.dependencies
- The dependency files to add. Max file length is 1024 characters.resourceClass
- The class of the resource- Throws:
NotFoundException
- If no resource of typePersistenceService
with id exists
-
getDependenciesForResource
<R extends CommonResource> Set<String> getDependenciesForResource(@NotBlank @NotBlank String id, Class<R> resourceClass) throws NotFoundException Get the set of dependency files associated with the resource with the given id.- Type Parameters:
R
- The resource type that the dependencies are associated with- Parameters:
id
- The id of the resource to get the dependency files for. Not null/empty/blank.resourceClass
- The class of the resource- Returns:
- The set of dependency files as paths
- Throws:
NotFoundException
- If no resource of typePersistenceService
with id exists
-
updateDependenciesForResource
<R extends CommonResource> void updateDependenciesForResource(@NotBlank @NotBlank String id, Set<@Size(max=1024) String> dependencies, Class<R> resourceClass) throws NotFoundException Update the set of dependency files associated with the resource with the given id.- Type Parameters:
R
- The resource type that the dependencies should be associated with- Parameters:
id
- The id of the resource to update the dependency files for. Not null/empty/blank.dependencies
- The dependency files to replace existing dependencys with. Not null/empty.resourceClass
- The class of the resource- Throws:
NotFoundException
- If no resource of typePersistenceService
with id exists
-
removeAllDependenciesForResource
<R extends CommonResource> void removeAllDependenciesForResource(@NotBlank @NotBlank String id, Class<R> resourceClass) throws NotFoundException Remove all dependency files from the resource.- Type Parameters:
R
- The resource type that the dependencies should be associated with- Parameters:
id
- The id of the resource to remove the dependency file from. Not null/empty/blank.resourceClass
- The class of the resource- Throws:
NotFoundException
- If no resource of typePersistenceService
with id exists
-
removeDependencyForResource
<R extends CommonResource> void removeDependencyForResource(@NotBlank @NotBlank String id, @NotBlank @NotBlank String dependency, Class<R> resourceClass) throws NotFoundException Remove a dependency file from the given resource.- Type Parameters:
R
- The resource type that the dependencies should be associated with- Parameters:
id
- The id of the resource to remove the dependency file from. Not null/empty/blank.dependency
- The dependency file to remove. Not null/empty/blank.resourceClass
- The class of the resource- Throws:
NotFoundException
- If no resource of typePersistenceService
with id exists
-
addTagsToResource
<R extends CommonResource> void addTagsToResource(@NotBlank @NotBlank String id, Set<@Size(max=255) String> tags, Class<R> resourceClass) throws NotFoundException Add tags to the existing set for a resource.- Type Parameters:
R
- The resource type that the tags should be associated with- Parameters:
id
- The id of the resource to add the tags to. Not null/empty/blank.tags
- The tags to add. Max file length is 255 characters.resourceClass
- The class of the resource- Throws:
NotFoundException
- If no resource of typePersistenceService
with id exists
-
getTagsForResource
<R extends CommonResource> Set<String> getTagsForResource(@NotBlank @NotBlank String id, Class<R> resourceClass) throws NotFoundException Get the set of tags associated with the resource with the given id.- Type Parameters:
R
- The resource type that the tags are associated with- Parameters:
id
- The id of the resource to get the tags for. Not null/empty/blank.resourceClass
- The class of the resource- Returns:
- The set of tags
- Throws:
NotFoundException
- If no resource of typePersistenceService
with id exists
-
updateTagsForResource
<R extends CommonResource> void updateTagsForResource(@NotBlank @NotBlank String id, Set<@Size(max=255) String> tags, Class<R> resourceClass) throws NotFoundException Update the set of tags associated with the resource with the given id.- Type Parameters:
R
- The resource type that the tags should be associated with- Parameters:
id
- The id of the resource to update the tags for. Not null/empty/blank.tags
- The tags to replace existing tags with. Not null/empty.resourceClass
- The class of the resource- Throws:
NotFoundException
- If no resource of typePersistenceService
with id exists
-
removeAllTagsForResource
<R extends CommonResource> void removeAllTagsForResource(@NotBlank @NotBlank String id, Class<R> resourceClass) throws NotFoundException Remove all tags from the resource.- Type Parameters:
R
- The resource type that the tags should be associated with- Parameters:
id
- The id of the resource to remove the tags from. Not null/empty/blank.resourceClass
- The class of the resource- Throws:
NotFoundException
- If no resource of typePersistenceService
with id exists
-
removeTagForResource
<R extends CommonResource> void removeTagForResource(@NotBlank @NotBlank String id, @NotBlank @NotBlank String tag, Class<R> resourceClass) throws NotFoundException Remove a tag from the given resource.- Type Parameters:
R
- The resource type that the tag should be associated with- Parameters:
id
- The id of the resource to remove the tag from. Not null/empty/blank.tag
- The tag to remove. Not null/empty/blank.resourceClass
- The class of the resource- Throws:
NotFoundException
- If no resource of typePersistenceService
with id exists
-
deleteUnusedTags
long deleteUnusedTags(@NotNull @NotNull Instant createdThresholdLowerBound, @NotNull @NotNull Instant createdThresholdUpperBound, @Min(1L) @jakarta.validation.constraints.Min(1L) int batchSize) Delete all tags from the database that aren't referenced which were created between the supplied threshold bounds.- Parameters:
createdThresholdLowerBound
- The instant in time when tags created after this time that aren't referenced will be selected. Inclusive.createdThresholdUpperBound
- The instant in time when tags created before this time that aren't referenced will be selected. Inclusive.batchSize
- The maximum number of tags to delete in a single transaction- Returns:
- The number of tags deleted
-
deleteUnusedFiles
long deleteUnusedFiles(@NotNull @NotNull Instant createdThresholdLowerBound, @NotNull @NotNull Instant createdThresholdUpperBound, @Min(1L) @jakarta.validation.constraints.Min(1L) int batchSize) Delete all files from the database that aren't referenced which were created between the supplied threshold bounds.- Parameters:
createdThresholdLowerBound
- The instant in time when files created after this time that aren't referenced will be selected. Inclusive.createdThresholdUpperBound
- The instant in time when files created before this time that aren't referenced will be selected. Inclusive.batchSize
- The maximum number of files to delete in a single transaction- Returns:
- The number of files deleted
-