Make AccountCache available to Prolog predicates

Some plugins implement Prolog predicates that need to get accounts.
E.g. the find-owners plugin has a Prolog predicate that loads the
accounts for all approvals on a change.

SubmitRuleEvaluator sets ReviewDb as a stored value in the Prolog
environment and hence Prolog predicates in plugins have access to it.
When accounts are moved to NoteDb accounts are no longer accessible
through ReviewDb. Hence the Prolog predicates need a different way to
get accounts. For this we make the AccountCache available by setting it
as a stored value in the Prolog environment.

Using the account cache instead of accessing the database should also
improve performance of Prolog predicates that need to access accounts.

Change-Id: I363a8ee0400622b4cc25d44f1d6fc876c951d412
Signed-off-by: Edwin Kempin <ekempin@google.com>
This commit is contained in:
Edwin Kempin
2017-06-13 14:31:08 +02:00
parent 8c36cc8805
commit c056334599
9 changed files with 66 additions and 11 deletions

View File

@@ -26,6 +26,7 @@ import com.google.gerrit.reviewdb.server.ReviewDb;
import com.google.gerrit.server.AnonymousUser;
import com.google.gerrit.server.CurrentUser;
import com.google.gerrit.server.IdentifiedUser;
import com.google.gerrit.server.account.AccountCache;
import com.google.gerrit.server.git.GitRepositoryManager;
import com.google.gerrit.server.patch.PatchList;
import com.google.gerrit.server.patch.PatchListCache;
@@ -46,6 +47,7 @@ import org.eclipse.jgit.lib.ObjectId;
import org.eclipse.jgit.lib.Repository;
public final class StoredValues {
public static final StoredValue<AccountCache> ACCOUNT_CACHE = create(AccountCache.class);
public static final StoredValue<ReviewDb> REVIEW_DB = create(ReviewDb.class);
public static final StoredValue<ChangeData> CHANGE_DATA = create(ChangeData.class);