Package com.google.gerrit.server.project
Class ProjectCacheImpl
- java.lang.Object
-
- com.google.gerrit.server.project.ProjectCacheImpl
-
- All Implemented Interfaces:
ProjectCache
public class ProjectCacheImpl extends Object implements ProjectCache
Cache of project information, including access rights.
-
-
Field Summary
Fields Modifier and Type Field Description static String
CACHE_NAME
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description com.google.common.collect.ImmutableSortedSet<Project.NameKey>
all()
com.google.common.collect.ImmutableSortedSet<Project.NameKey>
byName(String pfx)
Filter the set of registered project names by common prefix.ProjectState
checkedGet(Project.NameKey projectName)
Get the cached data for a project by its unique name.ProjectState
checkedGet(Project.NameKey projectName, boolean strict)
Get the cached data for a project by its unique name.void
evict(Project p)
Invalidate the cached information about the given project, and triggers reindexing for itvoid
evict(Project.NameKey p)
Invalidate the cached information about the given project, and triggers reindexing for itvoid
evictAllByName()
ProjectState
get(Project.NameKey projectName)
Get the cached data for a project by its unique name.ProjectState
getAllProjects()
ProjectState
getAllUsers()
Set<AccountGroup.UUID>
guessRelevantGroupUUIDs()
static com.google.inject.Module
module()
void
onCreateProject(Project.NameKey newProjectName)
Notify the cache that a new project was constructed.void
remove(Project p)
Remove information about the given project from the cache.void
remove(Project.NameKey name)
Remove information about the given project from the cache.long
sizeAllByName()
-
-
-
Field Detail
-
CACHE_NAME
public static final String CACHE_NAME
- See Also:
- Constant Field Values
-
-
Method Detail
-
module
public static com.google.inject.Module module()
-
getAllProjects
public ProjectState getAllProjects()
- Specified by:
getAllProjects
in interfaceProjectCache
- Returns:
- the parent state for all projects on this server.
-
getAllUsers
public ProjectState getAllUsers()
- Specified by:
getAllUsers
in interfaceProjectCache
- Returns:
- the project state of the project storing meta data for all users.
-
get
public ProjectState get(Project.NameKey projectName)
Description copied from interface:ProjectCache
Get the cached data for a project by its unique name.- Specified by:
get
in interfaceProjectCache
- Parameters:
projectName
- name of the project.- Returns:
- the cached data; null if no such project exists, projectName is null or an error occurred.
- See Also:
ProjectCache.checkedGet(com.google.gerrit.reviewdb.client.Project.NameKey)
-
checkedGet
public ProjectState checkedGet(Project.NameKey projectName) throws IOException
Description copied from interface:ProjectCache
Get the cached data for a project by its unique name.- Specified by:
checkedGet
in interfaceProjectCache
- Parameters:
projectName
- name of the project.- Returns:
- the cached data; null if no such project exists or projectName is null.
- Throws:
IOException
- when there was an error.
-
checkedGet
public ProjectState checkedGet(Project.NameKey projectName, boolean strict) throws Exception
Description copied from interface:ProjectCache
Get the cached data for a project by its unique name.- Specified by:
checkedGet
in interfaceProjectCache
- Parameters:
projectName
- name of the project.strict
- true when any error generates an exception- Returns:
- the cached data or null when strict = false
- Throws:
Exception
- in case of any error (strict = true) or only for I/O or other internal errors.
-
evict
public void evict(Project p)
Description copied from interface:ProjectCache
Invalidate the cached information about the given project, and triggers reindexing for it- Specified by:
evict
in interfaceProjectCache
- Parameters:
p
- project that is being evicted
-
evict
public void evict(Project.NameKey p)
Description copied from interface:ProjectCache
Invalidate the cached information about the given project, and triggers reindexing for it- Specified by:
evict
in interfaceProjectCache
- Parameters:
p
- the NameKey of the project that is being evicted
-
remove
public void remove(Project p)
Description copied from interface:ProjectCache
Remove information about the given project from the cache. It will no longer be returned fromProjectCache.all()
.- Specified by:
remove
in interfaceProjectCache
-
remove
public void remove(Project.NameKey name)
Description copied from interface:ProjectCache
Remove information about the given project from the cache. It will no longer be returned fromProjectCache.all()
.- Specified by:
remove
in interfaceProjectCache
-
onCreateProject
public void onCreateProject(Project.NameKey newProjectName) throws IOException
Description copied from interface:ProjectCache
Notify the cache that a new project was constructed.- Specified by:
onCreateProject
in interfaceProjectCache
- Throws:
IOException
-
all
public com.google.common.collect.ImmutableSortedSet<Project.NameKey> all()
- Specified by:
all
in interfaceProjectCache
- Returns:
- sorted iteration of projects.
-
guessRelevantGroupUUIDs
public Set<AccountGroup.UUID> guessRelevantGroupUUIDs()
- Specified by:
guessRelevantGroupUUIDs
in interfaceProjectCache
- Returns:
- estimated set of relevant groups extracted from hot project access rules. If the cache is cold or too small for the entire project set of the server, this set may be incomplete.
-
byName
public com.google.common.collect.ImmutableSortedSet<Project.NameKey> byName(String pfx)
Description copied from interface:ProjectCache
Filter the set of registered project names by common prefix.- Specified by:
byName
in interfaceProjectCache
- Parameters:
pfx
- common prefix.- Returns:
- sorted iteration of projects sharing the same prefix.
-
evictAllByName
public void evictAllByName()
-
sizeAllByName
public long sizeAllByName()
-
-