Interface JpaClusterRepository
- All Superinterfaces:
org.springframework.data.repository.CrudRepository<ClusterEntity,,Long> JpaBaseRepository<ClusterEntity>,org.springframework.data.jpa.repository.JpaRepository<ClusterEntity,,Long> org.springframework.data.jpa.repository.JpaSpecificationExecutor<ClusterEntity>,org.springframework.data.repository.PagingAndSortingRepository<ClusterEntity,,Long> org.springframework.data.repository.query.QueryByExampleExecutor<ClusterEntity>,org.springframework.data.repository.Repository<ClusterEntity,Long>
Cluster repository.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe SQL to find all clusters that aren't attached to any jobs still in the database and were created before a certain point in time. -
Method Summary
Modifier and TypeMethodDescriptionfindUnusedClusters(Set<String> unusedStatuses, Instant clusterCreatedThreshold, int limit) Find all the clusters that aren't attached to any jobs in the database, were created before the given time and have one of the given statuses.getClusterDto(String id) Find the cluster with the given id but also eagerly load all data needed for a cluster DTO.Methods inherited from interface org.springframework.data.repository.CrudRepository
count, delete, deleteAll, deleteAll, deleteAllById, deleteById, existsById, findById, saveMethods inherited from interface com.netflix.genie.web.data.services.impl.jpa.repositories.JpaBaseRepository
deleteByIdIn, existsByUniqueId, findByUniqueId, findByUniqueIdMethods inherited from interface org.springframework.data.jpa.repository.JpaRepository
deleteAllByIdInBatch, deleteAllInBatch, deleteAllInBatch, deleteInBatch, findAll, findAll, findAll, findAll, findAllById, flush, getById, getOne, getReferenceById, saveAll, saveAllAndFlush, saveAndFlushMethods inherited from interface org.springframework.data.jpa.repository.JpaSpecificationExecutor
count, exists, findAll, findAll, findAll, findOneMethods inherited from interface org.springframework.data.repository.PagingAndSortingRepository
findAllMethods inherited from interface org.springframework.data.repository.query.QueryByExampleExecutor
count, exists, findAll, findBy, findOne
-
Field Details
-
FIND_UNUSED_CLUSTERS_SQL
The SQL to find all clusters that aren't attached to any jobs still in the database and were created before a certain point in time.- See Also:
-
-
Method Details
-
findUnusedClusters
@Query(value="SELECT id FROM clusters WHERE status IN (:unusedStatuses) AND created < :clusterCreatedThreshold AND id NOT IN (SELECT DISTINCT(cluster_id) FROM jobs WHERE cluster_id IS NOT NULL) LIMIT :limit", nativeQuery=true) Set<Long> findUnusedClusters(@Param("unusedStatuses") Set<String> unusedStatuses, @Param("clusterCreatedThreshold") Instant clusterCreatedThreshold, @Param("limit") int limit) Find all the clusters that aren't attached to any jobs in the database, were created before the given time and have one of the given statuses.- Parameters:
unusedStatuses- The set of statuses a cluster must have to be considered unusedclusterCreatedThreshold- The instant in time which a cluster must have been created before to be considered unused. Exclusive.limit- Maximum number of IDs to return- Returns:
- The ids of the clusters that are considered unused
-
getClusterDto
@Query("SELECT c FROM ClusterEntity c WHERE c.uniqueId = :id") @EntityGraph(value="Cluster.dto", type=LOAD) Optional<ClusterEntity> getClusterDto(@Param("id") String id) Find the cluster with the given id but also eagerly load all data needed for a cluster DTO.- Parameters:
id- The id of the command to get- Returns:
- The
ClusterEntitywith all DTO data loaded orOptional.empty()if there is no cluster with the given id
-