use of com.google.gerrit.server.index.group.GroupIndexer in project gerrit by GerritCodeReview.
the class PeriodicGroupIndexer method run.
@Override
public synchronized void run() {
try (Repository allUsers = repoManager.openRepository(allUsersName)) {
ImmutableSet<AccountGroup.UUID> newGroupUuids = GroupNameNotes.loadAllGroups(allUsers).stream().map(GroupReference::getUUID).collect(toImmutableSet());
GroupIndexer groupIndexer = groupIndexerProvider.get();
int reindexCounter = 0;
for (AccountGroup.UUID groupUuid : newGroupUuids) {
if (groupIndexer.reindexIfStale(groupUuid)) {
reindexCounter++;
}
}
if (groupUuids != null) {
// index.
for (AccountGroup.UUID groupUuid : Sets.difference(groupUuids, newGroupUuids)) {
groupIndexer.index(groupUuid);
reindexCounter++;
}
}
groupUuids = newGroupUuids;
logger.atInfo().log("Run group indexer, %s groups reindexed", reindexCounter);
} catch (Exception t) {
logger.atSevere().withCause(t).log("Failed to reindex groups");
}
}
use of com.google.gerrit.server.index.group.GroupIndexer in project gerrit by GerritCodeReview.
the class ProjectResetterTest method groupEviction.
@Test
public void groupEviction() throws Exception {
AccountGroup.UUID uuid1 = AccountGroup.uuid("abcd1");
AccountGroup.UUID uuid2 = AccountGroup.uuid("abcd2");
AccountGroup.UUID uuid3 = AccountGroup.uuid("abcd3");
Project.NameKey allUsers = Project.nameKey(AllUsersNameProvider.DEFAULT);
Repository allUsersRepo = repoManager.createRepository(allUsers);
GroupCache cache = mock(GroupCache.class);
GroupIndexer indexer = mock(GroupIndexer.class);
GroupIncludeCache includeCache = mock(GroupIncludeCache.class);
createRef(allUsersRepo, RefNames.refsGroups(uuid1));
Ref ref2 = createRef(allUsersRepo, RefNames.refsGroups(uuid2));
try (ProjectResetter resetProject = builder(null, null, null, cache, includeCache, indexer, null).build(new ProjectResetter.Config().reset(project).reset(allUsers))) {
updateRef(allUsersRepo, ref2);
createRef(allUsersRepo, RefNames.refsGroups(uuid3));
}
verify(cache).evict(uuid2);
verify(indexer).index(uuid2);
verify(includeCache).evictParentGroupsOf(uuid2);
verify(cache).evict(uuid3);
verify(indexer).index(uuid3);
verify(includeCache).evictParentGroupsOf(uuid3);
verifyNoMoreInteractions(cache, indexer, includeCache);
}
Aggregations