Improve method and variable names related to group inclusion caches

In [1] group's accounts will be cached, thus in the semantic
environment of group inclusion caches the words 'member' and
'include' will not only be limited to subgroups and parent groups,
but will also include accounts.

This commit does not update cache names and does not affect users.
It only updates related method names to be more meaningful.

[1] https://gerrit-review.googlesource.com/58302

Change-Id: I9a5be1cb08ff53e2cede251a6f63e16ec25cdcfa
This commit is contained in:
Bruce Zu
2014-09-28 13:04:54 +08:00
committed by Saša Živkov
parent 0524c80b88
commit dd83336fd8
9 changed files with 48 additions and 48 deletions

View File

@@ -91,7 +91,7 @@ import javax.security.auth.login.LoginException;
return null;
}
private final Cache<String, ImmutableSet<String>> groupsByInclude;
private final Cache<String, ImmutableSet<String>> parentGroups;
private final Config config;
private final String server;
private final String username;
@@ -106,8 +106,8 @@ import javax.security.auth.login.LoginException;
@Inject
Helper(@GerritServerConfig final Config config,
@Named(LdapModule.GROUPS_BYINCLUDE_CACHE)
Cache<String, ImmutableSet<String>> groupsByInclude) {
@Named(LdapModule.PARENT_GROUPS_CACHE)
Cache<String, ImmutableSet<String>> parentGroups) {
this.config = config;
this.server = LdapRealm.optional(config, "server");
this.username = LdapRealm.optional(config, "username");
@@ -132,7 +132,7 @@ import javax.security.auth.login.LoginException;
} else {
connectTimeoutMillis = null;
}
this.groupsByInclude = groupsByInclude;
this.parentGroups = parentGroups;
this.connectionPoolConfig = getPoolProperties(config);
}
@@ -310,8 +310,8 @@ import javax.security.auth.login.LoginException;
private void recursivelyExpandGroups(final Set<String> groupDNs,
final LdapSchema schema, final DirContext ctx, final String groupDN) {
if (groupDNs.add(groupDN) && schema.accountMemberField != null) {
ImmutableSet<String> cachedGroupDNs = groupsByInclude.getIfPresent(groupDN);
if (cachedGroupDNs == null) {
ImmutableSet<String> cachedParentsDNs = parentGroups.getIfPresent(groupDN);
if (cachedParentsDNs == null) {
// Recursively identify the groups it is a member of.
ImmutableSet.Builder<String> dns = ImmutableSet.builder();
try {
@@ -330,10 +330,10 @@ import javax.security.auth.login.LoginException;
} catch (NamingException e) {
LdapRealm.log.warn("Could not find group " + groupDN, e);
}
cachedGroupDNs = dns.build();
groupsByInclude.put(groupDN, cachedGroupDNs);
cachedParentsDNs = dns.build();
parentGroups.put(groupDN, cachedParentsDNs);
}
for (String dn : cachedGroupDNs) {
for (String dn : cachedParentsDNs) {
recursivelyExpandGroups(groupDNs, schema, ctx, dn);
}
}

View File

@@ -33,7 +33,7 @@ public class LdapModule extends CacheModule {
static final String USERNAME_CACHE = "ldap_usernames";
static final String GROUP_CACHE = "ldap_groups";
static final String GROUP_EXIST_CACHE = "ldap_group_existence";
static final String GROUPS_BYINCLUDE_CACHE = "ldap_groups_byinclude";
static final String PARENT_GROUPS_CACHE = "ldap_groups_byinclude";
@Override
@@ -55,7 +55,7 @@ public class LdapModule extends CacheModule {
.expireAfterWrite(1, HOURS)
.loader(LdapRealm.ExistenceLoader.class);
cache(GROUPS_BYINCLUDE_CACHE,
cache(PARENT_GROUPS_CACHE,
String.class,
new TypeLiteral<ImmutableSet<String>>() {})
.expireAfterWrite(1, HOURS);