Add debug log that shows up in trace whenever CacheLoader#load is invoked

This allows us to see cache misses in the trace.

Change-Id: I7ed1c779c35e6621cabaa6f257289913c92e1fe9
Signed-off-by: Edwin Kempin <ekempin@google.com>
This commit is contained in:
Edwin Kempin
2018-08-14 10:16:31 +02:00
parent ab47dc9238
commit 944cd404ac
9 changed files with 18 additions and 0 deletions

View File

@@ -179,6 +179,7 @@ public class AccountCacheImpl implements AccountCache {
@Override
public Optional<AccountState> load(Account.Id who) throws Exception {
logger.atFine().log("Loading account %s", who);
return accounts.get(who);
}
}

View File

@@ -144,6 +144,7 @@ public class GroupCacheImpl implements GroupCache {
@Override
public Optional<InternalGroup> load(AccountGroup.Id key) throws Exception {
logger.atFine().log("Loading group %s by ID", key);
return groupQueryProvider.get().byId(key);
}
}
@@ -158,6 +159,7 @@ public class GroupCacheImpl implements GroupCache {
@Override
public Optional<InternalGroup> load(String name) throws Exception {
logger.atFine().log("Loading group '%s' by name", name);
return groupQueryProvider.get().byName(new AccountGroup.NameKey(name));
}
}
@@ -172,6 +174,7 @@ public class GroupCacheImpl implements GroupCache {
@Override
public Optional<InternalGroup> load(String uuid) throws Exception {
logger.atFine().log("Loading group %s by UUID", uuid);
return groups.getGroup(new AccountGroup.UUID(uuid));
}
}

View File

@@ -148,6 +148,7 @@ public class GroupIncludeCacheImpl implements GroupIncludeCache {
@Override
public ImmutableSet<AccountGroup.UUID> load(Account.Id memberId) throws OrmException {
logger.atFine().log("Loading groups with member %s", memberId);
return groupQueryProvider
.get()
.byMember(memberId)
@@ -168,6 +169,7 @@ public class GroupIncludeCacheImpl implements GroupIncludeCache {
@Override
public ImmutableList<AccountGroup.UUID> load(AccountGroup.UUID key) throws OrmException {
logger.atFine().log("Loading parent groups of %s", key);
return groupQueryProvider
.get()
.bySubgroup(key)
@@ -187,6 +189,7 @@ public class GroupIncludeCacheImpl implements GroupIncludeCache {
@Override
public ImmutableList<AccountGroup.UUID> load(String key) throws Exception {
logger.atFine().log("Loading all external groups");
return groups.getExternalGroups().collect(toImmutableList());
}
}

View File

@@ -152,6 +152,7 @@ class ExternalIdCacheImpl implements ExternalIdCache {
@Override
public AllExternalIds load(ObjectId notesRev) throws Exception {
logger.atFine().log("Loading external IDs (revision=%s)", notesRev);
Multimap<Account.Id, ExternalId> extIdsByAccount =
MultimapBuilder.hashKeys().arrayListValues().build();
for (ExternalId extId : externalIdReader.all(notesRev)) {

View File

@@ -351,6 +351,7 @@ class LdapRealm extends AbstractRealm {
@Override
public Optional<Account.Id> load(String username) throws Exception {
logger.atFine().log("Loading account for username %s", username);
return externalIds
.get(ExternalId.Key.create(SCHEME_GERRIT, username))
.map(ExternalId::accountId);
@@ -367,6 +368,7 @@ class LdapRealm extends AbstractRealm {
@Override
public Set<AccountGroup.UUID> load(String username) throws Exception {
logger.atFine().log("Loading group for member with username %s", username);
final DirContext ctx = helper.open();
try {
return helper.queryForGroups(ctx, username, null);
@@ -386,6 +388,7 @@ class LdapRealm extends AbstractRealm {
@Override
public Boolean load(String groupDn) throws Exception {
logger.atFine().log("Loading groupDn %s", groupDn);
final DirContext ctx = helper.open();
try {
Name compositeGroupName = new CompositeName().add(groupDn);

View File

@@ -235,6 +235,8 @@ public class H2CacheImpl<K, V> extends AbstractLoadingCache<K, V> implements Per
@Override
public ValueHolder<V> load(K key) throws Exception {
logger.atFine().log("Loading value for %s from cache", key);
if (store.mightContain(key)) {
ValueHolder<V> h = store.getIfPresent(key);
if (h != null) {

View File

@@ -144,6 +144,7 @@ public class SearchingChangeCacheImpl implements GitReferenceUpdatedListener {
@Override
public List<CachedChange> load(Project.NameKey key) throws Exception {
logger.atFine().log("Loading changes of project %s", key);
try (ManualRequestContext ctx = requestContext.open()) {
List<ChangeData> cds =
queryProvider

View File

@@ -269,6 +269,7 @@ public class ProjectCacheImpl implements ProjectCache {
@Override
public ProjectState load(String projectName) throws Exception {
logger.atFine().log("Loading project %s", projectName);
long now = clock.read();
Project.NameKey key = new Project.NameKey(projectName);
try (Repository git = mgr.openRepository(key)) {
@@ -298,6 +299,7 @@ public class ProjectCacheImpl implements ProjectCache {
@Override
public ImmutableSortedSet<Project.NameKey> load(ListKey key) throws Exception {
logger.atFine().log("Loading project list");
return ImmutableSortedSet.copyOf(mgr.list());
}
}

View File

@@ -102,6 +102,8 @@ public class SshKeyCacheImpl implements SshKeyCache {
@Override
public Iterable<SshKeyCacheEntry> load(String username) throws Exception {
logger.atFine().log("Loading SSH keys for account with username %s", username);
Optional<ExternalId> user = externalIds.get(ExternalId.Key.create(SCHEME_USERNAME, username));
if (!user.isPresent()) {
return NO_SUCH_USER;