Class BuildDataStorageImpl
- java.lang.Object
-
- jetbrains.buildServer.serverSide.statistics.impl.BuildDataStorageImpl
-
- All Implemented Interfaces:
AfterBuildsCleanupExtension
,BuildsCleanupExtension
,ServerExtension
,BuildDataStorage
,TeamCityExtension
public class BuildDataStorageImpl extends Object implements BuildsCleanupExtension, AfterBuildsCleanupExtension, BuildDataStorage
Performs actual storage and retrieval of build-related data
-
-
Constructor Summary
Constructors Constructor Description BuildDataStorageImpl(SQLRunnerEx sqlRunner, EventDispatcher<BuildServerListener> eventsDispatcher)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
afterCleanup(CleanupProcessState cleanupState)
Invoked upon finishing of the main cleanup process.void
cleanupBuildsData(BuildCleanupContext cleanupContext)
Invoked afterBuildsCleanupExtension.prepareBuildsData(jetbrains.buildServer.serverSide.cleanup.BuildCleanupContext)
is called for all extensions.void
clearCaches()
void
deleteValues(long promotionId, Collection<String> valueTypeKeys)
Delete published statistic values with the specified keys for the given promotionSortedSet<String>
getAgents(BuildChartSettings chartSettings)
Returns agents list for given filter settings.List<String>
getAvailableMetricsForBuildType(String buildTypeExtId)
Returns collection of available value type keys for specified build configurationBuildValue
getData(String valueTypeKey, BuildValueTransformer buildValueTransformer, long finishedBuildId, String externalBuildTypeId)
Get individual statistic value for given value type and finished buildBuildValue
getData(String valueTypeKey, BuildValueTransformer buildValueTransformer, SBuild build)
Get individual statistic value for given value type and build (finished or running)List<BuildValue>
getDataSet(String valueTypeKey, BuildChartSettings chartSettings, BuildValueTransformer buildValueTransformer)
Retrieve sorted list of values for given metric, filtered according to given settings.BigDecimal
getValue(String valueTypeKey, long buildId)
BigDecimal
getValue(String valueTypeKey, SBuild build)
Returns raw statistic value as it is stored in database for a given value type and a build.Map<Long,BigDecimal>
getValues(String valueTypeKey, Collection<SBuild> builds)
Retrives statistic values for a set of builds and returns map of build id to statistic value.Map<String,BigDecimal>
getValues(BuildPromotion promotion)
All raw values for a given build promotion.Map<String,BigDecimal>
getValues(SBuild build)
All raw values for a given build.Set<String>
getValueTypeKeys(String prefix)
Get all available ValueType keys filtering by prefixSet<String>
getValueTypeKeys(String prefix, String buildTypeExternalId)
Get all available ValueType keys for a build configuration filtering by prefixboolean
hasDataFor(String valueTypeKey, String externalBuildTypeId)
Flags whether any data was stored for given metric & buildTypeId pairboolean
hasDataFor(String valueTypeKey, SBuild build)
Flags whether any data was stored for given metric & build pairstatic String
normalizeAgentName(String string)
void
publishValue(String valueTypeKey, long promotionId, BigDecimal value)
Store single build statistic value for a build with specified idvoid
publishValues(long promotionId, Map<String,BigDecimal> statValues)
Publishes several values at once.void
publishValuesNoEvents(Map<Long,Map<String,BigDecimal>> promoId2statisticValues)
Publishes several statistic values at once for multiple promotions, but without sending events.void
setBuildsManager(BuildsManager buildsManager)
void
setBuildTypeIdentifiersManager(BuildTypeIdentifiersManager buildTypeIdentifiersManager)
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface jetbrains.buildServer.serverSide.cleanup.BuildsCleanupExtension
getCleanupBuildsDataConcurrencyLevel, getDisplayName, prepareBuildsData
-
-
-
-
Constructor Detail
-
BuildDataStorageImpl
public BuildDataStorageImpl(@NotNull SQLRunnerEx sqlRunner, @NotNull EventDispatcher<BuildServerListener> eventsDispatcher)
-
-
Method Detail
-
setBuildsManager
public void setBuildsManager(@NotNull BuildsManager buildsManager)
-
setBuildTypeIdentifiersManager
public void setBuildTypeIdentifiersManager(BuildTypeIdentifiersManager buildTypeIdentifiersManager)
-
getAvailableMetricsForBuildType
@NotNull public List<String> getAvailableMetricsForBuildType(@NotNull String buildTypeExtId)
Description copied from interface:BuildDataStorage
Returns collection of available value type keys for specified build configuration- Specified by:
getAvailableMetricsForBuildType
in interfaceBuildDataStorage
- Parameters:
buildTypeExtId
- external id of build configuration- Returns:
- see above
-
publishValue
public void publishValue(@NotNull String valueTypeKey, long promotionId, @NotNull BigDecimal value)
Description copied from interface:BuildDataStorage
Store single build statistic value for a build with specified id- Specified by:
publishValue
in interfaceBuildDataStorage
- Parameters:
valueTypeKey
- statistic value keypromotionId
- id of the build promotion (same as build ID)value
- value
-
publishValues
public void publishValues(long promotionId, @NotNull Map<String,BigDecimal> statValues)
Description copied from interface:BuildDataStorage
Publishes several values at once.- Specified by:
publishValues
in interfaceBuildDataStorage
- Parameters:
promotionId
- id of the build promotion (same as build ID)statValues
- map of statistic values to publish
-
publishValuesNoEvents
public void publishValuesNoEvents(@NotNull Map<Long,Map<String,BigDecimal>> promoId2statisticValues)
Description copied from interface:BuildDataStorage
Publishes several statistic values at once for multiple promotions, but without sending events.- Specified by:
publishValuesNoEvents
in interfaceBuildDataStorage
- Parameters:
promoId2statisticValues
- map of statistic values to publish
-
deleteValues
public void deleteValues(long promotionId, @NotNull Collection<String> valueTypeKeys)
Description copied from interface:BuildDataStorage
Delete published statistic values with the specified keys for the given promotion- Specified by:
deleteValues
in interfaceBuildDataStorage
- Parameters:
promotionId
- id of the build promotionvalueTypeKeys
- collection of the keys to be removed from the DB
-
getValueTypeKeys
@NotNull public Set<String> getValueTypeKeys(@NotNull String prefix)
Description copied from interface:BuildDataStorage
Get all available ValueType keys filtering by prefix
Will return all value types when the prefix is empty.
BuildDataStorage.getValueTypeKeys(String, String)
should be used if build type is known.- Specified by:
getValueTypeKeys
in interfaceBuildDataStorage
- Parameters:
prefix
- Prefix to search keys. Could be empty.- Returns:
- Set of all available keys starting with provided prefix.
-
getValueTypeKeys
@NotNull public Set<String> getValueTypeKeys(@NotNull String prefix, @NotNull String buildTypeExternalId)
Description copied from interface:BuildDataStorage
Get all available ValueType keys for a build configuration filtering by prefix
- Specified by:
getValueTypeKeys
in interfaceBuildDataStorage
- Parameters:
prefix
- Prefix to search keys. Could be empty.buildTypeExternalId
- external ID of a build type- Returns:
- Set of all available keys starting with provided prefix.
-
getValues
@NotNull public Map<String,BigDecimal> getValues(@NotNull BuildPromotion promotion)
Description copied from interface:BuildDataStorage
All raw values for a given build promotion. Key of the map is value type key and value is statistic value.- Specified by:
getValues
in interfaceBuildDataStorage
-
getValues
@NotNull public Map<String,BigDecimal> getValues(@NotNull SBuild build)
Description copied from interface:BuildDataStorage
All raw values for a given build. Key of the map is value type key and value is statistic value.- Specified by:
getValues
in interfaceBuildDataStorage
-
getData
@Nullable public BuildValue getData(@NotNull String valueTypeKey, BuildValueTransformer buildValueTransformer, long finishedBuildId, String externalBuildTypeId)
Description copied from interface:BuildDataStorage
Get individual statistic value for given value type and finished build- Specified by:
getData
in interfaceBuildDataStorage
- Parameters:
valueTypeKey
- metric keybuildValueTransformer
- optional transformer to be applied to the valuefinishedBuildId
- identifier of the finished buildexternalBuildTypeId
- external identifier of the build configuration- Returns:
- metric value for given parameters, null if not available
-
getData
@Nullable public BuildValue getData(@NotNull String valueTypeKey, @Nullable BuildValueTransformer buildValueTransformer, @NotNull SBuild build)
Description copied from interface:BuildDataStorage
Get individual statistic value for given value type and build (finished or running)- Specified by:
getData
in interfaceBuildDataStorage
- Parameters:
valueTypeKey
- metric keybuildValueTransformer
- optional transformer to be applied to the valuebuild
- finished or running build- Returns:
- metric value for given parameters, null if not available
-
getValue
@Nullable public BigDecimal getValue(@NotNull String valueTypeKey, long buildId)
Description copied from interface:BuildDataStorage
Same asBuildDataStorage.getValue(String, SBuild)
. Since 10.0 returns statistics only for not yet cleaned builds.- Specified by:
getValue
in interfaceBuildDataStorage
-
getValue
@Nullable public BigDecimal getValue(@NotNull String valueTypeKey, @NotNull SBuild build)
Description copied from interface:BuildDataStorage
Returns raw statistic value as it is stored in database for a given value type and a build. Note that raw value can differ from one returned byBuildDataStorage.getData(String, BuildValueTransformer, jetbrains.buildServer.serverSide.SBuild)
method because of possible transformation applied by BuildValueTransformer.- Specified by:
getValue
in interfaceBuildDataStorage
- Parameters:
valueTypeKey
- metric keybuild
- the build- Returns:
- metric value for given parameters, null if not available
-
getValues
@NotNull public Map<Long,BigDecimal> getValues(@NotNull String valueTypeKey, @NotNull Collection<SBuild> builds)
Description copied from interface:BuildDataStorage
Retrives statistic values for a set of builds and returns map of build id to statistic value.- Specified by:
getValues
in interfaceBuildDataStorage
- Returns:
- see above
-
getDataSet
@NotNull public List<BuildValue> getDataSet(@NotNull String valueTypeKey, @NotNull BuildChartSettings chartSettings, @Nullable BuildValueTransformer buildValueTransformer)
Description copied from interface:BuildDataStorage
Retrieve sorted list of values for given metric, filtered according to given settings. There will be BuildValue object for each build, even if there is no metric value for the given build.- Specified by:
getDataSet
in interfaceBuildDataStorage
- Parameters:
valueTypeKey
- metric keychartSettings
- build chart settingsbuildValueTransformer
- optional transformer to be applied to each value- Returns:
- list of metric values combined with its build data
-
getAgents
@NotNull public SortedSet<String> getAgents(@NotNull BuildChartSettings chartSettings)
Description copied from interface:BuildDataStorage
Returns agents list for given filter settings.- Specified by:
getAgents
in interfaceBuildDataStorage
- Parameters:
chartSettings
- build chart settings- Returns:
- agent names
-
hasDataFor
public boolean hasDataFor(@NotNull String valueTypeKey, String externalBuildTypeId)
Description copied from interface:BuildDataStorage
Flags whether any data was stored for given metric & buildTypeId pair- Specified by:
hasDataFor
in interfaceBuildDataStorage
- Parameters:
valueTypeKey
- metric keyexternalBuildTypeId
- build configuration external identifier- Returns:
- true if there is some data for given metric and given buildTypeId
-
hasDataFor
public boolean hasDataFor(@NotNull String valueTypeKey, @NotNull SBuild build)
Description copied from interface:BuildDataStorage
Flags whether any data was stored for given metric & build pair- Specified by:
hasDataFor
in interfaceBuildDataStorage
- Parameters:
valueTypeKey
- metric keybuild
- build to check- Returns:
- true if there is some data for given metric and given buildTypeId
-
cleanupBuildsData
public void cleanupBuildsData(@NotNull BuildCleanupContext cleanupContext)
Description copied from interface:BuildsCleanupExtension
Invoked afterBuildsCleanupExtension.prepareBuildsData(jetbrains.buildServer.serverSide.cleanup.BuildCleanupContext)
is called for all extensions. There is no guarantee about ordering of the method execution for different extensions, they may be called simultaneously etc. It should perform db operations in current thread otherwise deadlock can occur.- Specified by:
cleanupBuildsData
in interfaceBuildsCleanupExtension
- Parameters:
cleanupContext
- cleanup context
-
afterCleanup
public void afterCleanup(@NotNull CleanupProcessState cleanupState) throws CleanupInterruptedException
Description copied from interface:AfterBuildsCleanupExtension
Invoked upon finishing of the main cleanup process. At this point all data for specific builds is deleted.
Note: This extension might not be called for every cleanup run as cleanup process can be interrupted earlier. Extension must check cleanup process state and if it is interrupted, complete its operations and return as quick as possible.- Specified by:
afterCleanup
in interfaceAfterBuildsCleanupExtension
- Parameters:
cleanupState
- cleanup process state- Throws:
CleanupInterruptedException
- if the cleanup process was interrupted
-
clearCaches
public void clearCaches()
-
-