Automatically check for refs/meta/config changes
Periodically check a project's refs/meta/config for modifications made outside of Gerrit Code Review. This ensures slave servers will eventually pick up new access controls or project settings without requiring administrators to flush the "projects" cache over SSH. Checks are done only every cache.projects.checkFrequency period, as a local disk check requires at least one stat() call to examine the loose reference's last modified time. This is relatively inexpensive for a single project request like git clone, but not feasible for multiple project lookups like a query results page or user dashboard. To prevent many calls to System.currentTimeMillis() a background thread (managed by Executors.newScheduledThreadPool) is used to update a generation flag every checkFrequency period. During a cache get the ProjectState rechecks its refs/meta/config if the generation does not match, and gets replaced if there were changes. Bug: issue 962 Change-Id: I9ad4db27329968e2993b4dd142d1325446190065 Signed-off-by: Shawn O. Pearce <sop@google.com>
This commit is contained in:
@@ -31,6 +31,7 @@ import com.google.gerrit.server.AnonymousUser;
|
||||
import com.google.gerrit.server.CurrentUser;
|
||||
import com.google.gerrit.server.config.AuthConfig;
|
||||
import com.google.gerrit.server.config.GerritServerConfig;
|
||||
import com.google.gerrit.server.git.GitRepositoryManager;
|
||||
import com.google.gerrit.server.git.ProjectConfig;
|
||||
import com.google.inject.AbstractModule;
|
||||
import com.google.inject.Guice;
|
||||
@@ -316,12 +317,13 @@ public class RefControlTest extends TestCase {
|
||||
}
|
||||
};
|
||||
|
||||
GitRepositoryManager mgr = null;
|
||||
Project.NameKey wildProject = new Project.NameKey("-- All Projects --");
|
||||
ProjectControl.AssistedFactory projectControlFactory = null;
|
||||
all.put(local.getProject().getNameKey(), new ProjectState(anonymousUser,
|
||||
projectCache, wildProject, projectControlFactory, local));
|
||||
projectCache, wildProject, projectControlFactory, mgr, local));
|
||||
all.put(parent.getProject().getNameKey(), new ProjectState(anonymousUser,
|
||||
projectCache, wildProject, projectControlFactory, parent));
|
||||
projectCache, wildProject, projectControlFactory, mgr, parent));
|
||||
return all.get(local.getProject().getNameKey());
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user