Package sonia.scm.repository.work
Class SimpleCachingWorkingCopyPool
java.lang.Object
sonia.scm.repository.work.SimpleCachingWorkingCopyPool
- All Implemented Interfaces:
WorkingCopyPool
This class is a simple implementation of the
The usage of this pool has to be enabled by setting the system property `scm.workingCopyPoolStrategy` to 'sonia.scm.repository.work.SimpleCachingWorkingCopyPool'.
In general, this implementation should speed up modifications inside SCM-Manager performed by the editor plugin or the review plugin, but one has to take into account, that the space needed for repositories is multiplied. So you have to make sure, that there is enough space for clones of the repository.
Possible enhancements:
WorkingCopyPool
to demonstrate,
how caching can work in an LRU style. For the first time a WorkingCopy
is
requested for a repository with getWorkingCopy(SimpleWorkingCopyFactory.WorkingCopyContext)
,
this implementation fetches a new directory from the WorkdirProvider
.
On contextClosed(SimpleWorkingCopyFactory.WorkingCopyContext, File)
,
the directory is not deleted, but put into a cache with the repository id as key.
When a working copy is requested with getWorkingCopy(SimpleWorkingCopyFactory.WorkingCopyContext)
for a repository with such an existing directory, it is taken from the map, reclaimed and
returned as WorkingCopy
.
If for one repository a working copy is requested, while another is in use already,
the process will wait until the other process has finished.
The number of directories cached is limited. By default, directories are cached for
repositories. This can be changes with the system
property '' (if this is set to zero, no caching will
take place; to cache the directories for each repository without eviction simply set this to a
high enough value).
The usage of this pool has to be enabled by setting the system property `scm.workingCopyPoolStrategy` to 'sonia.scm.repository.work.SimpleCachingWorkingCopyPool'.
In general, this implementation should speed up modifications inside SCM-Manager performed by the editor plugin or the review plugin, but one has to take into account, that the space needed for repositories is multiplied. So you have to make sure, that there is enough space for clones of the repository.
Possible enhancements:
- Monitoring of times
- Allow multiple cached directories for busy repositories (possibly taking initial branches into account)
- Measure allocated disk space and set a limit
- Remove directories not used for a longer time
- Wait for a cached directory on parallel requests
-
Constructor Summary
ConstructorsConstructorDescriptionSimpleCachingWorkingCopyPool
(Integer workingCopyPoolSize, WorkdirProvider workdirProvider, io.micrometer.core.instrument.MeterRegistry meterRegistry) -
Method Summary
Modifier and TypeMethodDescriptionvoid
contextClosed
(SimpleWorkingCopyFactory<?, ?, ?>.WorkingCopyContext workingCopyContext, File workdir) <R,
W> WorkingCopy<R, W> getWorkingCopy
(SimpleWorkingCopyFactory<R, W, ?>.WorkingCopyContext context) void
shutdown()
-
Constructor Details
-
SimpleCachingWorkingCopyPool
@Inject public SimpleCachingWorkingCopyPool(@ConfigValue(key="workingCopyPoolSize",defaultValue="5",description="Amount of cached working copies") Integer workingCopyPoolSize, WorkdirProvider workdirProvider, io.micrometer.core.instrument.MeterRegistry meterRegistry)
-
-
Method Details
-
getWorkingCopy
public <R,W> WorkingCopy<R,W> getWorkingCopy(SimpleWorkingCopyFactory<R, W, ?>.WorkingCopyContext context) - Specified by:
getWorkingCopy
in interfaceWorkingCopyPool
-
contextClosed
public void contextClosed(SimpleWorkingCopyFactory<?, ?, ?>.WorkingCopyContext workingCopyContext, File workdir) - Specified by:
contextClosed
in interfaceWorkingCopyPool
-
shutdown
public void shutdown()- Specified by:
shutdown
in interfaceWorkingCopyPool
-