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 StringDELETED_ENTITIES_DATA_CLEANUP_TIMEOUT_PROP-
Fields inherited from interface jetbrains.buildServer.serverSide.cleanup.ServerCleanupManager
DEFAULT_CLEANUP_CRON
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedServerCleanupManagerImpl()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 booleanexecuteWithInactiveCleanup(Runnable runnable, boolean waitTillFinished)Executes specified runnable if cleanup is not running a critical section.CronSchedulergetCleanupStartCron()Returns cleanup start time cron scheduler.DategetCleanupStartTime()CleanupProcessStateExgetCleanupState()ConfigurationErrorsgetConfigErrors()Returns configuration errors object that holds such errors that make impossible the cleaning of removed projects and build configurations.intgetMaxCleanupDuration()voidinit()booleanisCleanupCanBeStarted()Returns true if cleanup can be started (ifServerCleanupManager.startCleanup()method can be invoked)booleanisCleanupEnabled()booleanisRunningCriticalSection()Determines whether the server is running a critical data modification section (like compacting the database).voidreadFrom(org.jdom.Element rootElement)Read this element data from given JDOM nodevoidrunWriteAction(Runnable writeAction)voidsetCleanupEnabled(boolean enabled)Enables or disables periodical cleanup.voidsetCleanupStartCron(String cronExpression)Sets cleanup start timevoidsetMaxCleanupDuration(int durationMins)Sets maximum allowed cleanup duration in minutes.voidsetMaxCleanupDurationSeconds(int durationSeconds)voidsetTimeService(TimeService timeService)voidstartCleanup()Starts cleanup process.voidstartCleanupAndWaitForFinish()voidstopCleanup(SUser userPerformingAction)Stops cleanup.voidwaitForCleanupTaskFinish()voidwriteTo(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:ServerCleanupManagerSets cleanup start time- Specified by:
setCleanupStartCronin 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:ServerCleanupManagerEnables 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:
setCleanupEnabledin interfaceServerCleanupManager- Parameters:
enabled- is periodical cleanup enabled
-
isCleanupEnabled
public boolean isCleanupEnabled()
- Specified by:
isCleanupEnabledin interfaceServerCleanupManager- Returns:
- true if cleanup is enabled
-
setMaxCleanupDuration
@Secured("CONFIGURE_SERVER_DATA_CLEANUP") public void setMaxCleanupDuration(int durationMins)
Description copied from interface:ServerCleanupManagerSets 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:
setMaxCleanupDurationin interfaceServerCleanupManager- Parameters:
durationMins- max cleanup duration in minutes, 0 or negative value will disable cleanup duration check
-
getMaxCleanupDuration
public int getMaxCleanupDuration()
- Specified by:
getMaxCleanupDurationin 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:ServerCleanupManagerReturns cleanup start time cron scheduler.- Specified by:
getCleanupStartCronin interfaceServerCleanupManager
-
getCleanupStartTime
@NotNull public Date getCleanupStartTime()
- Specified by:
getCleanupStartTimein interfaceServerCleanupManager
-
getCleanupState
@NotNull public CleanupProcessStateEx getCleanupState()
- Specified by:
getCleanupStatein interfaceServerCleanupManager- Returns:
- details about last (current or finished) server cleanup.
-
getConfigErrors
@NotNull public ConfigurationErrors getConfigErrors()
Description copied from interface:ServerCleanupManagerReturns configuration errors object that holds such errors that make impossible the cleaning of removed projects and build configurations.- Specified by:
getConfigErrorsin interfaceServerCleanupManager
-
setTimeService
@TestOnly public void setTimeService(@NotNull TimeService timeService)
-
isCleanupCanBeStarted
public boolean isCleanupCanBeStarted()
Description copied from interface:ServerCleanupManagerReturns true if cleanup can be started (ifServerCleanupManager.startCleanup()method can be invoked)- Specified by:
isCleanupCanBeStartedin interfaceServerCleanupManager- Returns:
- see above
-
startCleanup
@Secured("CONFIGURE_SERVER_DATA_CLEANUP") public void startCleanup() throws CleanupCannotBeStartedException
Description copied from interface:ServerCleanupManagerStarts cleanup process. The method will not return until the cleanup process is finished.- Specified by:
startCleanupin interfaceServerCleanupManager- Throws:
CleanupCannotBeStartedException
-
stopCleanup
@Secured("CONFIGURE_SERVER_DATA_CLEANUP") public void stopCleanup(@Nullable SUser userPerformingAction)
Description copied from interface:ServerCleanupManagerStops cleanup.- Specified by:
stopCleanupin interfaceServerCleanupManager- Parameters:
userPerformingAction- user who performs this action, ornullif 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:ServerCleanupManagerExecutes 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:
executeWithInactiveCleanupin 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:XmlExternalizableWrite data to the JDOM element- Specified by:
writeToin interfaceXmlExternalizable- Parameters:
parentElement- - parent element to write data to
-
readFrom
public void readFrom(@NotNull org.jdom.Element rootElement)Description copied from interface:XmlStorableRead this element data from given JDOM node- Specified by:
readFromin interfaceXmlStorable- Parameters:
rootElement- element which contains information about this storable
-
isRunningCriticalSection
public boolean isRunningCriticalSection()
Description copied from interface:ServerCleanupManagerDetermines whether the server is running a critical data modification section (like compacting the database).- Specified by:
isRunningCriticalSectionin interfaceServerCleanupManager- Returns:
- see above
- See Also:
ServerCleanupManager.executeWithInactiveCleanup(Runnable, boolean)
-
runWriteAction
public void runWriteAction(@NotNull Runnable writeAction)
-
-