Class BasePersister
- java.lang.Object
-
- jetbrains.buildServer.serverSide.impl.persisting.BasePersister
-
- All Implemented Interfaces:
TasksPersister
- Direct Known Subclasses:
ProjectsPersisterImpl
,SettingsPersisterImpl
public abstract class BasePersister extends Object implements TasksPersister
-
-
Field Summary
Fields Modifier and Type Field Description protected DeadlocksDetector
myDeadlocksDetector
protected Logger
myLog
protected PersisterOptions
myOptions
protected ScheduledExecutorService
mySaveExecutor
protected ServerResponsibilityEx
myServerResponsibility
protected PersistTasksStorage
myTasksStorage
-
Constructor Summary
Constructors Modifier Constructor Description protected
BasePersister(TaskType tasksType, PersisterOptions options, ServerResponsibilityEx serverResponsibility, PersistTasksStorage tasksStorage, TasksReader tasksReader, DeadlocksDetector deadlocksDetector)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
abortTask(long taskId)
void
addTask(PersistTaskEx task)
Adds a persist task to the queue.protected boolean
canWriteToConfigDirectory()
protected void
checkShutdown()
protected void
checkWriteConfigsResponsibility()
FilesWatcher
getFilesWatcher()
protected long
getNextTaskId(String description)
protected boolean
isInsideTaskExecution()
boolean
isShutdown()
void
onServerShutdown()
protected void
processTasks(Consumer<PersistTaskEx> beforeExecuteAction, Consumer<PersistTaskEx> postExecuteAction)
protected int
runAllReadyToExecuteTasks(Consumer<PersistTaskEx> beforeExecuteAction, Consumer<PersistTaskEx> postExecuteAction)
protected PersistTaskEx
scheduleTask(PersistTaskEx task, boolean insideTaskExecution)
protected void
setFilesWatcher(FilesWatcher filesWatcher)
protected void
signalCompleteTask()
void
visitTasks(Consumer<PersistTaskEx> consumer)
boolean
waitForAllTaskRemoved(long timeout)
void
waitForTasksCompletion()
Waits for all queued tasks to complete.
-
-
-
Field Detail
-
myLog
@NotNull protected final Logger myLog
-
myOptions
@NotNull protected final PersisterOptions myOptions
-
myTasksStorage
@NotNull protected final PersistTasksStorage myTasksStorage
-
myServerResponsibility
@NotNull protected final ServerResponsibilityEx myServerResponsibility
-
mySaveExecutor
@NotNull protected final ScheduledExecutorService mySaveExecutor
-
myDeadlocksDetector
@Nullable protected final DeadlocksDetector myDeadlocksDetector
-
-
Constructor Detail
-
BasePersister
protected BasePersister(@NotNull TaskType tasksType, @NotNull PersisterOptions options, @NotNull ServerResponsibilityEx serverResponsibility, @NotNull PersistTasksStorage tasksStorage, @NotNull TasksReader tasksReader, @Nullable DeadlocksDetector deadlocksDetector)
-
-
Method Detail
-
setFilesWatcher
protected void setFilesWatcher(@Nullable FilesWatcher filesWatcher)
-
getFilesWatcher
@Nullable public FilesWatcher getFilesWatcher()
-
getNextTaskId
protected long getNextTaskId(@NotNull String description)
-
scheduleTask
@NotNull protected PersistTaskEx scheduleTask(@NotNull PersistTaskEx task, boolean insideTaskExecution)
-
addTask
public void addTask(@NotNull PersistTaskEx task)
Adds a persist task to the queue.It's important that a serializable task (that can have the stage
PersistTaskStage.TASK_WITH_METADATA_READY
) should be added with the initial stagePersistTaskStage.PREPARE
. Otherwise it can be restored from the disk and processed before this addition!- Specified by:
addTask
in interfaceTasksPersister
-
abortTask
public void abortTask(long taskId)
- Specified by:
abortTask
in interfaceTasksPersister
-
visitTasks
public void visitTasks(@NotNull Consumer<PersistTaskEx> consumer)
- Specified by:
visitTasks
in interfaceTasksPersister
-
signalCompleteTask
protected void signalCompleteTask()
-
isShutdown
public boolean isShutdown()
-
checkShutdown
protected void checkShutdown()
-
onServerShutdown
public void onServerShutdown()
- Specified by:
onServerShutdown
in interfaceTasksPersister
-
waitForTasksCompletion
public void waitForTasksCompletion()
Description copied from interface:TasksPersister
Waits for all queued tasks to complete.- Specified by:
waitForTasksCompletion
in interfaceTasksPersister
-
waitForAllTaskRemoved
public boolean waitForAllTaskRemoved(long timeout)
- Returns:
true
if all the tasks were removed,false
if finished by timeout or interrupted
-
isInsideTaskExecution
protected boolean isInsideTaskExecution()
-
canWriteToConfigDirectory
protected boolean canWriteToConfigDirectory()
-
checkWriteConfigsResponsibility
protected void checkWriteConfigsResponsibility()
-
processTasks
protected void processTasks(@Nullable Consumer<PersistTaskEx> beforeExecuteAction, @Nullable Consumer<PersistTaskEx> postExecuteAction)
-
runAllReadyToExecuteTasks
protected int runAllReadyToExecuteTasks(@Nullable Consumer<PersistTaskEx> beforeExecuteAction, @Nullable Consumer<PersistTaskEx> postExecuteAction)
-
-