@Transactional(rollbackFor={GenieException.class,GenieRuntimeException.class,javax.validation.ConstraintViolationException.class}) public class JpaClusterPersistenceServiceImpl extends java.lang.Object implements ClusterPersistenceService
Constructor and Description |
---|
JpaClusterPersistenceServiceImpl(JpaTagPersistenceService tagPersistenceService,
JpaFilePersistenceService filePersistenceService,
JpaApplicationRepository applicationRepository,
JpaClusterRepository clusterRepository,
JpaCommandRepository commandRepository)
Default constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
addCommandsForCluster(@NotBlank(message="No cluster id entered. Unable to add commands.") java.lang.String id,
@NotEmpty(message="No command ids entered. Unable to add commands.") java.util.List<java.lang.String> commandIds)
Add commands to the cluster.
|
void |
addConfigsForCluster(@NotBlank(message="No cluster id entered. Unable to add configurations.") java.lang.String id,
@NotEmpty(message="No configuration files entered. Unable to add.") java.util.Set<java.lang.String> configs)
Add configuration files to the cluster.
|
void |
addDependenciesForCluster(@NotBlank(message="No cluster id entered. Unable to add dependencies.") java.lang.String id,
@NotEmpty(message="No dependencies entered. Unable to add dependencies.") java.util.Set<java.lang.String> dependencies)
Add dependency files to the cluster.
|
void |
addTagsForCluster(@NotBlank(message="No cluster id entered. Unable to add tags.") java.lang.String id,
@NotEmpty(message="No tags entered. Unable to add to tags.") java.util.Set<java.lang.String> tags)
Add tags to the cluster.
|
java.lang.String |
createCluster(@NotNull(message="No cluster request entered. Unable to create.") @Valid ClusterRequest request)
Create new cluster configuration.
|
void |
deleteAllClusters()
Delete all clusters from database.
|
void |
deleteCluster(@NotBlank(message="No id entered unable to delete.") java.lang.String id)
Delete a cluster configuration by id.
|
long |
deleteTerminatedClusters()
Delete all clusters that are in a terminated state and aren't attached to any jobs.
|
java.util.Map<Cluster,java.lang.String> |
findClustersAndCommandsForCriteria(@NotEmpty java.util.List<Criterion> clusterCriteria,
@NotNull Criterion commandCriterion)
Find the clusters and commands that can run a job given the criteria the user asked for in the job.
|
java.util.Map<Cluster,java.lang.String> |
findClustersAndCommandsForJob(@NotNull(message="JobRequest object is null. Unable to continue.") JobRequest jobRequest)
Find the clusters and commands that can run a job given the criteria the user asked for in the job.
|
Cluster |
getCluster(@NotBlank(message="No id entered. Unable to get.") java.lang.String id)
Get the cluster configuration by id.
|
org.springframework.data.domain.Page<Cluster> |
getClusters(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)
Get cluster info for various parameters.
|
java.util.List<Command> |
getCommandsForCluster(@NotBlank(message="No cluster id entered. Unable to get commands.") java.lang.String id,
java.util.Set<CommandStatus> statuses)
Get the set of commands associated with the cluster with given id.
|
java.util.Set<java.lang.String> |
getConfigsForCluster(@NotBlank(message="No cluster id sent. Cannot retrieve configurations.") java.lang.String id)
Get the set of configuration files associated with the cluster with given
id.
|
java.util.Set<java.lang.String> |
getDependenciesForCluster(@NotBlank(message="No cluster id entered. Unable to get dependencies.") java.lang.String id)
Get the set of dependency files associated with the cluster with given id.
|
java.util.Set<java.lang.String> |
getTagsForCluster(@NotBlank(message="No cluster id sent. Cannot retrieve tags.") java.lang.String id)
Get the set of tags associated with the cluster with given
id.
|
void |
patchCluster(@NotBlank java.lang.String id,
@NotNull com.github.fge.jsonpatch.JsonPatch patch)
Patch a cluster with the given json patch.
|
void |
removeAllCommandsForCluster(@NotBlank(message="No cluster id entered. Unable to remove commands.") java.lang.String id)
Remove all commands from the cluster.
|
void |
removeAllConfigsForCluster(@NotBlank(message="No cluster id entered. Unable to remove configs.") java.lang.String id)
Remove all configuration files from the cluster.
|
void |
removeAllDependenciesForCluster(@NotBlank(message="No cluster id entered. Unable to remove dependencies.") java.lang.String id)
Remove all dependency files from the cluster.
|
void |
removeAllTagsForCluster(@NotBlank(message="No cluster id entered. Unable to remove tags.") java.lang.String id)
Remove all tags from the cluster.
|
void |
removeCommandForCluster(@NotBlank(message="No cluster id entered. Unable to remove command.") java.lang.String id,
@NotBlank(message="No command id entered. Unable to remove command.") java.lang.String cmdId)
Remove a command from the cluster.
|
void |
removeDependencyForCluster(@NotBlank(message="No cluster id entered. Unable to remove dependency.") java.lang.String id,
@NotBlank(message="No dependency entered. Unable to remove dependency.") java.lang.String dependency)
Remove a dependency file from the cluster.
|
void |
removeTagForCluster(@NotBlank(message="No cluster id entered. Unable to remove tag.") java.lang.String id,
@NotBlank(message="No tag entered. Unable to remove.") java.lang.String tag)
Remove a tag from the cluster.
|
void |
setCommandsForCluster(@NotBlank(message="No cluster id entered. Unable to update commands.") java.lang.String id,
@NotNull(message="No command ids entered. Unable to update commands.") java.util.List<java.lang.String> commandIds)
Update the set of command files associated with the cluster with
given id.
|
void |
updateCluster(@NotBlank(message="No cluster id entered. Unable to update.") java.lang.String id,
@NotNull(message="No cluster information entered. Unable to update.") @Valid Cluster updateCluster)
Update a cluster.
|
void |
updateConfigsForCluster(@NotBlank(message="No cluster id entered. Unable to update configurations.") java.lang.String id,
@NotEmpty(message="No configs entered. Unable to update.") java.util.Set<java.lang.String> configs)
Update the set of configuration files associated with the cluster with
given id.
|
void |
updateDependenciesForCluster(@NotBlank(message="No cluster id entered. Unable to update dependencies.") java.lang.String id,
@NotNull(message="No dependencies entered. Unable to update.") java.util.Set<java.lang.String> dependencies)
Update the set of dependency files associated with the cluster with given
id.
|
void |
updateTagsForCluster(@NotBlank(message="No cluster id entered. Unable to update tags.") java.lang.String id,
@NotEmpty(message="No tags entered. Unable to update.") java.util.Set<java.lang.String> tags)
Update the set of tags associated with the cluster with
given id.
|
public JpaClusterPersistenceServiceImpl(JpaTagPersistenceService tagPersistenceService, JpaFilePersistenceService filePersistenceService, JpaApplicationRepository applicationRepository, JpaClusterRepository clusterRepository, JpaCommandRepository commandRepository)
tagPersistenceService
- The JpaTagPersistenceService
to usefilePersistenceService
- The JpaFilePersistenceService
to useapplicationRepository
- The JpaApplicationRepository
to useclusterRepository
- The JpaClusterRepository
to usecommandRepository
- The JpaCommandRepository
to usepublic java.lang.String createCluster(@NotNull(message="No cluster request entered. Unable to create.") @Valid @NotNull(message="No cluster request entered. Unable to create.") @Valid ClusterRequest request) throws GenieException
createCluster
in interface ClusterPersistenceService
request
- The cluster information to createGenieException
- if there is an error@Transactional(readOnly=true) public Cluster getCluster(@NotBlank(message="No id entered. Unable to get.") @NotBlank(message="No id entered. Unable to get.") java.lang.String id) throws GenieException
getCluster
in interface ClusterPersistenceService
id
- unique id of cluster configuration to returnGenieException
- For any error@Transactional(readOnly=true) public org.springframework.data.domain.Page<Cluster> getClusters(@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)
getClusters
in interface ClusterPersistenceService
name
- cluster namestatuses
- valid types - Types.ClusterStatustags
- tags allocated to this clusterminUpdateTime
- min time when cluster configuration was updatedmaxUpdateTime
- max time when cluster configuration was updatedpage
- The page to get@Transactional(readOnly=true) public java.util.Map<Cluster,java.lang.String> findClustersAndCommandsForJob(@NotNull(message="JobRequest object is null. Unable to continue.") @NotNull(message="JobRequest object is null. Unable to continue.") JobRequest jobRequest) throws GenieException
findClustersAndCommandsForJob
in interface ClusterPersistenceService
jobRequest
- The request to runt he job. Not null.GenieException
- if there is an error@Transactional(readOnly=true) public java.util.Map<Cluster,java.lang.String> findClustersAndCommandsForCriteria(@NotEmpty @NotEmpty java.util.List<Criterion> clusterCriteria, @NotNull @NotNull Criterion commandCriterion) throws GenieException
findClustersAndCommandsForCriteria
in interface ClusterPersistenceService
clusterCriteria
- The ordered list of cluster criterion provided by user to select a cluster for a jobcommandCriterion
- The criterion to use to select a command for a job on a clusterGenieException
- if there is an errorpublic void updateCluster(@NotBlank(message="No cluster id entered. Unable to update.") @NotBlank(message="No cluster id entered. Unable to update.") java.lang.String id, @NotNull(message="No cluster information entered. Unable to update.") @Valid @NotNull(message="No cluster information entered. Unable to update.") @Valid Cluster updateCluster) throws GenieException
updateCluster
in interface ClusterPersistenceService
id
- The id of the cluster to updateupdateCluster
- The information to update the cluster withGenieException
- if there is an errorpublic void patchCluster(@NotBlank @NotBlank java.lang.String id, @NotNull @NotNull com.github.fge.jsonpatch.JsonPatch patch) throws GenieException
patchCluster
in interface ClusterPersistenceService
id
- The id of the cluster to updatepatch
- The json patch to use to update the given clusterGenieException
- if there is an errorpublic void deleteAllClusters() throws GenieException
deleteAllClusters
in interface ClusterPersistenceService
GenieException
- if there is an errorpublic void deleteCluster(@NotBlank(message="No id entered unable to delete.") @NotBlank(message="No id entered unable to delete.") java.lang.String id) throws GenieException
deleteCluster
in interface ClusterPersistenceService
id
- unique id for cluster to deleteGenieException
- if there is an errorpublic void addConfigsForCluster(@NotBlank(message="No cluster id entered. Unable to add configurations.") @NotBlank(message="No cluster id entered. Unable to add configurations.") java.lang.String id, @NotEmpty(message="No configuration files entered. Unable to add.") @NotEmpty(message="No configuration files entered. Unable to add.") java.util.Set<java.lang.String> configs) throws GenieException
addConfigsForCluster
in interface ClusterPersistenceService
id
- The id of the cluster to add the configuration file to. Not
null/empty/blank.configs
- The configuration files to add. Not null/empty.GenieException
- if there is an error@Transactional(readOnly=true) public java.util.Set<java.lang.String> getConfigsForCluster(@NotBlank(message="No cluster id sent. Cannot retrieve configurations.") @NotBlank(message="No cluster id sent. Cannot retrieve configurations.") java.lang.String id) throws GenieException
getConfigsForCluster
in interface ClusterPersistenceService
id
- The id of the cluster to get the configuration files for. Not
null/empty/blank.GenieException
- if there is an errorpublic void updateConfigsForCluster(@NotBlank(message="No cluster id entered. Unable to update configurations.") @NotBlank(message="No cluster id entered. Unable to update configurations.") java.lang.String id, @NotEmpty(message="No configs entered. Unable to update.") @NotEmpty(message="No configs entered. Unable to update.") java.util.Set<java.lang.String> configs) throws GenieException
updateConfigsForCluster
in interface ClusterPersistenceService
id
- The id of the cluster to update the configuration files for.
Not null/empty/blank.configs
- The configuration files to replace existing configurations
with. Not null/empty.GenieException
- if there is an errorpublic void removeAllConfigsForCluster(@NotBlank(message="No cluster id entered. Unable to remove configs.") @NotBlank(message="No cluster id entered. Unable to remove configs.") java.lang.String id) throws GenieException
removeAllConfigsForCluster
in interface ClusterPersistenceService
id
- The id of the cluster to remove the configuration file from.
Not null/empty/blank.GenieException
- if there is an errorpublic void addDependenciesForCluster(@NotBlank(message="No cluster id entered. Unable to add dependencies.") @NotBlank(message="No cluster id entered. Unable to add dependencies.") java.lang.String id, @NotEmpty(message="No dependencies entered. Unable to add dependencies.") @NotEmpty(message="No dependencies entered. Unable to add dependencies.") java.util.Set<java.lang.String> dependencies) throws GenieException
addDependenciesForCluster
in interface ClusterPersistenceService
id
- The id of the cluster to add the dependency file to. Not
null/empty/blank.dependencies
- The dependency files to add. Not null.GenieException
- if there is an error@Transactional(readOnly=true) public java.util.Set<java.lang.String> getDependenciesForCluster(@NotBlank(message="No cluster id entered. Unable to get dependencies.") @NotBlank(message="No cluster id entered. Unable to get dependencies.") java.lang.String id) throws GenieException
getDependenciesForCluster
in interface ClusterPersistenceService
id
- The id of the cluster to get the dependency files for. Not
null/empty/blank.GenieException
- if there is an errorpublic void updateDependenciesForCluster(@NotBlank(message="No cluster id entered. Unable to update dependencies.") @NotBlank(message="No cluster id entered. Unable to update dependencies.") java.lang.String id, @NotNull(message="No dependencies entered. Unable to update.") @NotNull(message="No dependencies entered. Unable to update.") java.util.Set<java.lang.String> dependencies) throws GenieException
updateDependenciesForCluster
in interface ClusterPersistenceService
id
- The id of the cluster to update the dependency files for. Not
null/empty/blank.dependencies
- The dependency files to replace existing dependencies with. Not null/empty.GenieException
- if there is an errorpublic void removeAllDependenciesForCluster(@NotBlank(message="No cluster id entered. Unable to remove dependencies.") @NotBlank(message="No cluster id entered. Unable to remove dependencies.") java.lang.String id) throws GenieException
removeAllDependenciesForCluster
in interface ClusterPersistenceService
id
- The id of the cluster to remove the configuration file
from. Not null/empty/blank.GenieException
- if there is an errorpublic void removeDependencyForCluster(@NotBlank(message="No cluster id entered. Unable to remove dependency.") @NotBlank(message="No cluster id entered. Unable to remove dependency.") java.lang.String id, @NotBlank(message="No dependency entered. Unable to remove dependency.") @NotBlank(message="No dependency entered. Unable to remove dependency.") java.lang.String dependency) throws GenieException
removeDependencyForCluster
in interface ClusterPersistenceService
id
- The id of the cluster to remove the dependency file from. Not
null/empty/blank.dependency
- The dependency file to remove. Not null/empty/blank.GenieException
- if there is an errorpublic void addTagsForCluster(@NotBlank(message="No cluster id entered. Unable to add tags.") @NotBlank(message="No cluster id entered. Unable to add tags.") java.lang.String id, @NotEmpty(message="No tags entered. Unable to add to tags.") @NotEmpty(message="No tags entered. Unable to add to tags.") java.util.Set<java.lang.String> tags) throws GenieException
addTagsForCluster
in interface ClusterPersistenceService
id
- The id of the cluster to add the tags to. Not
null/empty/blank.tags
- The tags to add. Not null/empty.GenieException
- if there is an error@Transactional(readOnly=true) public java.util.Set<java.lang.String> getTagsForCluster(@NotBlank(message="No cluster id sent. Cannot retrieve tags.") @NotBlank(message="No cluster id sent. Cannot retrieve tags.") java.lang.String id) throws GenieException
getTagsForCluster
in interface ClusterPersistenceService
id
- The id of the cluster to get the tags for. Not
null/empty/blank.GenieException
- if there is an errorpublic void updateTagsForCluster(@NotBlank(message="No cluster id entered. Unable to update tags.") @NotBlank(message="No cluster id entered. Unable to update tags.") java.lang.String id, @NotEmpty(message="No tags entered. Unable to update.") @NotEmpty(message="No tags entered. Unable to update.") java.util.Set<java.lang.String> tags) throws GenieException
updateTagsForCluster
in interface ClusterPersistenceService
id
- The id of the cluster to update the tags for.
Not null/empty/blank.tags
- The tags to replace existing tags
with. Not null/empty.GenieException
- if there is an errorpublic void removeAllTagsForCluster(@NotBlank(message="No cluster id entered. Unable to remove tags.") @NotBlank(message="No cluster id entered. Unable to remove tags.") java.lang.String id) throws GenieException
removeAllTagsForCluster
in interface ClusterPersistenceService
id
- The id of the cluster to remove the tags from.
Not null/empty/blank.GenieException
- if there is an errorpublic void removeTagForCluster(@NotBlank(message="No cluster id entered. Unable to remove tag.") @NotBlank(message="No cluster id entered. Unable to remove tag.") java.lang.String id, @NotBlank(message="No tag entered. Unable to remove.") @NotBlank(message="No tag entered. Unable to remove.") java.lang.String tag) throws GenieException
removeTagForCluster
in interface ClusterPersistenceService
id
- The id of the cluster to remove the tag from. Not
null/empty/blank.tag
- The tag to remove. Not null/empty/blank.GenieException
- if there is an errorpublic void addCommandsForCluster(@NotBlank(message="No cluster id entered. Unable to add commands.") @NotBlank(message="No cluster id entered. Unable to add commands.") java.lang.String id, @NotEmpty(message="No command ids entered. Unable to add commands.") @NotEmpty(message="No command ids entered. Unable to add commands.") java.util.List<java.lang.String> commandIds) throws GenieException
addCommandsForCluster
in interface ClusterPersistenceService
id
- The id of the cluster to add the command file to. Not
null/empty/blank.commandIds
- The ids of the commands to add. Not null/empty.GenieException
- if there is an error@Transactional(readOnly=true) public java.util.List<Command> getCommandsForCluster(@NotBlank(message="No cluster id entered. Unable to get commands.") @NotBlank(message="No cluster id entered. Unable to get commands.") java.lang.String id, @Nullable java.util.Set<CommandStatus> statuses) throws GenieException
getCommandsForCluster
in interface ClusterPersistenceService
id
- The id of the cluster to get the commands for. Not
null/empty/blank.statuses
- The statuses to get commands forGenieException
- if there is an errorpublic void setCommandsForCluster(@NotBlank(message="No cluster id entered. Unable to update commands.") @NotBlank(message="No cluster id entered. Unable to update commands.") java.lang.String id, @NotNull(message="No command ids entered. Unable to update commands.") @NotNull(message="No command ids entered. Unable to update commands.") java.util.List<java.lang.String> commandIds) throws GenieException
setCommandsForCluster
in interface ClusterPersistenceService
id
- The id of the cluster to update the command files for. Not
null/empty/blank.commandIds
- The ids of the commands to replace existing
commands with. Not null/empty.GenieException
- if there is an errorpublic void removeAllCommandsForCluster(@NotBlank(message="No cluster id entered. Unable to remove commands.") @NotBlank(message="No cluster id entered. Unable to remove commands.") java.lang.String id) throws GenieException
removeAllCommandsForCluster
in interface ClusterPersistenceService
id
- The id of the cluster to remove the commands from. Not
null/empty/blank.GenieException
- if there is an errorpublic void removeCommandForCluster(@NotBlank(message="No cluster id entered. Unable to remove command.") @NotBlank(message="No cluster id entered. Unable to remove command.") java.lang.String id, @NotBlank(message="No command id entered. Unable to remove command.") @NotBlank(message="No command id entered. Unable to remove command.") java.lang.String cmdId) throws GenieException
removeCommandForCluster
in interface ClusterPersistenceService
id
- The id of the cluster to remove the command from. Not
null/empty/blank.cmdId
- The id of the command to remove. Not null/empty/blank.GenieException
- if there is an errorpublic long deleteTerminatedClusters()
deleteTerminatedClusters
in interface ClusterPersistenceService