Class DiskUsage
- java.lang.Object
-
- jetbrains.buildServer.serverSide.statistics.diskusage.DiskUsage
-
- All Implemented Interfaces:
DiskUsagePersister,DiskUsageViewer
public class DiskUsage extends Object implements DiskUsagePersister, DiskUsageViewer
User: Andrey Titov Date: 1/17/13Provides disk usage data. Collects usage data over artifacts and logs scanning artifact directories recursively.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classDiskUsage.BuildData
-
Field Summary
Fields Modifier and Type Field Description static StringFREE_SPACE_CALCULATOR_INCLUDE_EXTERNAL_STORAGES_PROPERTYstatic StringTC_PROPERTY_HUGE_LOG_SIZE_ALERT_LEVEL
-
Constructor Summary
Constructors Constructor Description DiskUsage(ProjectManager projectManager, ServerSettings serverSettings, DiskUsageStoreProvider diskUsageStoreProvider, FileSystemFacade fileSystemFacade, InMemoryProjectDiskUsage inMemoryProjectDiskUsage, ArtifactStorageDiskUsageInfoProvider artifactStorageDiskUsageInfoProvider, BuildHistoryEx buildHistory)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidbeforeBuildsDeletedFromHistory(List<SFinishedBuild> builds)This method should be called for builds deleted from history before their cleanup.voidbuildArtifactsCleaned(SBuildType buildType, long buildId, boolean wasPinned, boolean noArtifactsLeft, boolean allRemoved, long removedArtifacts, long removedInternalArtifacts, long removedLogs)Updates data over a build type after partial or full build cleanup.voidbuildArtifactsCleaned(SBuildType buildType, long buildId, boolean wasPinned, boolean noArtifactsLeft, boolean allRemoved, long removedArtifacts, long removedInternalArtifacts, long removedLogs, String storageId)Map<SProject,Map<String,CompositeDiskUsageData>>getAllData()longgetArtifactsDirectoryFreeSpace()The return value is usable disk spaceCompositeDiskUsageDatagetData(SBuildType bt)Disk usage data is stored in cache so it could be outdated.List<CompositeDiskUsageData>getData(SProject project)Disk usage data is stored in cache so it could be outdated.List<CompositeDiskUsageData>getDataWithSubprojects(SProject project)The method calculates disk usage data for all subproject of a given SProject including itself.longgetLastUpdateDate(SBuildType buildType)longgetLastUpdateDuration()DategetLastUpdateTime()longgetLogsDirectoryFreeSpace()The return value is usable disk spacelonggetPinnedArtifactsSize()longgetPinnedBuildsArtifactsSize(SBuildType buildType)longgetPinnedBuildsLogsSize(SBuildType buildType)longgetPinnedBuildsNumber()longgetPinnedBuildsNumber(SBuildType buildType)longgetPinnedBuildsSize(SBuildType buildType)longgetPinnedLogsSize()static longgetSizeThreshold()longgetTotalArtifactsSize()longgetTotalLogsSize()longgetVersion(SBuildType buildType)Disk usage data is stored versioned.booleanhasData(SBuildType bt)static booleanisBuildLogSizeHuge(long estimateSize)static booleanisDiskUsageEnabled()static booleanisProjectDiskUsageUsed()voidjunkDeleted(SBuildType buildType, long totalDeleted, String storageId)Decreases 'non-builds data' for buildTypeCompositeDiskUsageDatapeekData(SBuildType bt)Disk usage data is stored in cache so it could be outdated.List<CompositeDiskUsageData>peekData(SProject project)Disk usage data is stored in cache so it could be outdated.DiskUsageProjectRowpeekHierarchy(SProject rootProject)Peeks collected data for all projects.DiskUsageProjectRowpeekHierarchySingleProject(SProject rootProject)DiskUsageRowpeekRow(SBuildType bt)This method peeks collected data for a build type wrapping data objects to DiskUsageRow instances.Map<SProject,DiskUsageProjectRow>peekRows(Collection<SProject> project)This method peeks collected data for a number of projects wrapping data objects to DiskUsageProjectRow instances.List<DiskUsageRow>peekRows(SProject project)This method peeks collected data for a project wrapping data objects to DiskUsageRow instances.voidrecalculateAllData(UpdateAllProgress progress)Recalculates all data recursively going to each artifact directoryvoidrecalculateBuild(SBuild build)Recalculates a single buildCompositeDiskUsageDatarecalculateData(SBuildType bt)Recalculates a single build typevoidrecalculateProject(SProject project)voidsetLastUpdateDuration(long lastUpdateDurationMs)Sets the duration of last full scanvoidsetLastUpdateTime(Date lastUpdateTime)Sets the date of last full scanstatic OptionalLongtryParseLong(String s)voidupdateBuildPinned(SBuild build)Save disk usage data over the pinned buildvoidupdateBuildUnpinned(SBuild build)Save disk usage data over the unpinned build
-
-
-
Field Detail
-
TC_PROPERTY_HUGE_LOG_SIZE_ALERT_LEVEL
public static final String TC_PROPERTY_HUGE_LOG_SIZE_ALERT_LEVEL
- See Also:
- Constant Field Values
-
FREE_SPACE_CALCULATOR_INCLUDE_EXTERNAL_STORAGES_PROPERTY
public static final String FREE_SPACE_CALCULATOR_INCLUDE_EXTERNAL_STORAGES_PROPERTY
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
DiskUsage
public DiskUsage(@NotNull ProjectManager projectManager, @NotNull ServerSettings serverSettings, @NotNull DiskUsageStoreProvider diskUsageStoreProvider, @NotNull FileSystemFacade fileSystemFacade, @NotNull InMemoryProjectDiskUsage inMemoryProjectDiskUsage, @NotNull ArtifactStorageDiskUsageInfoProvider artifactStorageDiskUsageInfoProvider, @NotNull BuildHistoryEx buildHistory)
-
-
Method Detail
-
isBuildLogSizeHuge
public static boolean isBuildLogSizeHuge(long estimateSize)
-
getSizeThreshold
public static long getSizeThreshold()
-
isDiskUsageEnabled
public static boolean isDiskUsageEnabled()
-
getAllData
@NotNull public Map<SProject,Map<String,CompositeDiskUsageData>> getAllData()
- Returns:
- All collected data. Can run for quite long time at the first run.
-
peekRows
@NotNull public Map<SProject,DiskUsageProjectRow> peekRows(@NotNull Collection<SProject> project)
Description copied from interface:DiskUsageViewerThis method peeks collected data for a number of projects wrapping data objects to DiskUsageProjectRow instances. As peek method it doesn't recalculate missing data.
- Specified by:
peekRowsin interfaceDiskUsageViewer- Parameters:
project- projects to collect rows- Returns:
- map of packed rows.
-
peekHierarchy
@NotNull public DiskUsageProjectRow peekHierarchy(@NotNull SProject rootProject)
Description copied from interface:DiskUsageViewerPeeks collected data for all projects. Doesn't recalculate missing data
- Specified by:
peekHierarchyin interfaceDiskUsageViewer- Returns:
-
peekHierarchySingleProject
@NotNull public DiskUsageProjectRow peekHierarchySingleProject(@NotNull SProject rootProject)
- Specified by:
peekHierarchySingleProjectin interfaceDiskUsageViewer
-
isProjectDiskUsageUsed
public static boolean isProjectDiskUsageUsed()
-
recalculateAllData
public void recalculateAllData(@NotNull UpdateAllProgress progress)Recalculates all data recursively going to each artifact directory
- Specified by:
recalculateAllDatain interfaceDiskUsagePersister- Parameters:
progress- UpdateAllProgress instance that can be used to watch the progress.
-
getData
@NotNull public CompositeDiskUsageData getData(@NotNull SBuildType bt)
Disk usage data is stored in cache so it could be outdated. Use
recalculateDataorDiskUsageTaskExecutorto update values. Disk usage data will be calculated in this method if data was not collected yet. UsepeekDatato avoid blocking.- Parameters:
bt- Build type to collect disk usage data for- Returns:
- disk usage data over one BuildType
-
getData
@NotNull public List<CompositeDiskUsageData> getData(@NotNull SProject project)
Disk usage data is stored in cache so it could be outdated. Use
recalculateDataorDiskUsageTaskExecutorto update values. Disk usage data will be calculated in this method if data was not collected yet. UsepeekDatato avoid blocking.- Parameters:
project- Project to collect usage data in- Returns:
- disk usage data over all configurations in specified project
-
peekData
@NotNull public CompositeDiskUsageData peekData(@NotNull SBuildType bt)
Description copied from interface:DiskUsageViewerDisk usage data is stored in cache so it could be outdated. Use
recalculateDataorDiskUsageTaskExecutorto update values.This method doesn't calculate data when it's not available
- Specified by:
peekDatain interfaceDiskUsageViewer- Parameters:
bt- Build type to collect disk usage data for- Returns:
- disk usage data over one BuildType
-
hasData
public boolean hasData(@NotNull SBuildType bt)- Specified by:
hasDatain interfaceDiskUsagePersister- Returns:
- true if there is any saved data over provided buildType
-
peekData
@NotNull public List<CompositeDiskUsageData> peekData(@NotNull SProject project)
Description copied from interface:DiskUsageViewerDisk usage data is stored in cache so it could be outdated. Use
recalculateDataorDiskUsageTaskExecutorto update values.This method doesn't calculate data when it's not available
- Specified by:
peekDatain interfaceDiskUsageViewer- Parameters:
project- Project to collect usage data in- Returns:
- disk usage data over all configurations in specified project
-
peekRows
@NotNull public List<DiskUsageRow> peekRows(@NotNull SProject project)
Description copied from interface:DiskUsageViewerThis method peeks collected data for a project wrapping data objects to DiskUsageRow instances. As peek method it doesn't recalculate missing data.
- Specified by:
peekRowsin interfaceDiskUsageViewer- Parameters:
project- project to collect rows- Returns:
- list of packed rows.
-
peekRow
@Nullable public DiskUsageRow peekRow(@NotNull SBuildType bt)
Description copied from interface:DiskUsageViewerThis method peeks collected data for a build type wrapping data objects to DiskUsageRow instances. As peek method it doesn't recalculate missing data.
- Specified by:
peekRowin interfaceDiskUsageViewer- Parameters:
bt- build configuration to collect rows- Returns:
- packed row
-
getDataWithSubprojects
@NotNull public List<CompositeDiskUsageData> getDataWithSubprojects(@Nullable SProject project)
The method calculates disk usage data for all subproject of a given SProject including itself.
Disk usage data is stored in cache so it could be outdated. Use
recalculateDataorDiskUsageTaskExecutorto update values.- Parameters:
project- Project to collect disk usage data from. Root project will be used if null.- Returns:
- CompositeDiskUsageData instances including the ones for
projectand for all in't ancestors
-
recalculateData
@NotNull public CompositeDiskUsageData recalculateData(@NotNull SBuildType bt)
Description copied from interface:DiskUsagePersisterRecalculates a single build type
- Specified by:
recalculateDatain interfaceDiskUsagePersister- Returns:
-
buildArtifactsCleaned
public void buildArtifactsCleaned(@NotNull SBuildType buildType, long buildId, boolean wasPinned, boolean noArtifactsLeft, boolean allRemoved, long removedArtifacts, long removedInternalArtifacts, long removedLogs)Description copied from interface:DiskUsagePersisterUpdates data over a build type after partial or full build cleanup. If allRemoved is true (build is completely removed)CompositeDiskUsageData#getBuildsNumber()will be decreased. If at the same time removedArtifacts is 0 (no own artifacts removed) -CompositeDiskUsageData#getCleanedBuildsNumber()will be decreased as well. If allRemoved is false while noArtifactsLeft is true and removedArtifacts is positive (any own artifacts removed) -CompositeDiskUsageData#getCleanedBuildsNumber()will be increased. If wasPinned is true - pinned sizes will be decreased. If allRemoved is true at the same time - the build will be removed from pinned builds list.- Specified by:
buildArtifactsCleanedin interfaceDiskUsagePersisternoArtifactsLeft- should be true if build is removed completely (the whole build artifacts directory is removed)allRemoved- should be true if no artifacts left (internal artifacts don't matter)
-
buildArtifactsCleaned
public void buildArtifactsCleaned(@NotNull SBuildType buildType, long buildId, boolean wasPinned, boolean noArtifactsLeft, boolean allRemoved, long removedArtifacts, long removedInternalArtifacts, long removedLogs, @NotNull String storageId)- Specified by:
buildArtifactsCleanedin interfaceDiskUsagePersister
-
beforeBuildsDeletedFromHistory
public void beforeBuildsDeletedFromHistory(List<SFinishedBuild> builds)
Description copied from interface:DiskUsagePersisterThis method should be called for builds deleted from history before their cleanup. Pinned builds will be marked as unpinned, builds will be removed from top builds list, total log size and artifacts size would be moved to 'non-builds data'.
- Specified by:
beforeBuildsDeletedFromHistoryin interfaceDiskUsagePersister- Parameters:
builds- Cleaned builds
-
junkDeleted
public void junkDeleted(@NotNull SBuildType buildType, long totalDeleted, @NotNull String storageId)Description copied from interface:DiskUsagePersisterDecreases 'non-builds data' for buildType
- Specified by:
junkDeletedin interfaceDiskUsagePersister- Parameters:
buildType- Build type where junk was cleanedtotalDeleted- Size of cleaned junk
-
recalculateBuild
public void recalculateBuild(@NotNull SBuild build)Description copied from interface:DiskUsagePersisterRecalculates a single build
- Specified by:
recalculateBuildin interfaceDiskUsagePersister
-
getVersion
public long getVersion(@Nullable SBuildType buildType)Description copied from interface:DiskUsagePersisterDisk usage data is stored versioned. 0 means data was not collected yet.
- Specified by:
getVersionin interfaceDiskUsagePersister- Specified by:
getVersionin interfaceDiskUsageViewer- Returns:
- version
-
getLastUpdateDate
public long getLastUpdateDate(@Nullable SBuildType buildType)- Specified by:
getLastUpdateDatein interfaceDiskUsageViewer
-
getArtifactsDirectoryFreeSpace
public long getArtifactsDirectoryFreeSpace()
Description copied from interface:DiskUsageViewerThe return value is usable disk space
- Specified by:
getArtifactsDirectoryFreeSpacein interfaceDiskUsageViewer- Returns:
- free disk space in artifacts directory or
ArtifactStorageDiskUsageCalculator.UNLIMITED_SPACEif the space is not limited
-
getLogsDirectoryFreeSpace
public long getLogsDirectoryFreeSpace()
Description copied from interface:DiskUsageViewerThe return value is usable disk space
- Specified by:
getLogsDirectoryFreeSpacein interfaceDiskUsageViewer- Returns:
- free disk space in logs directory or
ArtifactStorageDiskUsageCalculator.UNLIMITED_SPACEif the space is not limited
-
getPinnedBuildsNumber
public long getPinnedBuildsNumber()
- Specified by:
getPinnedBuildsNumberin interfaceDiskUsageViewer- Returns:
- number of found pinned builds
-
getPinnedArtifactsSize
public long getPinnedArtifactsSize()
- Specified by:
getPinnedArtifactsSizein interfaceDiskUsageViewer- Returns:
- size of all artifacts in found pinned builds
-
getPinnedLogsSize
public long getPinnedLogsSize()
- Specified by:
getPinnedLogsSizein interfaceDiskUsageViewer- Returns:
- size of all logs in found pinned builds
-
getPinnedBuildsNumber
public long getPinnedBuildsNumber(@NotNull SBuildType buildType)- Specified by:
getPinnedBuildsNumberin interfaceDiskUsageViewer- Returns:
- number of found pinned builds in specified BuildType
-
getPinnedBuildsSize
public long getPinnedBuildsSize(@NotNull SBuildType buildType)- Specified by:
getPinnedBuildsSizein interfaceDiskUsageViewer- Returns:
- total size of artifacts and logs in found pinned builds of specified BuildType
-
getPinnedBuildsArtifactsSize
public long getPinnedBuildsArtifactsSize(@NotNull SBuildType buildType)- Specified by:
getPinnedBuildsArtifactsSizein interfaceDiskUsageViewer- Returns:
- total size of artifacts in found pinned builds of specified BuildType
-
getPinnedBuildsLogsSize
public long getPinnedBuildsLogsSize(@NotNull SBuildType buildType)- Specified by:
getPinnedBuildsLogsSizein interfaceDiskUsageViewer- Returns:
- total size of logs in found pinned builds of specified BuildType
-
getTotalArtifactsSize
public long getTotalArtifactsSize()
- Specified by:
getTotalArtifactsSizein interfaceDiskUsageViewer- Returns:
- size of all found artifacts
-
getTotalLogsSize
public long getTotalLogsSize()
- Specified by:
getTotalLogsSizein interfaceDiskUsageViewer- Returns:
- size of all found logs
-
getLastUpdateTime
@Nullable public Date getLastUpdateTime()
- Specified by:
getLastUpdateTimein interfaceDiskUsageViewer- Returns:
- last full scan date
-
setLastUpdateTime
public void setLastUpdateTime(@Nullable Date lastUpdateTime)Description copied from interface:DiskUsagePersisterSets the date of last full scan
- Specified by:
setLastUpdateTimein interfaceDiskUsagePersister
-
getLastUpdateDuration
public long getLastUpdateDuration()
- Specified by:
getLastUpdateDurationin interfaceDiskUsageViewer- Returns:
- last full scan duration
-
setLastUpdateDuration
public void setLastUpdateDuration(long lastUpdateDurationMs)
Description copied from interface:DiskUsagePersisterSets the duration of last full scan
- Specified by:
setLastUpdateDurationin interfaceDiskUsagePersister
-
updateBuildPinned
public void updateBuildPinned(@NotNull SBuild build)Description copied from interface:DiskUsagePersisterSave disk usage data over the pinned build
- Specified by:
updateBuildPinnedin interfaceDiskUsagePersister
-
updateBuildUnpinned
public void updateBuildUnpinned(@NotNull SBuild build)Description copied from interface:DiskUsagePersisterSave disk usage data over the unpinned build
- Specified by:
updateBuildUnpinnedin interfaceDiskUsagePersister
-
recalculateProject
public void recalculateProject(@NotNull SProject project)- Specified by:
recalculateProjectin interfaceDiskUsagePersister
-
tryParseLong
public static OptionalLong tryParseLong(@NotNull String s)
-
-