@Transactional(rollbackFor={GenieException.class,GenieCheckedException.class,GenieRuntimeException.class,javax.validation.ConstraintViolationException.class}) public class JpaPersistenceServiceImpl extends java.lang.Object implements PersistenceService
PersistenceService
using JPA.Constructor and Description |
---|
JpaPersistenceServiceImpl(javax.persistence.EntityManager entityManager,
JpaRepositories jpaRepositories,
AttachmentService attachmentService)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
addApplicationsForCommand(@NotBlank java.lang.String id,
@NotEmpty java.util.List<java.lang.String> applicationIds)
Add applications for the command.
|
void |
addClusterCriterionForCommand(java.lang.String id,
@Valid Criterion criterion)
Add a new
Criterion to the existing list of cluster criteria for the command identified by id. |
void |
addClusterCriterionForCommand(java.lang.String id,
@Valid Criterion criterion,
@Min(value=0L) int priority)
Add a new
Criterion to the existing list of cluster criteria for the command identified by id. |
<R extends CommonResource> |
addConfigsToResource(@NotBlank java.lang.String id,
java.util.Set<java.lang.String> configs,
java.lang.Class<R> resourceClass)
Add configuration files to the existing set for a resource.
|
<R extends CommonResource> |
addDependenciesToResource(@NotBlank java.lang.String id,
java.util.Set<java.lang.String> dependencies,
java.lang.Class<R> resourceClass)
Add dependency files to the existing set for a resource.
|
<R extends CommonResource> |
addTagsToResource(@NotBlank java.lang.String id,
java.util.Set<java.lang.String> tags,
java.lang.Class<R> resourceClass)
Add tags to the existing set for a resource.
|
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 . |
void |
createJob(JobRequest jobRequest,
JobMetadata jobMetadata,
@NotNull Job job,
@NotNull JobExecution jobExecution)
Deprecated.
|
void |
deleteAllApplications()
Delete all applications from the system.
|
void |
deleteAllClusters()
Delete all clusters from database.
|
void |
deleteAllCommands()
Delete all commands from the system.
|
void |
deleteApplication(@NotBlank java.lang.String id)
Delete an
Application from the system. |
void |
deleteCluster(@NotBlank java.lang.String id)
Delete a
Cluster by id. |
void |
deleteCommand(@NotBlank java.lang.String id)
Delete a
Command from system. |
long |
deleteJobsCreatedBefore(@NotNull java.time.Instant creationThreshold,
@NotNull java.util.Set<JobStatus> excludeStatuses,
@Min(value=1L) int batchSize)
This method will delete a chunk of jobs whose creation time is earlier than the given date.
|
long |
deleteUnusedApplications(java.time.Instant createdThreshold)
Delete any unused applications that were created before the given time.
|
long |
deleteUnusedClusters(java.util.Set<ClusterStatus> deleteStatuses,
java.time.Instant clusterCreatedThreshold)
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(java.util.Set<CommandStatus> deleteStatuses,
java.time.Instant commandCreatedThreshold)
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 java.time.Instant createdThreshold)
Delete all files from the database that aren't referenced which were created before the supplied created
threshold.
|
long |
deleteUnusedTags(@NotNull java.time.Instant createdThreshold)
Delete all tags from the database that aren't referenced which were created before the supplied created
threshold.
|
org.springframework.data.domain.Page<Application> |
findApplications(java.lang.String name,
java.lang.String user,
java.util.Set<ApplicationStatus> statuses,
java.util.Set<java.lang.String> tags,
java.lang.String type,
org.springframework.data.domain.Pageable page)
Find applications which match the given filter criteria.
|
org.springframework.data.domain.Page<Cluster> |
findClusters(java.lang.String name,
java.util.Set<ClusterStatus> statuses,
java.util.Set<java.lang.String> tags,
java.time.Instant minUpdateTime,
java.time.Instant maxUpdateTime,
org.springframework.data.domain.Pageable page)
Find and
Cluster s that match the given parameters. |
java.util.Set<Cluster> |
findClustersMatchingAnyCriterion(@NotEmpty java.util.Set<Criterion> criteria,
boolean addDefaultStatus)
|
java.util.Set<Cluster> |
findClustersMatchingCriterion(@Valid Criterion criterion,
boolean addDefaultStatus)
|
org.springframework.data.domain.Page<Command> |
findCommands(java.lang.String name,
java.lang.String user,
java.util.Set<CommandStatus> statuses,
java.util.Set<java.lang.String> tags,
org.springframework.data.domain.Pageable page)
Find commands matching the given filter criteria.
|
java.util.Set<Command> |
findCommandsMatchingCriterion(@Valid Criterion criterion,
boolean addDefaultStatus)
|
org.springframework.data.domain.Page<JobSearchResult> |
findJobs(java.lang.String id,
java.lang.String name,
java.lang.String user,
java.util.Set<JobStatus> statuses,
java.util.Set<java.lang.String> tags,
java.lang.String clusterName,
java.lang.String clusterId,
java.lang.String commandName,
java.lang.String commandId,
java.time.Instant minStarted,
java.time.Instant maxStarted,
java.time.Instant minFinished,
java.time.Instant maxFinished,
java.lang.String grouping,
java.lang.String groupingInstance,
@NotNull org.springframework.data.domain.Pageable page)
Find jobs which match the given filter criteria.
|
java.util.Set<java.lang.String> |
getActiveAgentJobs()
Get the set of active agent jobs.
|
long |
getActiveJobCountForUser(@NotBlank java.lang.String user)
Get the count of 'active' jobs for a given user across all instances.
|
java.util.Set<Job> |
getAllActiveJobsOnHost(@NotBlank java.lang.String hostname)
Given a hostname return a set of all the jobs currently active on that host.
|
java.util.Set<java.lang.String> |
getAllHostsWithActiveJobs()
Get a set of host names which are currently have active jobs in the Genie cluster.
|
Application |
getApplication(@NotBlank java.lang.String id)
Get the application metadata for given id.
|
java.util.List<Application> |
getApplicationsForCommand(java.lang.String id)
Get the applications for a given command.
|
Cluster |
getCluster(@NotBlank java.lang.String id)
Get the
Cluster identified by the given id. |
java.util.List<Criterion> |
getClusterCriteriaForCommand(java.lang.String id)
For the given command id return the Cluster
Criterion in priority order that is currently
associated with this command if any. |
java.util.Set<Cluster> |
getClustersForCommand(@NotBlank java.lang.String id,
java.util.Set<ClusterStatus> statuses)
Get all the clusters the command with given id is associated with.
|
Command |
getCommand(@NotBlank java.lang.String id)
Get the metadata for the
Command identified by the id. |
java.util.Set<Command> |
getCommandsForApplication(@NotBlank java.lang.String id,
java.util.Set<CommandStatus> statuses)
Get all the commands the application with given id is associated with.
|
<R extends CommonResource> |
getConfigsForResource(@NotBlank java.lang.String id,
java.lang.Class<R> resourceClass)
Get the set of configuration files associated with the resource with the given id.
|
<R extends CommonResource> |
getDependenciesForResource(@NotBlank java.lang.String id,
java.lang.Class<R> resourceClass)
Get the set of dependency files associated with the resource with the given id.
|
FinishedJob |
getFinishedJob(@NotBlank java.lang.String id)
Get a DTO representing a finished job.
|
JobInfoAggregate |
getHostJobInformation(@NotBlank java.lang.String hostname)
Get all the aggregate metadata information about jobs running on a given hostname.
|
Job |
getJob(@NotBlank java.lang.String id)
Get job information for given job id.
|
java.util.List<Application> |
getJobApplications(@NotBlank java.lang.String id)
Get the applications the job used or is currently using.
|
java.util.Optional<java.lang.String> |
getJobArchiveLocation(@NotBlank java.lang.String id)
Get the location a job directory was archived to if at all.
|
ArchiveStatus |
getJobArchiveStatus(@NotBlank java.lang.String id)
Get the archive status for a job with the given
id . |
Cluster |
getJobCluster(@NotBlank java.lang.String id)
Get the cluster the job used or is using.
|
Command |
getJobCommand(@NotBlank java.lang.String id)
Get the command the job used or is using.
|
JobExecution |
getJobExecution(@NotBlank java.lang.String id)
Get job execution for given job id.
|
java.lang.String |
getJobHost(@NotBlank java.lang.String id)
Get the hostname a job is running on.
|
JobMetadata |
getJobMetadata(@NotBlank java.lang.String id)
Get the metadata about a job.
|
JobRequest |
getJobRequest(@NotBlank java.lang.String id)
Get the original request for a job.
|
java.util.Optional<JobSpecification> |
getJobSpecification(@NotBlank java.lang.String id)
Get the saved job specification for the given job.
|
JobStatus |
getJobStatus(@NotBlank java.lang.String id)
Get the status for a job with the given
id . |
java.util.Set<java.lang.String> |
getJobsWithStatusAndArchiveStatusUpdatedBefore(@NotEmpty java.util.Set<JobStatus> statuses,
@NotEmpty java.util.Set<ArchiveStatus> archiveStatuses,
@NotNull java.time.Instant updated)
Get the set of jobs (agent only) whose state is in
statuses and archive status is in
archiveStatuses and last updated before updated . |
<R extends CommonResource> |
getTagsForResource(@NotBlank java.lang.String id,
java.lang.Class<R> resourceClass)
Get the set of tags associated with the resource with the given id.
|
java.util.Set<java.lang.String> |
getUnclaimedAgentJobs()
Get the set of agent jobs in that have not reached CLAIMED state.
|
long |
getUsedMemoryOnHost(@NotBlank java.lang.String hostname)
Get the amount of memory currently used on the given host by Genie jobs in any of the following states.
|
java.util.Map<java.lang.String,UserResourcesSummary> |
getUserResourcesSummaries(java.util.Set<JobStatus> statuses,
boolean api)
Get a map of summaries of resources usage for each user with at least one active job.
|
JobRequest |
getV3JobRequest(@NotBlank java.lang.String id)
Deprecated.
|
boolean |
isApiJob(@NotBlank java.lang.String id)
Get whether the job with the given ID was submitted via the REST API or other mechanism.
|
boolean |
isV4(@NotBlank java.lang.String id)
Get whether the job is a V4 job (Run with agent).
|
java.util.Optional<java.lang.String> |
lookupAgentConnectionServer(@NotBlank java.lang.String jobId)
Lookup the hostname/address of the server with an active connection to a given agent.
|
void |
removeAgentConnection(@NotBlank java.lang.String jobId,
@NotBlank java.lang.String hostname)
Remove an existing connection currently active from the given agent to the local node.
|
int |
removeAllAgentConnectionsToServer(@NotBlank java.lang.String hostname)
Drop all records of agent connections to the specified hostname.
|
void |
removeAllClusterCriteriaForCommand(java.lang.String id)
Remove all the
Criterion currently associated with the command identified by id. |
<R extends CommonResource> |
removeAllConfigsForResource(@NotBlank java.lang.String id,
java.lang.Class<R> resourceClass)
Remove all configuration files from the resource.
|
<R extends CommonResource> |
removeAllDependenciesForResource(@NotBlank java.lang.String id,
java.lang.Class<R> resourceClass)
Remove all dependency files from the resource.
|
<R extends CommonResource> |
removeAllTagsForResource(@NotBlank java.lang.String id,
java.lang.Class<R> resourceClass)
Remove all tags from the resource.
|
void |
removeApplicationForCommand(@NotBlank java.lang.String id,
@NotBlank java.lang.String appId)
Remove the application from the command.
|
void |
removeApplicationsForCommand(@NotBlank java.lang.String id)
Remove all the applications from the command.
|
void |
removeClusterCriterionForCommand(java.lang.String id,
@Min(value=0L) int priority)
Remove the
Criterion with the given priority from the current list of cluster criteria
associated with the command identified by id. |
<R extends CommonResource> |
removeConfigForResource(@NotBlank java.lang.String id,
@NotBlank java.lang.String config,
java.lang.Class<R> resourceClass)
Remove a configuration file from the given resource.
|
<R extends CommonResource> |
removeDependencyForResource(@NotBlank java.lang.String id,
@NotBlank java.lang.String dependency,
java.lang.Class<R> resourceClass)
Remove a dependency file from the given resource.
|
<R extends CommonResource> |
removeTagForResource(@NotBlank java.lang.String id,
@NotBlank java.lang.String tag,
java.lang.Class<R> resourceClass)
Remove a tag from the given resource.
|
void |
saveAgentConnection(@NotBlank java.lang.String jobId,
@NotBlank java.lang.String hostname)
Store a new connection currently active from the given agent to the given node.
|
java.lang.String |
saveApplication(@Valid ApplicationRequest applicationRequest)
Save a new application.
|
java.lang.String |
saveCluster(@Valid ClusterRequest clusterRequest)
Save a
Cluster . |
java.lang.String |
saveCommand(@Valid CommandRequest commandRequest)
Save a
Command in the system based on the given CommandRequest . |
java.lang.String |
saveJobSubmission(@Valid JobSubmission jobSubmission)
Save the given job submission information in the underlying data store.
|
void |
saveResolvedJob(@NotBlank java.lang.String id,
@Valid ResolvedJob resolvedJob)
Save the given resolved details for a job.
|
void |
setApplicationsForCommand(@NotBlank java.lang.String id,
@NotNull java.util.List<java.lang.String> applicationIds)
Set the applications for the command.
|
void |
setClusterCriteriaForCommand(java.lang.String id,
java.util.List<Criterion> clusterCriteria)
For the command identified by id reset the entire list of cluster criteria to match the contents of
clusterCriteria.
|
void |
setJobCompletionInformation(@NotBlank(message="No job id entered. Unable to update.") java.lang.String id,
int exitCode,
JobStatus status,
@NotBlank(message="Status message can\'t be blank. Unable to update") java.lang.String statusMessage,
java.lang.Long stdOutSize,
java.lang.Long stdErrSize)
Deprecated.
|
void |
setJobRunningInformation(@NotBlank java.lang.String id,
@Min(value=0L,message="Must be no lower than zero") int processId,
@Min(value=1L,message="Must be at least 1 millisecond, preferably much more") long checkDelay,
@NotNull java.time.Instant timeout)
Deprecated.
|
void |
updateApplication(@NotBlank java.lang.String id,
@Valid Application updateApp)
Update an
Application . |
void |
updateCluster(@NotBlank java.lang.String id,
@Valid Cluster updateCluster)
Update a
Cluster with the given information. |
void |
updateCommand(@NotBlank java.lang.String id,
@Valid Command updateCommand)
Update a
Command . |
<R extends CommonResource> |
updateConfigsForResource(@NotBlank java.lang.String id,
java.util.Set<java.lang.String> configs,
java.lang.Class<R> resourceClass)
Update the set of configuration files associated with the resource with the given id.
|
<R extends CommonResource> |
updateDependenciesForResource(@NotBlank java.lang.String id,
java.util.Set<java.lang.String> dependencies,
java.lang.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.") java.lang.String id,
@NotNull(message="Status cannot be null.") ArchiveStatus archiveStatus)
Update the status and status message of the job.
|
void |
updateJobStatus(@NotBlank java.lang.String id,
@NotNull JobStatus currentStatus,
@NotNull 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 . |
void |
updateJobStatus(@NotBlank(message="No job id entered. Unable to update.") java.lang.String id,
JobStatus jobStatus,
@NotBlank(message="Status message cannot be empty.") java.lang.String statusMsg)
Deprecated.
|
void |
updateJobWithRuntimeEnvironment(@NotBlank java.lang.String jobId,
@NotBlank java.lang.String clusterId,
@NotBlank java.lang.String commandId,
@NotNull java.util.List<java.lang.String> applicationIds,
@Min(value=1L) int memory)
Deprecated.
|
int |
updateStatusForUnusedCommands(CommandStatus desiredStatus,
java.time.Instant commandCreatedThreshold,
java.util.Set<CommandStatus> currentStatuses,
java.time.Instant jobCreatedThreshold)
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 that was created
in the Genie system after jobCreatedThreshold.
|
<R extends CommonResource> |
updateTagsForResource(@NotBlank java.lang.String id,
java.util.Set<java.lang.String> tags,
java.lang.Class<R> resourceClass)
Update the set of tags associated with the resource with the given id.
|
public JpaPersistenceServiceImpl(javax.persistence.EntityManager entityManager, JpaRepositories jpaRepositories, AttachmentService attachmentService)
entityManager
- The EntityManager
to usejpaRepositories
- All the repositories in the Genie applicationattachmentService
- The AttachmentService
implementation to usepublic java.lang.String saveApplication(@Valid @Valid ApplicationRequest applicationRequest) throws IdAlreadyExistsException
saveApplication
in interface PersistenceService
applicationRequest
- The ApplicationRequest
containing the metadata of the application to createIdAlreadyExistsException
- If the ID is already used by another application@Transactional(readOnly=true) public Application getApplication(@NotBlank @NotBlank java.lang.String id) throws NotFoundException
getApplication
in interface PersistenceService
id
- unique id for application configuration to get. Not null/empty.Application
NotFoundException
- if no application with id exists@Transactional(readOnly=true) public org.springframework.data.domain.Page<Application> findApplications(@Nullable java.lang.String name, @Nullable java.lang.String user, @Nullable java.util.Set<ApplicationStatus> statuses, @Nullable java.util.Set<java.lang.String> tags, @Nullable java.lang.String type, org.springframework.data.domain.Pageable page)
findApplications
in interface PersistenceService
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 resultspublic void updateApplication(@NotBlank @NotBlank java.lang.String id, @Valid @Valid Application updateApp) throws NotFoundException, PreconditionFailedException
Application
.updateApplication
in interface PersistenceService
id
- The id of the application to updateupdateApp
- Information to update for the application configuration withNotFoundException
- If no Application
with id existsPreconditionFailedException
- If id and updateApp id don't matchpublic void deleteAllApplications() throws PreconditionFailedException
deleteAllApplications
in interface PersistenceService
PreconditionFailedException
- When any Application
is still associated with a commandpublic void deleteApplication(@NotBlank @NotBlank java.lang.String id) throws PreconditionFailedException
Application
from the system.deleteApplication
in interface PersistenceService
id
- unique id of the application to deletePreconditionFailedException
- When the Application
is still used by any command@Transactional(readOnly=true) public java.util.Set<Command> getCommandsForApplication(@NotBlank @NotBlank java.lang.String id, @Nullable java.util.Set<CommandStatus> statuses) throws NotFoundException
getCommandsForApplication
in interface PersistenceService
id
- The id of the application to get the commands for.statuses
- The desired status(es) to filter the associated commands forNotFoundException
- If no Application
with id exists@Transactional(isolation=READ_COMMITTED) public long deleteUnusedApplications(java.time.Instant createdThreshold)
deleteUnusedApplications
in interface PersistenceService
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.public java.lang.String saveCluster(@Valid @Valid ClusterRequest clusterRequest) throws IdAlreadyExistsException
Cluster
.saveCluster
in interface PersistenceService
clusterRequest
- The cluster information to saveIdAlreadyExistsException
- If a Cluster
with the given id already exists@Transactional(readOnly=true) public Cluster getCluster(@NotBlank @NotBlank java.lang.String id) throws NotFoundException
Cluster
identified by the given id.getCluster
in interface PersistenceService
id
- unique id of the Cluster
to getCluster
NotFoundException
- If no Cluster
with id exists@Transactional(readOnly=true) public org.springframework.data.domain.Page<Cluster> findClusters(@Nullable java.lang.String name, @Nullable java.util.Set<ClusterStatus> statuses, @Nullable java.util.Set<java.lang.String> tags, @Nullable java.time.Instant minUpdateTime, @Nullable java.time.Instant maxUpdateTime, org.springframework.data.domain.Pageable page)
Cluster
s that match the given parameters. Null or empty parameters are ignored.findClusters
in interface PersistenceService
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 getpublic void updateCluster(@NotBlank @NotBlank java.lang.String id, @Valid @Valid Cluster updateCluster) throws NotFoundException, PreconditionFailedException
Cluster
with the given information.updateCluster
in interface PersistenceService
id
- The id of the cluster to updateupdateCluster
- The information to update the cluster withNotFoundException
- If no Cluster
with id existsPreconditionFailedException
- If the id doesn't match the updateCluster idpublic void deleteAllClusters() throws PreconditionFailedException
deleteAllClusters
in interface PersistenceService
PreconditionFailedException
- If the cluster is still associated with any jobpublic void deleteCluster(@NotBlank @NotBlank java.lang.String id) throws PreconditionFailedException
Cluster
by id.deleteCluster
in interface PersistenceService
id
- unique id of the cluster to deletePreconditionFailedException
- If the cluster is still associated with any job@Transactional(isolation=READ_COMMITTED) public long deleteUnusedClusters(java.util.Set<ClusterStatus> deleteStatuses, java.time.Instant clusterCreatedThreshold)
deleteUnusedClusters
in interface PersistenceService
deleteStatuses
- The set of ClusterStatus
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.public java.util.Set<Cluster> findClustersMatchingCriterion(@Valid @Valid Criterion criterion, boolean addDefaultStatus)
findClustersMatchingCriterion
in interface PersistenceService
criterion
- The Criterion
supplied that each cluster needs to completely match to be returnedaddDefaultStatus
- true if the a default status should be added to the supplied
Criterion
if the supplied criterion doesn't already have a statusCluster
's which matched the Criterion
public java.util.Set<Cluster> findClustersMatchingAnyCriterion(@NotEmpty @NotEmpty java.util.Set<Criterion> criteria, boolean addDefaultStatus)
findClustersMatchingAnyCriterion
in interface PersistenceService
criteria
- The set of Criterion
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 supplied
Criterion
if the supplied criterion doesn't already have a statusCluster
's which matched the Criterion
public java.lang.String saveCommand(@Valid @Valid CommandRequest commandRequest) throws IdAlreadyExistsException
Command
in the system based on the given CommandRequest
.saveCommand
in interface PersistenceService
commandRequest
- encapsulates the command configuration information to createIdAlreadyExistsException
- If there was a conflict on the unique id for the command@Transactional(readOnly=true) public Command getCommand(@NotBlank @NotBlank java.lang.String id) throws NotFoundException
Command
identified by the id.getCommand
in interface PersistenceService
id
- unique id for command to get. Not null/empty.NotFoundException
- If no Command
exists with the given id@Transactional(readOnly=true) public org.springframework.data.domain.Page<Command> findCommands(@Nullable java.lang.String name, @Nullable java.lang.String user, @Nullable java.util.Set<CommandStatus> statuses, @Nullable java.util.Set<java.lang.String> tags, org.springframework.data.domain.Pageable page)
findCommands
in interface PersistenceService
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 getpublic void updateCommand(@NotBlank @NotBlank java.lang.String id, @Valid @Valid Command updateCommand) throws NotFoundException, PreconditionFailedException
Command
.updateCommand
in interface PersistenceService
id
- The id of the command configuration to update. Not null or empty.updateCommand
- contains the information to update the command withNotFoundException
- If no Command
exists with the given idPreconditionFailedException
- When the id doesn't match the id of updateCommandpublic void deleteAllCommands() throws PreconditionFailedException
deleteAllCommands
in interface PersistenceService
PreconditionFailedException
- If any constraint is violated trying to delete a commandpublic void deleteCommand(@NotBlank @NotBlank java.lang.String id) throws NotFoundException
Command
from system.deleteCommand
in interface PersistenceService
id
- unique if of the command to deleteNotFoundException
- If no Command
exists with the given idpublic void addApplicationsForCommand(@NotBlank @NotBlank java.lang.String id, @NotEmpty @NotEmpty java.util.List<java.lang.String> applicationIds) throws NotFoundException, PreconditionFailedException
addApplicationsForCommand
in interface PersistenceService
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.NotFoundException
- If no Command
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 commandpublic void setApplicationsForCommand(@NotBlank @NotBlank java.lang.String id, @NotNull @NotNull java.util.List<java.lang.String> applicationIds) throws NotFoundException, PreconditionFailedException
setApplicationsForCommand
in interface PersistenceService
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.NotFoundException
- If no Command
exists with the given id or one of the
applications doesn't existPreconditionFailedException
- If there are duplicate application ids in the list@Transactional(readOnly=true) public java.util.List<Application> getApplicationsForCommand(java.lang.String id) throws NotFoundException
getApplicationsForCommand
in interface PersistenceService
id
- The id of the command to get the application for. Not null/empty/blank.NotFoundException
- If no Command
exists with the given idpublic void removeApplicationsForCommand(@NotBlank @NotBlank java.lang.String id) throws NotFoundException, PreconditionFailedException
removeApplicationsForCommand
in interface PersistenceService
id
- The id of the command to remove the application from. Not null/empty/blank.NotFoundException
- If no Command
exists with the given idPreconditionFailedException
- If applications are unable to be removedpublic void removeApplicationForCommand(@NotBlank @NotBlank java.lang.String id, @NotBlank @NotBlank java.lang.String appId) throws NotFoundException
removeApplicationForCommand
in interface PersistenceService
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/blankNotFoundException
- If no Command
exists with the given id@Transactional(readOnly=true) public java.util.Set<Cluster> getClustersForCommand(@NotBlank @NotBlank java.lang.String id, @Nullable java.util.Set<ClusterStatus> statuses) throws NotFoundException
getClustersForCommand
in interface PersistenceService
id
- The id of the command to get the clusters for.statuses
- The status of the clusters returnedNotFoundException
- If no Command
exists with the given id@Transactional(readOnly=true) public java.util.List<Criterion> getClusterCriteriaForCommand(java.lang.String id) throws NotFoundException
Criterion
in priority order that is currently
associated with this command if any.getClusterCriteriaForCommand
in interface PersistenceService
id
- The id of the command to get the criteria forNotFoundException
- If no command with id existspublic void addClusterCriterionForCommand(java.lang.String id, @Valid @Valid Criterion criterion) throws NotFoundException
Criterion
to the existing list of cluster criteria for the command identified by id.
This new criterion will be the lowest priority criterion.addClusterCriterionForCommand
in interface PersistenceService
id
- The id of the command to add tocriterion
- The new Criterion
to addNotFoundException
- If no command with id existspublic void addClusterCriterionForCommand(java.lang.String id, @Valid @Valid Criterion criterion, @Min(value=0L) @Min(value=0L) int priority) throws NotFoundException
Criterion
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.addClusterCriterionForCommand
in interface PersistenceService
id
- The id of the command to add tocriterion
- The new Criterion
to addpriority
- The place in the existing cluster criteria list this new criterion should be placed. Min 0.NotFoundException
- If no command with id existspublic void setClusterCriteriaForCommand(java.lang.String id, java.util.List<Criterion> clusterCriteria) throws NotFoundException
setClusterCriteriaForCommand
in interface PersistenceService
id
- The id of the command to set the cluster criteria forclusterCriteria
- The priority list of Criterion
to setNotFoundException
- If no command with id existspublic void removeClusterCriterionForCommand(java.lang.String id, @Min(value=0L) @Min(value=0L) int priority) throws NotFoundException
Criterion
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.removeClusterCriterionForCommand
in interface PersistenceService
id
- The id of the command to remove the criterion frompriority
- The priority of the criterion to removeNotFoundException
- If no command with id existspublic void removeAllClusterCriteriaForCommand(java.lang.String id) throws NotFoundException
Criterion
currently associated with the command identified by id.removeAllClusterCriteriaForCommand
in interface PersistenceService
id
- The id of the command to remove the criteria fromNotFoundException
- If no command with id exists@Transactional(readOnly=true) public java.util.Set<Command> findCommandsMatchingCriterion(@Valid @Valid Criterion criterion, boolean addDefaultStatus)
findCommandsMatchingCriterion
in interface PersistenceService
criterion
- The Criterion
supplied that each command needs to completely match to be returnedaddDefaultStatus
- true if a default status should be added to the supplied criterion if a
status isn't already presentCommand
's which matched the Criterion
@Transactional(isolation=READ_COMMITTED) public int updateStatusForUnusedCommands(CommandStatus desiredStatus, java.time.Instant commandCreatedThreshold, java.util.Set<CommandStatus> currentStatuses, java.time.Instant jobCreatedThreshold)
updateStatusForUnusedCommands
in interface PersistenceService
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 updatejobCreatedThreshold
- The instant in time after which a command must not have been used in a Genie job
for it to be considered for update. Inclusive.@Transactional(isolation=READ_COMMITTED) public long deleteUnusedCommands(java.util.Set<CommandStatus> deleteStatuses, java.time.Instant commandCreatedThreshold)
deleteUnusedCommands
in interface PersistenceService
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.@Deprecated public void createJob(@NotNull JobRequest jobRequest, @NotNull JobMetadata jobMetadata, @NotNull @NotNull Job job, @NotNull @NotNull JobExecution jobExecution) throws GenieException
createJob
in interface PersistenceService
jobRequest
- the Job request object to save. Not nulljobMetadata
- metadata about the job request. Not nulljob
- The Job object to createjobExecution
- The job execution object to createGenieException
- if there is an error@Deprecated public void updateJobWithRuntimeEnvironment(@NotBlank @NotBlank java.lang.String jobId, @NotBlank @NotBlank java.lang.String clusterId, @NotBlank @NotBlank java.lang.String commandId, @NotNull @NotNull java.util.List<java.lang.String> applicationIds, @Min(value=1L) @Min(value=1L) int memory) throws GenieException
updateJobWithRuntimeEnvironment
in interface PersistenceService
jobId
- The id of the job to updateclusterId
- The id of the cluster the job runs oncommandId
- The id of the command the job runs withapplicationIds
- The ids of the applications used to run the jobmemory
- The amount of memory (in MB) to run the job withGenieException
- For any problems while updating@Deprecated public void updateJobStatus(@NotBlank(message="No job id entered. Unable to update.") @NotBlank(message="No job id entered. Unable to update.") java.lang.String id, @NotNull(message="Status cannot be null.") JobStatus jobStatus, @NotBlank(message="Status message cannot be empty.") @NotBlank(message="Status message cannot be empty.") java.lang.String statusMsg) throws GenieException
updateJobStatus
in interface PersistenceService
id
- The id of the job to update the status for.jobStatus
- The updated status of the job.statusMsg
- The updated status message of the job.GenieException
- if there is an error@Deprecated public void setJobRunningInformation(@NotBlank @NotBlank java.lang.String id, @Min(value=0L,message="Must be no lower than zero") @Min(value=0L,message="Must be no lower than zero") int processId, @Min(value=1L,message="Must be at least 1 millisecond, preferably much more") @Min(value=1L,message="Must be at least 1 millisecond, preferably much more") long checkDelay, @NotNull @NotNull java.time.Instant timeout) throws GenieException
setJobRunningInformation
in interface PersistenceService
id
- the id of the job to update the process id forprocessId
- The id of the process on the box for this jobcheckDelay
- The delay to check the process withtimeout
- The date at which this job should timeoutGenieException
- if there is an error@Deprecated public void setJobCompletionInformation(@NotBlank(message="No job id entered. Unable to update.") @NotBlank(message="No job id entered. Unable to update.") java.lang.String id, int exitCode, @NotNull(message="No job status entered.") JobStatus status, @NotBlank(message="Status message can\'t be blank. Unable to update") @NotBlank(message="Status message can\'t be blank. Unable to update") java.lang.String statusMessage, @Nullable java.lang.Long stdOutSize, @Nullable java.lang.Long stdErrSize) throws GenieException
setJobCompletionInformation
in interface PersistenceService
id
- the id of the job to update the exit codeexitCode
- The exit code of the processstatus
- The job status for the jobstatusMessage
- The job status messagestdOutSize
- The size (in bytes) of the standard out file or null if there isn't onestdErrSize
- The size (in bytes) of the standard error file or null if there isn't oneGenieException
- if there is an error@Transactional(readOnly=true) @Deprecated public JobRequest getV3JobRequest(@NotBlank @NotBlank java.lang.String id) throws GenieException
getV3JobRequest
in interface PersistenceService
id
- id of job request to look upGenieException
- if there is an error@Transactional(readOnly=true) public Job getJob(@NotBlank @NotBlank java.lang.String id) throws GenieException
getJob
in interface PersistenceService
id
- id of job to look upGenieException
- if there is an error@Transactional(readOnly=true) public JobExecution getJobExecution(@NotBlank @NotBlank java.lang.String id) throws GenieException
getJobExecution
in interface PersistenceService
id
- id of job execution to look upGenieException
- if there is an error@Transactional(readOnly=true) public JobMetadata getJobMetadata(@NotBlank @NotBlank java.lang.String id) throws GenieException
getJobMetadata
in interface PersistenceService
id
- The id of the job to get metadata forGenieException
- If any error occurs@Transactional(readOnly=true) public org.springframework.data.domain.Page<JobSearchResult> findJobs(@Nullable java.lang.String id, @Nullable java.lang.String name, @Nullable java.lang.String user, @Nullable java.util.Set<JobStatus> statuses, @Nullable java.util.Set<java.lang.String> tags, @Nullable java.lang.String clusterName, @Nullable java.lang.String clusterId, @Nullable java.lang.String commandName, @Nullable java.lang.String commandId, @Nullable java.time.Instant minStarted, @Nullable java.time.Instant maxStarted, @Nullable java.time.Instant minFinished, @Nullable java.time.Instant maxFinished, @Nullable java.lang.String grouping, @Nullable java.lang.String groupingInstance, @NotNull @NotNull org.springframework.data.domain.Pageable page)
findJobs
in interface PersistenceService
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@Transactional(isolation=READ_COMMITTED) public long deleteJobsCreatedBefore(@NotNull @NotNull java.time.Instant creationThreshold, @NotNull @NotNull java.util.Set<JobStatus> excludeStatuses, @Min(value=1L) @Min(value=1L) int batchSize)
deleteJobsCreatedBefore
in interface PersistenceService
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@Nonnull public java.lang.String saveJobSubmission(@Valid @Valid JobSubmission jobSubmission) throws IdAlreadyExistsException, SaveAttachmentException
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. If
JobSubmission
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.
See AttachmentService
for more information.
saveJobSubmission
in interface PersistenceService
jobSubmission
- All the information the system has gathered regarding the job submission from the user
either via the API or via the agent CLIIdAlreadyExistsException
- If the id the user requested already exists in the system for another jobSaveAttachmentException
- If attachments were sent in with the job submission and they were unable to be
persisted to an underlying storage mechanism meant to share the data with an
agent process@Transactional(readOnly=true) public JobRequest getJobRequest(@NotBlank @NotBlank java.lang.String id) throws NotFoundException
getJobRequest
in interface PersistenceService
id
- The unique id of the job to getNotFoundException
- If no job with id
existspublic void saveResolvedJob(@NotBlank @NotBlank java.lang.String id, @Valid @Valid ResolvedJob resolvedJob) throws NotFoundException
JobStatus.RESOLVED
.saveResolvedJob
in interface PersistenceService
id
- The id of the jobresolvedJob
- The resolved information for the jobNotFoundException
- When the job identified by id
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.@Transactional(readOnly=true) public java.util.Optional<JobSpecification> getJobSpecification(@NotBlank @NotBlank java.lang.String id) throws NotFoundException
Optional
will be returned.getJobSpecification
in interface PersistenceService
id
- The id of the jobJobSpecification
if one is present else an empty Optional
NotFoundException
- If no job with id
existspublic void claimJob(@NotBlank @NotBlank java.lang.String id, @Valid @Valid AgentClientMetadata agentClientMetadata) throws NotFoundException, GenieJobAlreadyClaimedException, GenieInvalidStatusException
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 PersistenceService
id
- The id of the job to claim. Must exist in the system.agentClientMetadata
- The metadata about the client claiming the jobNotFoundException
- if no job with the given id
existsGenieJobAlreadyClaimedException
- if the job with the given id
already has been claimedGenieInvalidStatusException
- if the current job status is not JobStatus.RESOLVED
public void updateJobStatus(@NotBlank @NotBlank java.lang.String id, @NotNull @NotNull JobStatus currentStatus, @NotNull @NotNull JobStatus newStatus, @Nullable java.lang.String newStatusMessage) throws NotFoundException, GenieInvalidStatusException
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 PersistenceService
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 changeNotFoundException
- if no job with the given id
existsGenieInvalidStatusException
- 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
.public void updateJobArchiveStatus(@NotBlank(message="No job id entered. Unable to update.") @NotBlank(message="No job id entered. Unable to update.") java.lang.String id, @NotNull(message="Status cannot be null.") @NotNull(message="Status cannot be null.") ArchiveStatus archiveStatus) throws NotFoundException
updateJobArchiveStatus
in interface PersistenceService
id
- The id of the job to update the status for.archiveStatus
- The updated archive status for the job.NotFoundException
- If no job with the given id
exists@Transactional(readOnly=true) public boolean isV4(@NotBlank @NotBlank java.lang.String id) throws NotFoundException
isV4
in interface PersistenceService
id
- The id of the jobNotFoundException
- If no job with the given id
exists@Transactional(readOnly=true) public JobStatus getJobStatus(@NotBlank @NotBlank java.lang.String id) throws NotFoundException
id
.getJobStatus
in interface PersistenceService
id
- The id of the job to get status forNotFoundException
- If no job with the given id
exists@Transactional(readOnly=true) public ArchiveStatus getJobArchiveStatus(@NotBlank @NotBlank java.lang.String id) throws NotFoundException
id
.getJobArchiveStatus
in interface PersistenceService
id
- The id of the job to get status forNotFoundException
- If no job with the given id
exists@Transactional(readOnly=true) public java.util.Optional<java.lang.String> getJobArchiveLocation(@NotBlank @NotBlank java.lang.String id) throws NotFoundException
getJobArchiveLocation
in interface PersistenceService
id
- The id of the job to get the location forOptional.empty()
NotFoundException
- When there is no job with id id
@Transactional(readOnly=true) public FinishedJob getFinishedJob(@NotBlank @NotBlank java.lang.String id) throws NotFoundException, GenieInvalidStatusException
getFinishedJob
in interface PersistenceService
id
- The id of the job to retrieveNotFoundException
- if no job with the given id
existsGenieInvalidStatusException
- if the current status of the job is not final@Transactional(readOnly=true) public boolean isApiJob(@NotBlank @NotBlank java.lang.String id) throws NotFoundException
isApiJob
in interface PersistenceService
id
- The id of the job. Not blank.NotFoundException
- If no job with id exists@Transactional(readOnly=true) public java.util.Set<Job> getAllActiveJobsOnHost(@NotBlank @NotBlank java.lang.String hostname)
getAllActiveJobsOnHost
in interface PersistenceService
hostname
- The host name to search for. Not null or empty.@Transactional(readOnly=true) public java.util.Set<java.lang.String> getAllHostsWithActiveJobs()
getAllHostsWithActiveJobs
in interface PersistenceService
@Transactional(readOnly=true) public Cluster getJobCluster(@NotBlank @NotBlank java.lang.String id) throws NotFoundException
getJobCluster
in interface PersistenceService
id
- The id of the job to get the cluster forCluster
NotFoundException
- If either the job or the cluster is not found@Transactional(readOnly=true) public Command getJobCommand(@NotBlank @NotBlank java.lang.String id) throws NotFoundException
getJobCommand
in interface PersistenceService
id
- The id of the job to get the command forCommand
NotFoundException
- If either the job or the command is not found@Transactional(readOnly=true) public java.util.List<Application> getJobApplications(@NotBlank @NotBlank java.lang.String id) throws NotFoundException
getJobApplications
in interface PersistenceService
id
- The id of the job to get the applications forApplication
sNotFoundException
- If either the job or the applications were not found@Transactional(readOnly=true) public java.lang.String getJobHost(@NotBlank @NotBlank java.lang.String id) throws NotFoundException
getJobHost
in interface PersistenceService
id
- The id of the job to get the hostname forNotFoundException
- If the job host cannot be found@Transactional(readOnly=true) public long getActiveJobCountForUser(@NotBlank @NotBlank java.lang.String user)
getActiveJobCountForUser
in interface PersistenceService
user
- The user name@Transactional(readOnly=true) public java.util.Map<java.lang.String,UserResourcesSummary> getUserResourcesSummaries(java.util.Set<JobStatus> statuses, boolean api)
getUserResourcesSummaries
in interface PersistenceService
statuses
- The set of JobStatus
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)@Transactional(readOnly=true) public long getUsedMemoryOnHost(@NotBlank @NotBlank java.lang.String hostname)
getUsedMemoryOnHost
in interface PersistenceService
hostname
- The hostname to get the memory for@Transactional(readOnly=true) public java.util.Set<java.lang.String> getActiveAgentJobs()
getActiveAgentJobs
in interface PersistenceService
@Transactional(readOnly=true) public java.util.Set<java.lang.String> getUnclaimedAgentJobs()
getUnclaimedAgentJobs
in interface PersistenceService
@Transactional(readOnly=true) public JobInfoAggregate getHostJobInformation(@NotBlank @NotBlank java.lang.String hostname)
getHostJobInformation
in interface PersistenceService
hostname
- The hostname the agent is running the job onJobInfoAggregate
containing the metadata information@Transactional(readOnly=true) public java.util.Set<java.lang.String> getJobsWithStatusAndArchiveStatusUpdatedBefore(@NotEmpty @NotEmpty java.util.Set<JobStatus> statuses, @NotEmpty @NotEmpty java.util.Set<ArchiveStatus> archiveStatuses, @NotNull @NotNull java.time.Instant updated)
statuses
and archive status is in
archiveStatuses
and last updated before updated
.getJobsWithStatusAndArchiveStatusUpdatedBefore
in interface PersistenceService
statuses
- the set of job statusesarchiveStatuses
- the set of job archive statusesupdated
- the threshold of last updatepublic <R extends CommonResource> void addConfigsToResource(@NotBlank @NotBlank java.lang.String id, java.util.Set<java.lang.String> configs, java.lang.Class<R> resourceClass) throws NotFoundException
addConfigsToResource
in interface PersistenceService
R
- The resource type that the configs should be associated withid
- 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 resourceNotFoundException
- If no resource of type R
with id exists@Transactional(readOnly=true) public <R extends CommonResource> java.util.Set<java.lang.String> getConfigsForResource(@NotBlank @NotBlank java.lang.String id, java.lang.Class<R> resourceClass) throws NotFoundException
getConfigsForResource
in interface PersistenceService
R
- The resource type that the configs are associated withid
- The id of the resource to get the configuration files for. Not null/empty/blank.resourceClass
- The class of the resourceNotFoundException
- If no resource of type R
with id existspublic <R extends CommonResource> void updateConfigsForResource(@NotBlank @NotBlank java.lang.String id, java.util.Set<java.lang.String> configs, java.lang.Class<R> resourceClass) throws NotFoundException
updateConfigsForResource
in interface PersistenceService
R
- The resource type that the configs should be associated withid
- 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 resourceNotFoundException
- If no resource of type R
with id existspublic <R extends CommonResource> void removeAllConfigsForResource(@NotBlank @NotBlank java.lang.String id, java.lang.Class<R> resourceClass) throws NotFoundException
removeAllConfigsForResource
in interface PersistenceService
R
- The resource type that the configs should be associated withid
- The id of the resource to remove the configuration file from. Not null/empty/blank.resourceClass
- The class of the resourceNotFoundException
- If no resource of type R
with id existspublic <R extends CommonResource> void removeConfigForResource(@NotBlank @NotBlank java.lang.String id, @NotBlank @NotBlank java.lang.String config, java.lang.Class<R> resourceClass) throws NotFoundException
removeConfigForResource
in interface PersistenceService
R
- The resource type that the configs should be associated withid
- 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 resourceNotFoundException
- If no resource of type R
with id existspublic <R extends CommonResource> void addDependenciesToResource(@NotBlank @NotBlank java.lang.String id, java.util.Set<java.lang.String> dependencies, java.lang.Class<R> resourceClass) throws NotFoundException
addDependenciesToResource
in interface PersistenceService
R
- The resource type that the dependencies should be associated withid
- 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 resourceNotFoundException
- If no resource of type R
with id exists@Transactional(readOnly=true) public <R extends CommonResource> java.util.Set<java.lang.String> getDependenciesForResource(@NotBlank @NotBlank java.lang.String id, java.lang.Class<R> resourceClass) throws NotFoundException
getDependenciesForResource
in interface PersistenceService
R
- The resource type that the dependencies are associated withid
- The id of the resource to get the dependency files for. Not null/empty/blank.resourceClass
- The class of the resourceNotFoundException
- If no resource of type R
with id existspublic <R extends CommonResource> void updateDependenciesForResource(@NotBlank @NotBlank java.lang.String id, java.util.Set<java.lang.String> dependencies, java.lang.Class<R> resourceClass) throws NotFoundException
updateDependenciesForResource
in interface PersistenceService
R
- The resource type that the dependencies should be associated withid
- 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 resourceNotFoundException
- If no resource of type R
with id existspublic <R extends CommonResource> void removeAllDependenciesForResource(@NotBlank @NotBlank java.lang.String id, java.lang.Class<R> resourceClass) throws NotFoundException
removeAllDependenciesForResource
in interface PersistenceService
R
- The resource type that the dependencies should be associated withid
- The id of the resource to remove the dependency file from. Not null/empty/blank.resourceClass
- The class of the resourceNotFoundException
- If no resource of type R
with id existspublic <R extends CommonResource> void removeDependencyForResource(@NotBlank @NotBlank java.lang.String id, @NotBlank @NotBlank java.lang.String dependency, java.lang.Class<R> resourceClass) throws NotFoundException
removeDependencyForResource
in interface PersistenceService
R
- The resource type that the dependencies should be associated withid
- 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 resourceNotFoundException
- If no resource of type R
with id existspublic <R extends CommonResource> void addTagsToResource(@NotBlank @NotBlank java.lang.String id, java.util.Set<java.lang.String> tags, java.lang.Class<R> resourceClass) throws NotFoundException
addTagsToResource
in interface PersistenceService
R
- The resource type that the tags should be associated withid
- 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 resourceNotFoundException
- If no resource of type R
with id exists@Transactional(readOnly=true) public <R extends CommonResource> java.util.Set<java.lang.String> getTagsForResource(@NotBlank @NotBlank java.lang.String id, java.lang.Class<R> resourceClass) throws NotFoundException
getTagsForResource
in interface PersistenceService
R
- The resource type that the tags are associated withid
- The id of the resource to get the tags for. Not null/empty/blank.resourceClass
- The class of the resourceNotFoundException
- If no resource of type R
with id existspublic <R extends CommonResource> void updateTagsForResource(@NotBlank @NotBlank java.lang.String id, java.util.Set<java.lang.String> tags, java.lang.Class<R> resourceClass) throws NotFoundException
updateTagsForResource
in interface PersistenceService
R
- The resource type that the tags should be associated withid
- 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 resourceNotFoundException
- If no resource of type R
with id existspublic <R extends CommonResource> void removeAllTagsForResource(@NotBlank @NotBlank java.lang.String id, java.lang.Class<R> resourceClass) throws NotFoundException
removeAllTagsForResource
in interface PersistenceService
R
- The resource type that the tags should be associated withid
- The id of the resource to remove the tags from. Not null/empty/blank.resourceClass
- The class of the resourceNotFoundException
- If no resource of type R
with id existspublic <R extends CommonResource> void removeTagForResource(@NotBlank @NotBlank java.lang.String id, @NotBlank @NotBlank java.lang.String tag, java.lang.Class<R> resourceClass) throws NotFoundException
removeTagForResource
in interface PersistenceService
R
- The resource type that the tag should be associated withid
- 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 resourceNotFoundException
- If no resource of type R
with id existspublic void saveAgentConnection(@NotBlank @NotBlank java.lang.String jobId, @NotBlank @NotBlank java.lang.String hostname)
saveAgentConnection
in interface PersistenceService
jobId
- the id of a job the agent is runninghostname
- the server owning the connectionpublic void removeAgentConnection(@NotBlank @NotBlank java.lang.String jobId, @NotBlank @NotBlank java.lang.String hostname)
removeAgentConnection
in interface PersistenceService
jobId
- the id of a job the agent is runninghostname
- the hostname expected to be associated to the connection@Transactional(readOnly=true) public java.util.Optional<java.lang.String> lookupAgentConnectionServer(@NotBlank @NotBlank java.lang.String jobId)
lookupAgentConnectionServer
in interface PersistenceService
jobId
- the id of a job the agent is runningpublic int removeAllAgentConnectionsToServer(@NotBlank @NotBlank java.lang.String hostname)
removeAllAgentConnectionsToServer
in interface PersistenceService
hostname
- the server hostname@Transactional(isolation=READ_COMMITTED) public long deleteUnusedTags(@NotNull @NotNull java.time.Instant createdThreshold)
deleteUnusedTags
in interface PersistenceService
createdThreshold
- The instant in time where tags created before this time that aren't referenced
will be deleted. Inclusive@Transactional(isolation=READ_COMMITTED) public long deleteUnusedFiles(@NotNull @NotNull java.time.Instant createdThreshold)
deleteUnusedFiles
in interface PersistenceService
createdThreshold
- The instant in time where files created before this time that aren't referenced
will be deleted. Inclusive