Class ServerCleanupManagerImpl
- java.lang.Object
-
- jetbrains.buildServer.serverSide.impl.cleanup.ServerCleanupManagerImpl
-
- All Implemented Interfaces:
ServerCleanupManager
,MainConfigProcessor
,ServerExtension
,TeamCityExtension
,XmlExternalizable
,XmlStorable
public class ServerCleanupManagerImpl extends Object implements ServerCleanupManager, MainConfigProcessor
-
-
Field Summary
Fields Modifier and Type Field Description static String
DELETED_ENTITIES_DATA_CLEANUP_TIMEOUT_PROP
-
Fields inherited from interface jetbrains.buildServer.serverSide.cleanup.ServerCleanupManager
DEFAULT_CLEANUP_CRON
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
ServerCleanupManagerImpl()
ServerCleanupManagerImpl(EventDispatcher<BuildServerListener> dispatcher, ConfigurationErrors configErrors, MaintenanceLock maintenanceLock, CleanupHistoryManager cleanupHistoryManager, AuditLogFactory auditLogFactory, CustomDataStorageManager customDataStorageManager, ExecutorServicesEx executorServices, MultiNodesEvents multiNodesEvents, MultiNodeTasks multiNodeTasks, ServerResponsibility serverResponsibility, CleanupProcessCreator cleanupProcessCreator, UserModel userModel)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
executeWithInactiveCleanup(Runnable runnable, boolean waitTillFinished)
Executes specified runnable if cleanup is not running a critical section.CronScheduler
getCleanupStartCron()
Returns cleanup start time cron scheduler.Date
getCleanupStartTime()
CleanupProcessStateEx
getCleanupState()
ConfigurationErrors
getConfigErrors()
Returns configuration errors object that holds such errors that make impossible the cleaning of removed projects and build configurations.int
getMaxCleanupDuration()
void
init()
boolean
isCleanupCanBeStarted()
Returns true if cleanup can be started (ifServerCleanupManager.startCleanup()
method can be invoked)boolean
isCleanupEnabled()
boolean
isRunningCriticalSection()
Determines whether the server is running a critical data modification section (like compacting the database).void
readFrom(org.jdom.Element rootElement)
Read this element data from given JDOM nodevoid
runWriteAction(Runnable writeAction)
void
setCleanupEnabled(boolean enabled)
Enables or disables periodical cleanup.void
setCleanupStartCron(String cronExpression)
Sets cleanup start timevoid
setMaxCleanupDuration(int durationMins)
Sets maximum allowed cleanup duration in minutes.void
setMaxCleanupDurationSeconds(int durationSeconds)
void
setTimeService(TimeService timeService)
void
startCleanup()
Starts cleanup process.void
startCleanupAndWaitForFinish()
void
stopCleanup(SUser userPerformingAction)
Stops cleanup.void
waitForCleanupTaskFinish()
void
writeTo(org.jdom.Element parentElement)
Write data to the JDOM element
-
-
-
Field Detail
-
DELETED_ENTITIES_DATA_CLEANUP_TIMEOUT_PROP
public static final String DELETED_ENTITIES_DATA_CLEANUP_TIMEOUT_PROP
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
ServerCleanupManagerImpl
protected ServerCleanupManagerImpl()
-
ServerCleanupManagerImpl
@Autowired public ServerCleanupManagerImpl(@NotNull EventDispatcher<BuildServerListener> dispatcher, @NotNull ConfigurationErrors configErrors, @NotNull MaintenanceLock maintenanceLock, @NotNull CleanupHistoryManager cleanupHistoryManager, @NotNull AuditLogFactory auditLogFactory, @NotNull CustomDataStorageManager customDataStorageManager, @NotNull ExecutorServicesEx executorServices, @NotNull MultiNodesEvents multiNodesEvents, @NotNull MultiNodeTasks multiNodeTasks, @NotNull ServerResponsibility serverResponsibility, @NotNull CleanupProcessCreator cleanupProcessCreator, @NotNull UserModel userModel)
-
-
Method Detail
-
init
public void init()
-
setCleanupStartCron
@Secured("CONFIGURE_SERVER_DATA_CLEANUP") public void setCleanupStartCron(@NotNull String cronExpression) throws CronParseException
Description copied from interface:ServerCleanupManager
Sets cleanup start time- Specified by:
setCleanupStartCron
in interfaceServerCleanupManager
- Parameters:
cronExpression
- cleanup start time cron expression- Throws:
CronParseException
-
setCleanupEnabled
@Secured("CONFIGURE_SERVER_DATA_CLEANUP") public void setCleanupEnabled(boolean enabled)
Description copied from interface:ServerCleanupManager
Enables or disables periodical cleanup. If enabled, cleanup will start at specified start time. If start time is not specified, cleanup will start at 03:00- Specified by:
setCleanupEnabled
in interfaceServerCleanupManager
- Parameters:
enabled
- is periodical cleanup enabled
-
isCleanupEnabled
public boolean isCleanupEnabled()
- Specified by:
isCleanupEnabled
in interfaceServerCleanupManager
- Returns:
- true if cleanup is enabled
-
setMaxCleanupDuration
@Secured("CONFIGURE_SERVER_DATA_CLEANUP") public void setMaxCleanupDuration(int durationMins)
Description copied from interface:ServerCleanupManager
Sets maximum allowed cleanup duration in minutes. Note that in fact cleanup can take a bit more time than specified in this setting, this is because cleanup operation can't be interrupted at any time.- Specified by:
setMaxCleanupDuration
in interfaceServerCleanupManager
- Parameters:
durationMins
- max cleanup duration in minutes, 0 or negative value will disable cleanup duration check
-
getMaxCleanupDuration
public int getMaxCleanupDuration()
- Specified by:
getMaxCleanupDuration
in interfaceServerCleanupManager
- Returns:
- max cleanup duration in minutes
-
setMaxCleanupDurationSeconds
@TestOnly @Secured("CONFIGURE_SERVER_DATA_CLEANUP") public void setMaxCleanupDurationSeconds(int durationSeconds)
-
getCleanupStartCron
@NotNull public CronScheduler getCleanupStartCron()
Description copied from interface:ServerCleanupManager
Returns cleanup start time cron scheduler.- Specified by:
getCleanupStartCron
in interfaceServerCleanupManager
-
getCleanupStartTime
@NotNull public Date getCleanupStartTime()
- Specified by:
getCleanupStartTime
in interfaceServerCleanupManager
-
getCleanupState
@NotNull public CleanupProcessStateEx getCleanupState()
- Specified by:
getCleanupState
in interfaceServerCleanupManager
- Returns:
- details about last (current or finished) server cleanup.
-
getConfigErrors
@NotNull public ConfigurationErrors getConfigErrors()
Description copied from interface:ServerCleanupManager
Returns configuration errors object that holds such errors that make impossible the cleaning of removed projects and build configurations.- Specified by:
getConfigErrors
in interfaceServerCleanupManager
-
setTimeService
@TestOnly public void setTimeService(@NotNull TimeService timeService)
-
isCleanupCanBeStarted
public boolean isCleanupCanBeStarted()
Description copied from interface:ServerCleanupManager
Returns true if cleanup can be started (ifServerCleanupManager.startCleanup()
method can be invoked)- Specified by:
isCleanupCanBeStarted
in interfaceServerCleanupManager
- Returns:
- see above
-
startCleanup
@Secured("CONFIGURE_SERVER_DATA_CLEANUP") public void startCleanup() throws CleanupCannotBeStartedException
Description copied from interface:ServerCleanupManager
Starts cleanup process. The method will not return until the cleanup process is finished.- Specified by:
startCleanup
in interfaceServerCleanupManager
- Throws:
CleanupCannotBeStartedException
-
stopCleanup
@Secured("CONFIGURE_SERVER_DATA_CLEANUP") public void stopCleanup(@Nullable SUser userPerformingAction)
Description copied from interface:ServerCleanupManager
Stops cleanup.- Specified by:
stopCleanup
in interfaceServerCleanupManager
- Parameters:
userPerformingAction
- user who performs this action, ornull
if action is performed by system
-
waitForCleanupTaskFinish
public void waitForCleanupTaskFinish() throws InterruptedException
- Throws:
InterruptedException
-
startCleanupAndWaitForFinish
public void startCleanupAndWaitForFinish() throws InterruptedException, CleanupCannotBeStartedException
-
executeWithInactiveCleanup
public boolean executeWithInactiveCleanup(@NotNull Runnable runnable, boolean waitTillFinished)
Description copied from interface:ServerCleanupManager
Executes specified runnable if cleanup is not running a critical section. Cleanup will not start a critical data modification section while runnable is executing. If parameter waitTillFinished is true the method will wait till cleanup is finished.- Specified by:
executeWithInactiveCleanup
in interfaceServerCleanupManager
- Parameters:
runnable
- runnable to executewaitTillFinished
- true to wait till cleanup finishes- Returns:
- true if runnable was executed
-
writeTo
public void writeTo(@NotNull org.jdom.Element parentElement)
Description copied from interface:XmlExternalizable
Write data to the JDOM element- Specified by:
writeTo
in interfaceXmlExternalizable
- Parameters:
parentElement
- - parent element to write data to
-
readFrom
public void readFrom(@NotNull org.jdom.Element rootElement)
Description copied from interface:XmlStorable
Read this element data from given JDOM node- Specified by:
readFrom
in interfaceXmlStorable
- Parameters:
rootElement
- element which contains information about this storable
-
isRunningCriticalSection
public boolean isRunningCriticalSection()
Description copied from interface:ServerCleanupManager
Determines whether the server is running a critical data modification section (like compacting the database).- Specified by:
isRunningCriticalSection
in interfaceServerCleanupManager
- Returns:
- see above
- See Also:
ServerCleanupManager.executeWithInactiveCleanup(Runnable, boolean)
-
runWriteAction
public void runWriteAction(@NotNull Runnable writeAction)
-
-