Interface PersistenceService
- All Known Implementing Classes:
JpaPersistenceServiceImpl
- Since:
- 4.0.0
-
Method Summary
Modifier and TypeMethodDescriptionvoidaddApplicationsForCommand(@NotBlank String id, @NotEmpty List<@NotBlank String> applicationIds) Add applications for the command.voidaddClusterCriterionForCommand(String id, @Valid com.netflix.genie.common.internal.dtos.Criterion criterion) Add a newCriterionto the existing list of cluster criteria for the command identified by id.voidaddClusterCriterionForCommand(String id, @Valid com.netflix.genie.common.internal.dtos.Criterion criterion, @javax.validation.constraints.Min(0L) int priority) Add a newCriterionto the existing list of cluster criteria for the command identified by id.<R extends com.netflix.genie.common.internal.dtos.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 com.netflix.genie.common.internal.dtos.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 com.netflix.genie.common.internal.dtos.CommonResource>
voidaddTagsToResource(@NotBlank String id, Set<@Size(max=255) String> tags, Class<R> resourceClass) Add tags to the existing set for a resource.voidclaimJob(@NotBlank String id, @Valid com.netflix.genie.common.internal.dtos.AgentClientMetadata agentClientMetadata) Set a job identified byidto be owned by the agent identified byagentClientMetadata.voidDelete all applications from the system.voidDelete all clusters from database.voidDelete all commands from the system.voiddeleteApplication(@NotBlank String id) Delete anApplicationfrom the system.voiddeleteCluster(@NotBlank String id) Delete aClusterby id.voiddeleteCommand(@NotBlank String id) Delete aCommandfrom system.longdeleteJobsCreatedBefore(@NotNull Instant creationThreshold, @NotNull Set<com.netflix.genie.common.internal.dtos.JobStatus> excludeStatuses, @javax.validation.constraints.Min(1L) int batchSize) This method will delete a chunk of jobs whose creation time is earlier than the given date.longdeleteUnusedApplications(@NotNull Instant createdThreshold, @javax.validation.constraints.Min(1L) int batchSize) Delete any unused applications that were created before the given time.longdeleteUnusedClusters(Set<com.netflix.genie.common.internal.dtos.ClusterStatus> deleteStatuses, @NotNull Instant clusterCreatedThreshold, @javax.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.longdeleteUnusedCommands(Set<com.netflix.genie.common.internal.dtos.CommandStatus> deleteStatuses, @NotNull Instant commandCreatedThreshold, @javax.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.longdeleteUnusedFiles(@NotNull Instant createdThresholdLowerBound, @NotNull Instant createdThresholdUpperBound, @javax.validation.constraints.Min(1L) int batchSize) Delete all files from the database that aren't referenced which were created between the supplied threshold bounds.longdeleteUnusedTags(@NotNull Instant createdThresholdLowerBound, @NotNull Instant createdThresholdUpperBound, @javax.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<com.netflix.genie.common.internal.dtos.Application>findApplications(String name, String user, Set<com.netflix.genie.common.internal.dtos.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<com.netflix.genie.common.internal.dtos.Cluster>findClusters(String name, Set<com.netflix.genie.common.internal.dtos.ClusterStatus> statuses, Set<String> tags, Instant minUpdateTime, Instant maxUpdateTime, org.springframework.data.domain.Pageable page) Find andClusters that match the given parameters.Set<com.netflix.genie.common.internal.dtos.Cluster>findClustersMatchingAnyCriterion(@NotEmpty Set<@Valid com.netflix.genie.common.internal.dtos.Criterion> criteria, boolean addDefaultStatus) Find all theCluster's that match any of the givenCriterion.Set<com.netflix.genie.common.internal.dtos.Cluster>findClustersMatchingCriterion(@Valid com.netflix.genie.common.internal.dtos.Criterion criterion, boolean addDefaultStatus) Find all theCluster's that match the givenCriterion.org.springframework.data.domain.Page<com.netflix.genie.common.internal.dtos.Command>findCommands(String name, String user, Set<com.netflix.genie.common.internal.dtos.CommandStatus> statuses, Set<String> tags, org.springframework.data.domain.Pageable page) Find commands matching the given filter criteria.Set<com.netflix.genie.common.internal.dtos.Command>findCommandsMatchingCriterion(@Valid com.netflix.genie.common.internal.dtos.Criterion criterion, boolean addDefaultStatus) Find all theCommand's that match the givenCriterion.org.springframework.data.domain.Page<com.netflix.genie.common.dto.search.JobSearchResult>findJobs(String id, String name, String user, Set<com.netflix.genie.common.dto.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.longgetActiveJobCountForUser(@NotBlank String user) Get the count of 'active' jobs for a given user across all instances.Get the set of active jobs.com.netflix.genie.common.internal.dtos.ApplicationgetApplication(@NotBlank String id) Get the application metadata for given id.List<com.netflix.genie.common.internal.dtos.Application>Get the applications for a given command.com.netflix.genie.common.internal.dtos.ClustergetCluster(@NotBlank String id) Get theClusteridentified by the given id.List<com.netflix.genie.common.internal.dtos.Criterion>For the given command id return the ClusterCriterionin priority order that is currently associated with this command if any.Set<com.netflix.genie.common.internal.dtos.Cluster>getClustersForCommand(@NotBlank String id, Set<com.netflix.genie.common.internal.dtos.ClusterStatus> statuses) Get all the clusters the command with given id is associated with.com.netflix.genie.common.internal.dtos.CommandgetCommand(@NotBlank String id) Get the metadata for theCommandidentified by the id.Set<com.netflix.genie.common.internal.dtos.Command>getCommandsForApplication(@NotBlank String id, Set<com.netflix.genie.common.internal.dtos.CommandStatus> statuses) Get all the commands the application with given id is associated with.getConfigsForResource(@NotBlank String id, Class<R> resourceClass) Get the set of configuration files associated with the resource with the given id.getDependenciesForResource(@NotBlank String id, Class<R> resourceClass) Get the set of dependency files associated with the resource with the given id.com.netflix.genie.common.internal.dtos.FinishedJobgetFinishedJob(@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.com.netflix.genie.common.dto.JobGet job information for given job id.List<com.netflix.genie.common.internal.dtos.Application>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.com.netflix.genie.common.internal.dtos.ArchiveStatusgetJobArchiveStatus(@NotBlank String id) Get the archive status for a job with the givenid.com.netflix.genie.common.internal.dtos.ClustergetJobCluster(@NotBlank String id) Get the cluster the job used or is using.com.netflix.genie.common.internal.dtos.CommandgetJobCommand(@NotBlank String id) Get the command the job used or is using.com.netflix.genie.common.dto.JobExecutiongetJobExecution(@NotBlank String id) Get job execution for given job id.com.netflix.genie.common.dto.JobMetadatagetJobMetadata(@NotBlank String id) Get the metadata about a job.com.netflix.genie.common.internal.dtos.JobRequestgetJobRequest(@NotBlank String id) Get the original request for a job.Optional<com.netflix.genie.common.internal.dtos.JobSpecification>getJobSpecification(@NotBlank String id) Get the saved job specification for the given job.com.netflix.genie.common.internal.dtos.JobStatusgetJobStatus(@NotBlank String id) Get the status for a job with the givenid.getJobsWithStatusAndArchiveStatusUpdatedBefore(@NotEmpty Set<com.netflix.genie.common.internal.dtos.JobStatus> statuses, @NotEmpty Set<com.netflix.genie.common.internal.dtos.ArchiveStatus> archiveStatuses, @NotNull Instant updated) Get the set of jobs (agent only) whose state is instatusesand archive status is inarchiveStatusesand last updated beforeupdated.com.fasterxml.jackson.databind.JsonNodegetLauncherExt(@NotBlank String id) Get the job requested launcher extension.com.fasterxml.jackson.databind.JsonNodegetRequestedLauncherExt(@NotBlank String id) Get the command the job used or is using.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.longgetUsedMemoryOnHost(@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<com.netflix.genie.common.internal.dtos.JobStatus> statuses, boolean api) Get a map of summaries of resources usage for each user with at least one active job.booleanGet whether the job with the given ID was submitted via the REST API or other mechanism.voidRemove all theCriterioncurrently associated with the command identified by id.<R extends com.netflix.genie.common.internal.dtos.CommonResource>
voidremoveAllConfigsForResource(@NotBlank String id, Class<R> resourceClass) Remove all configuration files from the resource.<R extends com.netflix.genie.common.internal.dtos.CommonResource>
voidremoveAllDependenciesForResource(@NotBlank String id, Class<R> resourceClass) Remove all dependency files from the resource.<R extends com.netflix.genie.common.internal.dtos.CommonResource>
voidremoveAllTagsForResource(@NotBlank String id, Class<R> resourceClass) Remove all tags from the resource.voidremoveApplicationForCommand(@NotBlank String id, @NotBlank String appId) Remove the application from the command.voidremoveApplicationsForCommand(@NotBlank String id) Remove all the applications from the command.voidremoveClusterCriterionForCommand(String id, @javax.validation.constraints.Min(0L) int priority) Remove theCriterionwith the given priority from the current list of cluster criteria associated with the command identified by id.<R extends com.netflix.genie.common.internal.dtos.CommonResource>
voidremoveConfigForResource(@NotBlank String id, @NotBlank String config, Class<R> resourceClass) Remove a configuration file from the given resource.<R extends com.netflix.genie.common.internal.dtos.CommonResource>
voidremoveDependencyForResource(@NotBlank String id, @NotBlank String dependency, Class<R> resourceClass) Remove a dependency file from the given resource.<R extends com.netflix.genie.common.internal.dtos.CommonResource>
voidremoveTagForResource(@NotBlank String id, @NotBlank String tag, Class<R> resourceClass) Remove a tag from the given resource.saveApplication(@Valid com.netflix.genie.common.internal.dtos.ApplicationRequest applicationRequest) Save a new application.saveCluster(@Valid com.netflix.genie.common.internal.dtos.ClusterRequest clusterRequest) Save aCluster.saveCommand(@Valid com.netflix.genie.common.internal.dtos.CommandRequest commandRequest) Save aCommandin the system based on the givenCommandRequest.saveJobSubmission(@Valid JobSubmission jobSubmission) Save the given job submission information in the underlying data store.voidsaveResolvedJob(@NotBlank String id, @Valid ResolvedJob resolvedJob) Save the given resolved details for a job.voidsetApplicationsForCommand(@NotBlank String id, @NotNull List<@NotBlank String> applicationIds) Set the applications for the command.voidsetClusterCriteriaForCommand(String id, List<@Valid com.netflix.genie.common.internal.dtos.Criterion> clusterCriteria) For the command identified by id reset the entire list of cluster criteria to match the contents of clusterCriteria.voidupdateApplication(@NotBlank String id, @Valid com.netflix.genie.common.internal.dtos.Application updateApp) Update anApplication.voidupdateCluster(@NotBlank String id, @Valid com.netflix.genie.common.internal.dtos.Cluster updateCluster) Update aClusterwith the given information.voidupdateCommand(@NotBlank String id, @Valid com.netflix.genie.common.internal.dtos.Command updateCommand) Update aCommand.<R extends com.netflix.genie.common.internal.dtos.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 com.netflix.genie.common.internal.dtos.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.voidupdateJobArchiveStatus(@NotBlank(message="No job id entered. Unable to update.") String id, @NotNull(message="Status cannot be null.") com.netflix.genie.common.internal.dtos.ArchiveStatus archiveStatus) Update the status and status message of the job.com.netflix.genie.common.internal.dtos.JobStatusupdateJobStatus(@NotBlank String id, @NotNull com.netflix.genie.common.internal.dtos.JobStatus currentStatus, @NotNull com.netflix.genie.common.internal.dtos.JobStatus newStatus, String newStatusMessage) Update the status of the job identified withidto benewStatusprovided that the current status of the job matchesnewStatus.voidupdateLauncherExt(@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.voidupdateRequestedLauncherExt(@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.intupdateStatusForUnusedCommands(com.netflix.genie.common.internal.dtos.CommandStatus desiredStatus, Instant commandCreatedThreshold, Set<com.netflix.genie.common.internal.dtos.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 com.netflix.genie.common.internal.dtos.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 com.netflix.genie.common.internal.dtos.ApplicationRequest applicationRequest) throws IdAlreadyExistsException Save a new application.- Parameters:
applicationRequest- TheApplicationRequestcontaining 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
com.netflix.genie.common.internal.dtos.Application getApplication(@NotBlank @NotBlank String id) throws NotFoundException 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<com.netflix.genie.common.internal.dtos.Application> findApplications(@Nullable String name, @Nullable String user, @Nullable Set<com.netflix.genie.common.internal.dtos.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 com.netflix.genie.common.internal.dtos.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 noApplicationwith id existsPreconditionFailedException- If id and updateApp id don't match
-
deleteAllApplications
Delete all applications from the system.- Throws:
PreconditionFailedException- When anyApplicationis still associated with a command
-
deleteApplication
Delete anApplicationfrom the system.- Parameters:
id- unique id of the application to delete- Throws:
PreconditionFailedException- When theApplicationis still used by any command
-
getCommandsForApplication
Set<com.netflix.genie.common.internal.dtos.Command> getCommandsForApplication(@NotBlank @NotBlank String id, @Nullable Set<com.netflix.genie.common.internal.dtos.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 noApplicationwith id exists
-
deleteUnusedApplications
long deleteUnusedApplications(@NotNull @NotNull Instant createdThreshold, @Min(1L) @javax.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
String saveCluster(@Valid @Valid com.netflix.genie.common.internal.dtos.ClusterRequest clusterRequest) throws IdAlreadyExistsException Save aCluster.- Parameters:
clusterRequest- The cluster information to save- Returns:
- The id of the saved cluster
- Throws:
IdAlreadyExistsException- If aClusterwith the given id already exists
-
getCluster
com.netflix.genie.common.internal.dtos.Cluster getCluster(@NotBlank @NotBlank String id) throws NotFoundException Get theClusteridentified by the given id.- Parameters:
id- unique id of theClusterto get- Returns:
- The
Cluster - Throws:
NotFoundException- If noClusterwith id exists
-
findClusters
org.springframework.data.domain.Page<com.netflix.genie.common.internal.dtos.Cluster> findClusters(@Nullable String name, @Nullable Set<com.netflix.genie.common.internal.dtos.ClusterStatus> statuses, @Nullable Set<String> tags, @Nullable Instant minUpdateTime, @Nullable Instant maxUpdateTime, org.springframework.data.domain.Pageable page) Find andClusters that match the given parameters. Null or empty parameters are ignored.- Parameters:
name- cluster namestatuses-ClusterStatusthat 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 com.netflix.genie.common.internal.dtos.Cluster updateCluster) throws NotFoundException, PreconditionFailedException Update aClusterwith the given information.- Parameters:
id- The id of the cluster to updateupdateCluster- The information to update the cluster with- Throws:
NotFoundException- If noClusterwith 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 aClusterby 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<com.netflix.genie.common.internal.dtos.ClusterStatus> deleteStatuses, @NotNull @NotNull Instant clusterCreatedThreshold, @Min(1L) @javax.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 ofClusterStatusa 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<com.netflix.genie.common.internal.dtos.Cluster> findClustersMatchingCriterion(@Valid @Valid com.netflix.genie.common.internal.dtos.Criterion criterion, boolean addDefaultStatus) Find all theCluster's that match the givenCriterion.- Parameters:
criterion- TheCriterionsupplied that each cluster needs to completely match to be returnedaddDefaultStatus- true if the a default status should be added to the suppliedCriterionif the supplied criterion doesn't already have a status- Returns:
- All the
Cluster's which matched theCriterion
-
findClustersMatchingAnyCriterion
Set<com.netflix.genie.common.internal.dtos.Cluster> findClustersMatchingAnyCriterion(@NotEmpty @NotEmpty Set<@Valid com.netflix.genie.common.internal.dtos.Criterion> criteria, boolean addDefaultStatus) Find all theCluster's that match any of the givenCriterion.- Parameters:
criteria- The set ofCriterionsupplied 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 suppliedCriterionif the supplied criterion doesn't already have a status- Returns:
- All the
Cluster's which matched theCriterion
-
saveCommand
String saveCommand(@Valid @Valid com.netflix.genie.common.internal.dtos.CommandRequest commandRequest) throws IdAlreadyExistsException Save aCommandin 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
com.netflix.genie.common.internal.dtos.Command getCommand(@NotBlank @NotBlank String id) throws NotFoundException Get the metadata for theCommandidentified by the id.- Parameters:
id- unique id for command to get. Not null/empty.- Returns:
- The command
- Throws:
NotFoundException- If noCommandexists with the given id
-
findCommands
org.springframework.data.domain.Page<com.netflix.genie.common.internal.dtos.Command> findCommands(@Nullable String name, @Nullable String user, @Nullable Set<com.netflix.genie.common.internal.dtos.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 com.netflix.genie.common.internal.dtos.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 noCommandexists 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 aCommandfrom system.- Parameters:
id- unique if of the command to delete- Throws:
NotFoundException- If noCommandexists 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 noCommandexists 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 noCommandexists with the given id or one of the applications doesn't existPreconditionFailedException- If there are duplicate application ids in the list
-
getApplicationsForCommand
List<com.netflix.genie.common.internal.dtos.Application> getApplicationsForCommand(String id) throws NotFoundException 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 noCommandexists 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 noCommandexists 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 noCommandexists with the given id
-
getClustersForCommand
Set<com.netflix.genie.common.internal.dtos.Cluster> getClustersForCommand(@NotBlank @NotBlank String id, @Nullable Set<com.netflix.genie.common.internal.dtos.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 noCommandexists with the given id
-
getClusterCriteriaForCommand
List<com.netflix.genie.common.internal.dtos.Criterion> getClusterCriteriaForCommand(String id) throws NotFoundException For the given command id return the ClusterCriterionin 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 com.netflix.genie.common.internal.dtos.Criterion criterion) throws NotFoundException Add a newCriterionto 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 newCriterionto add- Throws:
NotFoundException- If no command with id exists
-
addClusterCriterionForCommand
void addClusterCriterionForCommand(String id, @Valid @Valid com.netflix.genie.common.internal.dtos.Criterion criterion, @Min(0L) @javax.validation.constraints.Min(0L) int priority) throws NotFoundException Add a newCriterionto 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 newCriterionto 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 com.netflix.genie.common.internal.dtos.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 ofCriterionto set- Throws:
NotFoundException- If no command with id exists
-
removeClusterCriterionForCommand
void removeClusterCriterionForCommand(String id, @Min(0L) @javax.validation.constraints.Min(0L) int priority) throws NotFoundException Remove theCriterionwith 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 theCriterioncurrently 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
Set<com.netflix.genie.common.internal.dtos.Command> findCommandsMatchingCriterion(@Valid @Valid com.netflix.genie.common.internal.dtos.Criterion criterion, boolean addDefaultStatus) Find all theCommand's that match the givenCriterion.- Parameters:
criterion- TheCriterionsupplied 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 present- Returns:
- All the
Command's which matched theCriterion
-
updateStatusForUnusedCommands
int updateStatusForUnusedCommands(com.netflix.genie.common.internal.dtos.CommandStatus desiredStatus, Instant commandCreatedThreshold, Set<com.netflix.genie.common.internal.dtos.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<com.netflix.genie.common.internal.dtos.CommandStatus> deleteStatuses, @NotNull @NotNull Instant commandCreatedThreshold, @Min(1L) @javax.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
com.netflix.genie.common.dto.Job getJob(@NotBlank @NotBlank String id) throws com.netflix.genie.common.exceptions.GenieException Get job information for given job id.- Parameters:
id- id of job to look up- Returns:
- the job
- Throws:
com.netflix.genie.common.exceptions.GenieException- if there is an error
-
getJobExecution
com.netflix.genie.common.dto.JobExecution getJobExecution(@NotBlank @NotBlank String id) throws com.netflix.genie.common.exceptions.GenieException Get job execution for given job id.- Parameters:
id- id of job execution to look up- Returns:
- the job
- Throws:
com.netflix.genie.common.exceptions.GenieException- if there is an error
-
getJobMetadata
com.netflix.genie.common.dto.JobMetadata getJobMetadata(@NotBlank @NotBlank String id) throws com.netflix.genie.common.exceptions.GenieException Get the metadata about a job.- Parameters:
id- The id of the job to get metadata for- Returns:
- The metadata for a job
- Throws:
com.netflix.genie.common.exceptions.GenieException- If any error occurs
-
findJobs
org.springframework.data.domain.Page<com.netflix.genie.common.dto.search.JobSearchResult> findJobs(@Nullable String id, @Nullable String name, @Nullable String user, @Nullable Set<com.netflix.genie.common.dto.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<com.netflix.genie.common.internal.dtos.JobStatus> excludeStatuses, @Min(1L) @javax.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.RESERVEDmeaning that the unique id returned by this API has been reserved within Genie and no other job can use it. IfJobSubmissioncontains 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. SeeAttachmentServicefor 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
com.netflix.genie.common.internal.dtos.JobRequest getJobRequest(@NotBlank @NotBlank String id) throws NotFoundException 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 withidexists
-
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 byidcan'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<com.netflix.genie.common.internal.dtos.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 emptyOptionalwill be returned.- Parameters:
id- The id of the job- Returns:
- The
JobSpecificationif one is present else an emptyOptional - Throws:
NotFoundException- If no job withidexists
-
claimJob
void claimJob(@NotBlank @NotBlank String id, @Valid @Valid com.netflix.genie.common.internal.dtos.AgentClientMetadata agentClientMetadata) throws NotFoundException, com.netflix.genie.common.internal.exceptions.unchecked.GenieJobAlreadyClaimedException, com.netflix.genie.common.internal.exceptions.unchecked.GenieInvalidStatusException Set a job identified byidto 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 givenidexistscom.netflix.genie.common.internal.exceptions.unchecked.GenieJobAlreadyClaimedException- if the job with the givenidalready has been claimedcom.netflix.genie.common.internal.exceptions.unchecked.GenieInvalidStatusException- if the current job status is notJobStatus.RESOLVED
-
updateJobStatus
com.netflix.genie.common.internal.dtos.JobStatus updateJobStatus(@NotBlank @NotBlank String id, @NotNull @NotNull com.netflix.genie.common.internal.dtos.JobStatus currentStatus, @NotNull @NotNull com.netflix.genie.common.internal.dtos.JobStatus newStatus, @Nullable String newStatusMessage) throws NotFoundException Update the status of the job identified withidto benewStatusprovided that the current status of the job matchesnewStatus. Optionally a status message can be provided to provide more details to users. If thenewStatusisJobStatus.RUNNINGthe start time will be set. If thenewStatusis 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 givenidexists
-
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.") com.netflix.genie.common.internal.dtos.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 givenidexists
-
getJobStatus
com.netflix.genie.common.internal.dtos.JobStatus getJobStatus(@NotBlank @NotBlank String id) throws NotFoundException 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 givenidexists
-
getJobArchiveStatus
com.netflix.genie.common.internal.dtos.ArchiveStatus getJobArchiveStatus(@NotBlank @NotBlank String id) throws NotFoundException 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 givenidexists
-
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
com.netflix.genie.common.internal.dtos.FinishedJob getFinishedJob(@NotBlank @NotBlank String id) throws NotFoundException, com.netflix.genie.common.internal.exceptions.unchecked.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 givenidexistscom.netflix.genie.common.internal.exceptions.unchecked.GenieInvalidStatusException- 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
com.netflix.genie.common.internal.dtos.Cluster getJobCluster(@NotBlank @NotBlank String id) throws NotFoundException 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
com.netflix.genie.common.internal.dtos.Command getJobCommand(@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
Command - Throws:
NotFoundException- If either the job or the command is not found
-
getJobApplications
List<com.netflix.genie.common.internal.dtos.Application> getJobApplications(@NotBlank @NotBlank String id) throws NotFoundException Get the applications the job used or is currently using.- Parameters:
id- The id of the job to get the applications for- Returns:
- The
Applications - 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
Map<String,com.netflix.genie.common.dto.UserResourcesSummary> getUserResourcesSummaries(Set<com.netflix.genie.common.internal.dtos.JobStatus> statuses, boolean api) Get a map of summaries of resources usage for each user with at least one active job.- Parameters:
statuses- The set ofJobStatusa 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.JobStatus.CLAIMEDJobStatus.INITJobStatus.RUNNING- 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
JobInfoAggregatecontaining the metadata information
-
getJobsWithStatusAndArchiveStatusUpdatedBefore
Set<String> getJobsWithStatusAndArchiveStatusUpdatedBefore(@NotEmpty @NotEmpty Set<com.netflix.genie.common.internal.dtos.JobStatus> statuses, @NotEmpty @NotEmpty Set<com.netflix.genie.common.internal.dtos.ArchiveStatus> archiveStatuses, @NotNull @NotNull Instant updated) Get the set of jobs (agent only) whose state is instatusesand archive status is inarchiveStatusesand 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 givenidexists
-
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
JsonNodepassed to the launcher at launch, or aNullNodeif none was saved - Throws:
NotFoundException- If no job with the givenidexists
-
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 givenidexists
-
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
JsonNodeemitted by the launcher at launch - Throws:
NotFoundException- If no job with the givenidexists
-
addConfigsToResource
<R extends com.netflix.genie.common.internal.dtos.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 typePersistenceServicewith id exists
-
getConfigsForResource
<R extends com.netflix.genie.common.internal.dtos.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 typePersistenceServicewith id exists
-
updateConfigsForResource
<R extends com.netflix.genie.common.internal.dtos.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 typePersistenceServicewith id exists
-
removeAllConfigsForResource
<R extends com.netflix.genie.common.internal.dtos.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 typePersistenceServicewith id exists
-
removeConfigForResource
<R extends com.netflix.genie.common.internal.dtos.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 typePersistenceServicewith id exists
-
addDependenciesToResource
<R extends com.netflix.genie.common.internal.dtos.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 typePersistenceServicewith id exists
-
getDependenciesForResource
<R extends com.netflix.genie.common.internal.dtos.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 typePersistenceServicewith id exists
-
updateDependenciesForResource
<R extends com.netflix.genie.common.internal.dtos.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 typePersistenceServicewith id exists
-
removeAllDependenciesForResource
<R extends com.netflix.genie.common.internal.dtos.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 typePersistenceServicewith id exists
-
removeDependencyForResource
<R extends com.netflix.genie.common.internal.dtos.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 typePersistenceServicewith id exists
-
addTagsToResource
<R extends com.netflix.genie.common.internal.dtos.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 typePersistenceServicewith id exists
-
getTagsForResource
<R extends com.netflix.genie.common.internal.dtos.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 typePersistenceServicewith id exists
-
updateTagsForResource
<R extends com.netflix.genie.common.internal.dtos.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 typePersistenceServicewith id exists
-
removeAllTagsForResource
<R extends com.netflix.genie.common.internal.dtos.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 typePersistenceServicewith id exists
-
removeTagForResource
<R extends com.netflix.genie.common.internal.dtos.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 typePersistenceServicewith id exists
-
deleteUnusedTags
long deleteUnusedTags(@NotNull @NotNull Instant createdThresholdLowerBound, @NotNull @NotNull Instant createdThresholdUpperBound, @Min(1L) @javax.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) @javax.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
-