in git-server-tc/src/main/java/jetbrains/buildServer/buildTriggers/vcs/git/GitClonesUpdater.java [28:79]
public GitClonesUpdater(@NotNull EventDispatcher<RepositoryStateListener> eventDispatcher,
@NotNull EventDispatcher<BuildServerListener> serverEventDispatcher,
@NotNull ServerResponsibility serverResponsibility,
@NotNull GitVcsSupport gitVcsSupport,
@NotNull RepositoryManager repositoryManager) {
myVcs = gitVcsSupport;
myRepositoryManager = repositoryManager;
eventDispatcher.addListener(new RepositoryStateListenerAdapter() {
@Override
public void repositoryStateChanged(@NotNull final VcsRoot root,
@NotNull final RepositoryState oldState,
@NotNull final RepositoryState newState) {
if (serverResponsibility.canCheckForChanges() && CurrentNodeInfo.getNodeId().equals(newState.getLastUpdatedBy())) return;
if (!TeamCityProperties.getBooleanOrTrue("teamcity.git.localClones.updateIfNoCheckingForChangesResponsibility")) return;
if (root.getVcsName().equals(Constants.VCS_NAME)) {
if (myScheduledForUpdate.size() > TeamCityProperties.getInteger("teamcity.git.localClones.maxScheduledUpdates", 1000) && !myScheduledForUpdate.containsKey(root)) {
Loggers.VCS.warn("Cannot schedule update of the local clone for: " + LogUtil.describe(root) + " because the number of already scheduled updates is too big");
return;
}
myScheduledForUpdate.put(root, RepositoryStateFactory.toData(newState));
synchronized (myScheduledForUpdate) {
if (myExecutor == null) {
myExecutor = ExecutorsFactory.newFixedDaemonExecutor("Git local clones updater",
TeamCityProperties.getInteger("teamcity.git.localClones.maxParallelUpdateThreads", 2),
TeamCityProperties.getInteger("teamcity.git.localClones.maxPoolSize", 2),
TeamCityProperties.getInteger("teamcity.git.localClones.maxQueueSize", 5));
}
}
if (myExecutor.isShutdown()) return;
try {
myExecutor.submit(GitClonesUpdater.this::processVcsRootsScheduledForUpdate);
} catch (RejectedExecutionException ignored) {
//if the exception occured it means there are already submitted tasks which will process our change, so we can ignore this exception
}
}
}
});
serverEventDispatcher.addListener(new BuildServerAdapter() {
@Override
public void serverShutdown() {
if (myExecutor != null) {
ThreadUtil.shutdownGracefully(myExecutor, "Git local clones updater");
}
}
});
}