From f87dca186b33a2ee1add0c364a97f57b005271be Mon Sep 17 00:00:00 2001 From: Alice Kober-Sotzek Date: Thu, 12 Oct 2017 14:44:17 +0200 Subject: [PATCH] Improve naming of group caches Throughout Gerrit, the members of a group always refer to accounts. For some reason, the cache for the subgroups of a group also used the term 'members'. To reduce confusion (especially with the newly introduced cache for the groups which contain a specific account), we change the name of the caches relating to subgroups. Change-Id: I8e1e4e91045f9f4769c75e7c48e57a019ac97069 --- Documentation/cmd-show-caches.txt | 4 ++-- Documentation/config-gerrit.txt | 12 ++++++------ Documentation/rest-api-config.txt | 16 ++++++++-------- .../gerrit/server/account/GroupIncludeCache.java | 14 ++++++++++++-- .../server/account/GroupIncludeCacheImpl.java | 4 ++-- 5 files changed, 30 insertions(+), 20 deletions(-) diff --git a/Documentation/cmd-show-caches.txt b/Documentation/cmd-show-caches.txt index 1c9c7e9c74..6a1f554c62 100644 --- a/Documentation/cmd-show-caches.txt +++ b/Documentation/cmd-show-caches.txt @@ -61,12 +61,12 @@ Intended for interactive use only. adv_bases | | | | changes | | 27.1ms | 0% | groups | 5646 | 11.8ms | 97% | - groups_byinclude | 230 | 2.4ms | 62% | groups_bymember | | | | groups_byname | | | | + groups_bysubgroup | 230 | 2.4ms | 62% | groups_byuuid | 5612 | 29.2ms | 99% | groups_external | 1 | 1.5s | 98% | - groups_members | 5714 | 19.7ms | 99% | + groups_subgroups | 5714 | 19.7ms | 99% | ldap_group_existence | | | | ldap_groups | 650 | 680.5ms | 99% | ldap_groups_byinclude | 1024 | | 83% | diff --git a/Documentation/config-gerrit.txt b/Documentation/config-gerrit.txt index 7a59fa14ae..d241b981c5 100644 --- a/Documentation/config-gerrit.txt +++ b/Documentation/config-gerrit.txt @@ -847,18 +847,18 @@ including the group owner, name, and description. External group membership obtained from LDAP is cached under `"ldap_groups"`. -cache `"groups_byinclude"`:: -+ -Caches group inclusions in other groups. If direct updates are made -to the `account_group_includes` table, this cache should be flushed. - cache `"groups_bymember"`:: + Caches the groups which contain a specific member (account). If direct updates are made to the `account_group_members` table, this cache should be flushed. -cache `"groups_members"`:: +cache `"groups_bysubgroups"`:: ++ +Caches the parent groups of a subgroup. If direct updates are made +to the `account_group_includes` table, this cache should be flushed. + +cache `"groups_subgroups"`:: + Caches subgroups. If direct updates are made to the `account_group_includes` table, this cache should be flushed. diff --git a/Documentation/rest-api-config.txt b/Documentation/rest-api-config.txt index f1e9126fae..320e8482fa 100644 --- a/Documentation/rest-api-config.txt +++ b/Documentation/rest-api-config.txt @@ -333,11 +333,6 @@ The entries in the map are sorted by cache name. "mem": 12 } }, - "groups_byinclude": { - "type": "MEM", - "entries": {}, - "hit_ratio": {} - }, "groups_bymember": { "type": "MEM", "entries": {}, @@ -348,6 +343,11 @@ The entries in the map are sorted by cache name. "entries": {}, "hit_ratio": {} }, + "groups_bysubgroup": { + "type": "MEM", + "entries": {}, + "hit_ratio": {} + }, "groups_byuuid": { "type": "MEM", "entries": { @@ -363,7 +363,7 @@ The entries in the map are sorted by cache name. "entries": {}, "hit_ratio": {} }, - groups_members": { + groups_subgroups": { "type": "MEM", "entries": { "mem": 4 @@ -472,12 +472,12 @@ The cache names are lexicographically sorted. "diff_intraline", "git_tags", "groups", - "groups_byinclude", "groups_bymember", "groups_byname", + "groups_bysubgroup", "groups_byuuid", "groups_external", - "groups_members", + "groups_subgroups", "permission_sort", "plugin_resources", "project_list", diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/account/GroupIncludeCache.java b/gerrit-server/src/main/java/com/google/gerrit/server/account/GroupIncludeCache.java index daa431ebb2..157afb8979 100644 --- a/gerrit-server/src/main/java/com/google/gerrit/server/account/GroupIncludeCache.java +++ b/gerrit-server/src/main/java/com/google/gerrit/server/account/GroupIncludeCache.java @@ -29,10 +29,20 @@ public interface GroupIncludeCache { */ Collection getGroupsWithMember(Account.Id memberId); - /** @return groups directly a member of the passed group. */ + /** + * Returns the subgroups of a group. + * + * @param group the UUID of the group + * @return the UUIDs of all direct subgroups + */ Collection subgroupsOf(AccountGroup.UUID group); - /** @return any groups the passed group belongs to. */ + /** + * Returns the parent groups of a subgroup. + * + * @param groupId the UUID of the subgroup + * @return the UUIDs of all direct parent groups + */ Collection parentGroupsOf(AccountGroup.UUID groupId); /** @return set of any UUIDs that are not internal groups. */ diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/account/GroupIncludeCacheImpl.java b/gerrit-server/src/main/java/com/google/gerrit/server/account/GroupIncludeCacheImpl.java index cfb14c5487..e1286275b4 100644 --- a/gerrit-server/src/main/java/com/google/gerrit/server/account/GroupIncludeCacheImpl.java +++ b/gerrit-server/src/main/java/com/google/gerrit/server/account/GroupIncludeCacheImpl.java @@ -52,8 +52,8 @@ import org.slf4j.LoggerFactory; @Singleton public class GroupIncludeCacheImpl implements GroupIncludeCache { private static final Logger log = LoggerFactory.getLogger(GroupIncludeCacheImpl.class); - private static final String PARENT_GROUPS_NAME = "groups_byinclude"; - private static final String SUBGROUPS_NAME = "groups_members"; + private static final String PARENT_GROUPS_NAME = "groups_bysubgroup"; + private static final String SUBGROUPS_NAME = "groups_subgroups"; private static final String GROUPS_WITH_MEMBER_NAME = "groups_bymember"; private static final String EXTERNAL_NAME = "groups_external";