use of com.google.gerrit.server.cache.CacheModule in project gerrit by GerritCodeReview.
the class HttpPluginModule method configureServlets.
@Override
protected void configureServlets() {
bind(HttpPluginServlet.class);
serveRegex("^/(?:a/)?plugins/(.*)?$").with(HttpPluginServlet.class);
bind(LfsPluginServlet.class);
serveRegex(LfsDefinitions.LFS_URL_REGEX).with(LfsPluginServlet.class);
bind(StartPluginListener.class).annotatedWith(UniqueAnnotations.create()).to(HttpPluginServlet.class);
bind(ReloadPluginListener.class).annotatedWith(UniqueAnnotations.create()).to(HttpPluginServlet.class);
bind(StartPluginListener.class).annotatedWith(UniqueAnnotations.create()).to(LfsPluginServlet.class);
bind(ReloadPluginListener.class).annotatedWith(UniqueAnnotations.create()).to(LfsPluginServlet.class);
bind(ModuleGenerator.class).to(HttpAutoRegisterModuleGenerator.class);
install(new CacheModule() {
@Override
protected void configure() {
cache(PLUGIN_RESOURCES, ResourceKey.class, Resource.class).maximumWeight(2 << 20).weigher(ResourceWeigher.class);
}
});
}
use of com.google.gerrit.server.cache.CacheModule in project gerrit by GerritCodeReview.
the class LdapRealmTest method setUpInjector.
@Before
public void setUpInjector() throws Exception {
Injector injector = Guice.createInjector(new InMemoryModule(), new CacheModule() {
@Override
protected void configure() {
cache(GROUP_CACHE, String.class, new TypeLiteral<Set<AccountGroup.UUID>>() {
}).loader(LdapRealm.MemberLoader.class);
cache(USERNAME_CACHE, String.class, new TypeLiteral<Optional<Account.Id>>() {
}).loader(LdapRealm.UserLoader.class);
cache(GROUP_EXIST_CACHE, String.class, new TypeLiteral<Boolean>() {
}).loader(LdapRealm.ExistenceLoader.class);
cache(PARENT_GROUPS_CACHE, String.class, new TypeLiteral<ImmutableSet<String>>() {
});
}
});
injector.injectMembers(this);
}
use of com.google.gerrit.server.cache.CacheModule in project gerrit by GerritCodeReview.
the class ProjectCacheImpl method module.
public static Module module() {
return new CacheModule() {
@Override
protected void configure() {
// We split the project cache into two parts for performance reasons:
// 1) An in-memory part that has only the project name as key.
// 2) A persisted part that has the name and revision as key.
//
// When loading dashboards or returning change query results we potentially
// need to access hundreds of projects because each change could originate in
// a different project and, through inheritance, require us to check even more
// projects when evaluating permissions. It's not feasible to read the revision
// of refs/meta/config from each of these repos as that would require opening
// them all and reading their ref list or table.
// At the same time, we want the persisted cache to be immutable and we want it
// to be impossible that a value for a given key is out of date. We therefore
// require a revision in the key. That is in line with the rest of the caches in
// Gerrit.
//
// Splitting the cache into two chunks internally in this class allows us to retain
// the existing performance guarantees of not requiring reads for the repo for values
// cached in-memory but also to persist the cache which leads to a much improved
// cold-start behavior and in-memory miss latency.
cache(CACHE_NAME, Project.NameKey.class, CachedProjectConfig.class).loader(InMemoryLoader.class).refreshAfterWrite(Duration.ofMinutes(15)).expireAfterWrite(Duration.ofHours(1));
persist(PERSISTED_CACHE_NAME, Cache.ProjectCacheKeyProto.class, CachedProjectConfig.class).loader(PersistedLoader.class).keySerializer(new ProtobufSerializer<>(Cache.ProjectCacheKeyProto.parser())).valueSerializer(PersistedProjectConfigSerializer.INSTANCE).diskLimit(// 1 GiB
1 << 30).version(4).maximumWeight(0);
cache(CACHE_LIST, ListKey.class, new TypeLiteral<ImmutableSortedSet<Project.NameKey>>() {
}).maximumWeight(1).loader(Lister.class);
bind(ProjectCacheImpl.class);
bind(ProjectCache.class).to(ProjectCacheImpl.class);
install(new LifecycleModule() {
@Override
protected void configure() {
listener().to(ProjectCacheWarmer.class);
}
});
}
};
}
use of com.google.gerrit.server.cache.CacheModule in project gerrit by GerritCodeReview.
the class StaticModule method configureServlets.
@Override
protected void configureServlets() {
serveRegex("^/Documentation$").with(named(DOC_SERVLET));
serveRegex("^/Documentation/$").with(named(DOC_SERVLET));
serveRegex("^/Documentation/(.+)$").with(named(DOC_SERVLET));
serve("/static/*").with(SiteStaticDirectoryServlet.class);
install(new CacheModule() {
@Override
protected void configure() {
cache(CACHE, Path.class, Resource.class).maximumWeight(1 << 20).weigher(ResourceServlet.Weigher.class);
}
});
if (!options.headless()) {
install(new CoreStaticModule());
install(new PolyGerritModule());
}
}
Aggregations