Class DiskMonitor
java.lang.Object
org.craftercms.studio.impl.v2.monitor.DiskMonitor
- All Implemented Interfaces:
org.springframework.beans.factory.InitializingBean
public class DiskMonitor
extends Object
implements org.springframework.beans.factory.InitializingBean
Job for monitoring disk usage.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionDiskMonitor(RepositoryCleanupJob gitGCJob, StudioNotificationSender notificationSender, SystemStatusProvider systemStatusProvider, String baseRepoPath, int lowWaterMark, int highWaterMark) -
Method Summary
Modifier and TypeMethodDescriptionvoidprotected voidCalculates the current disk status based on the disk usage.voidprotected org.craftercms.commons.monitoring.DiskInfoGets the current disk information based on the configured repository base path.protected Stringprotected DiskStatusnoPreviousAlarmStatus(org.craftercms.commons.monitoring.DiskInfo newDiskInfo, int lowWaterMark, int highWaterMark) Handles the case where there was no previous alarm status.protected DiskStatuspreviousAlarmStatus(org.craftercms.commons.monitoring.DiskInfo newDiskInfo, DiskStatus previousStatus, int lowWaterMark, int highWaterMark) Handles the case where the previous disk status was an alarm.protected void
-
Field Details
-
diskStatus
-
-
Constructor Details
-
DiskMonitor
@ConstructorProperties({"gitGCJob","notificationSender","systemStatusProvider","baseRepoPath","lowWaterMark","highWaterMark"}) public DiskMonitor(RepositoryCleanupJob gitGCJob, StudioNotificationSender notificationSender, SystemStatusProvider systemStatusProvider, String baseRepoPath, int lowWaterMark, int highWaterMark)
-
-
Method Details
-
afterPropertiesSet
public void afterPropertiesSet()- Specified by:
afterPropertiesSetin interfaceorg.springframework.beans.factory.InitializingBean
-
checkDiskUsage
public void checkDiskUsage() -
getServerName
- Throws:
UnknownHostException
-
sendAlarm
protected void sendAlarm() -
calculateDiskStatus
protected void calculateDiskStatus()Calculates the current disk status based on the disk usage. -
noPreviousAlarmStatus
protected DiskStatus noPreviousAlarmStatus(org.craftercms.commons.monitoring.DiskInfo newDiskInfo, int lowWaterMark, int highWaterMark) Handles the case where there was no previous alarm status. Checks the current disk usage and if above the high watermark, it triggers the git gc on all repositories.- Parameters:
newDiskInfo- the new disk informationlowWaterMark- the low watermark percentagehighWaterMark- the high watermark percentage- Returns:
- a new DiskStatus object with the updated disk information and alarm state
-
getDiskInfo
protected org.craftercms.commons.monitoring.DiskInfo getDiskInfo()Gets the current disk information based on the configured repository base path.- Returns:
- a DiskInfo object containing the disk usage information
-
previousAlarmStatus
protected DiskStatus previousAlarmStatus(org.craftercms.commons.monitoring.DiskInfo newDiskInfo, DiskStatus previousStatus, int lowWaterMark, int highWaterMark) Handles the case where the previous disk status was an alarm. Checks the current disk usage and if still above the low watermark, it keeps the alarm state.- Parameters:
newDiskInfo- the new disk informationpreviousStatus- the previous disk statuslowWaterMark- the low watermark percentagehighWaterMark- the high watermark percentage- Returns:
- a new DiskStatus object with the updated disk information and alarm state
-
getDiskStatus
-