Package com.bytedesk.core.server
Interface ServerRepository
- All Superinterfaces:
org.springframework.data.repository.CrudRepository<ServerEntity,
,Long> org.springframework.data.jpa.repository.JpaRepository<ServerEntity,
,Long> org.springframework.data.jpa.repository.JpaSpecificationExecutor<ServerEntity>
,org.springframework.data.repository.ListCrudRepository<ServerEntity,
,Long> org.springframework.data.repository.ListPagingAndSortingRepository<ServerEntity,
,Long> org.springframework.data.repository.PagingAndSortingRepository<ServerEntity,
,Long> org.springframework.data.repository.query.QueryByExampleExecutor<ServerEntity>
,org.springframework.data.repository.Repository<ServerEntity,
Long>
public interface ServerRepository
extends org.springframework.data.jpa.repository.JpaRepository<ServerEntity,Long>, org.springframework.data.jpa.repository.JpaSpecificationExecutor<ServerEntity>
Repository for ServerEntity
Provides database operations for server monitoring data
Note: Only super administrators can access server monitoring data
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.springframework.data.jpa.repository.JpaSpecificationExecutor
org.springframework.data.jpa.repository.JpaSpecificationExecutor.SpecificationFluentQuery<T extends Object>
-
Method Summary
Modifier and TypeMethodDescriptionlong
countByStatusAndDeletedFalse
(String status) Count servers by statuslong
Count servers by typeFind all serversfindByEnvironmentAndDeletedFalse
(String environment) Find servers by environmentfindByLocationAndDeletedFalse
(String location) Find servers by locationfindByServerNameAndDeletedFalse
(String serverName) Find server by server namefindByStatusAndDeletedFalse
(String status) Find servers by statusFind servers by typeFind server by UIDfindServersWithHighUsage
(Double cpuThreshold, Double memoryThreshold, Double diskThreshold) Find servers with high resource usagefindServersWithoutRecentHeartbeat
(ZonedDateTime cutoffTime) Find servers that haven't sent heartbeat recentlyMethods inherited from interface org.springframework.data.repository.CrudRepository
count, delete, deleteAll, deleteAll, deleteAllById, deleteById, existsById, findById, save
Methods inherited from interface org.springframework.data.jpa.repository.JpaRepository
deleteAllByIdInBatch, deleteAllInBatch, deleteAllInBatch, deleteInBatch, findAll, findAll, flush, getById, getOne, getReferenceById, saveAllAndFlush, saveAndFlush
Methods inherited from interface org.springframework.data.jpa.repository.JpaSpecificationExecutor
count, delete, exists, findAll, findAll, findAll, findAll, findBy, findOne
Methods inherited from interface org.springframework.data.repository.ListCrudRepository
findAll, findAllById, saveAll
Methods inherited from interface org.springframework.data.repository.ListPagingAndSortingRepository
findAll
Methods inherited from interface org.springframework.data.repository.PagingAndSortingRepository
findAll
Methods inherited from interface org.springframework.data.repository.query.QueryByExampleExecutor
count, exists, findAll, findBy, findOne
-
Method Details
-
findByUid
Find server by UID- Parameters:
uid
- server UID- Returns:
- Optional<ServerEntity&gt;
-
findByServerNameAndDeletedFalse
Find server by server name- Parameters:
serverName
- server name- Returns:
- Optional<ServerEntity>
-
findByDeletedFalseOrderByCreatedAtDesc
List<ServerEntity> findByDeletedFalseOrderByCreatedAtDesc()Find all servers- Returns:
- List<ServerEntity>
-
findByTypeAndDeletedFalse
Find servers by type- Parameters:
type
- server type- Returns:
- List<ServerEntity>
-
findByStatusAndDeletedFalse
Find servers by status- Parameters:
status
- server status- Returns:
- List<ServerEntity>
-
findServersWithHighUsage
@Query("SELECT s FROM ServerEntity s WHERE s.deleted = false AND (s.cpuUsage >= :cpuThreshold OR s.memoryUsage >= :memoryThreshold OR s.diskUsage >= :diskThreshold)") List<ServerEntity> findServersWithHighUsage(@Param("cpuThreshold") Double cpuThreshold, @Param("memoryThreshold") Double memoryThreshold, @Param("diskThreshold") Double diskThreshold) Find servers with high resource usage- Parameters:
cpuThreshold
- CPU usage thresholdmemoryThreshold
- memory usage thresholddiskThreshold
- disk usage threshold- Returns:
- List<ServerEntity>
-
findServersWithoutRecentHeartbeat
@Query("SELECT s FROM ServerEntity s WHERE s.deleted = false AND (s.lastHeartbeat IS NULL OR s.lastHeartbeat < :cutoffTime)") List<ServerEntity> findServersWithoutRecentHeartbeat(@Param("cutoffTime") ZonedDateTime cutoffTime) Find servers that haven't sent heartbeat recently- Parameters:
cutoffTime
- cutoff time for heartbeat- Returns:
- List<ServerEntity>
-
countByStatusAndDeletedFalse
Count servers by status- Parameters:
status
- server status- Returns:
- count
-
countByTypeAndDeletedFalse
Count servers by type- Parameters:
type
- server type- Returns:
- count
-
findByEnvironmentAndDeletedFalse
Find servers by environment- Parameters:
environment
- environment (DEV, TEST, PROD, etc.)- Returns:
- List<ServerEntity>
-
findByLocationAndDeletedFalse
Find servers by location- Parameters:
location
- server location- Returns:
- List<ServerEntity>
-