Revert external ID cache

It make more sense to include the commit SHA-1 of the notes branch from
which the external IDs have been read into the cache key. This makes it
easier to implement this cache within a multimaster setup.
However, obviously, we can include the commit SHA-1 of the notes branch
into the cache key only after the external IDs have been migrated to
NoteDb (because before this the notes branch does not exist yet).
Revert the cache for now and re-add an improved version of the cache
later with the change that implements the migration of the external IDs
to NoteDb.

This reverts the following commits:
- 2869caaf70:
  Add cache for external ids
- 48d5c9b9aa:
  Make ExternalIdCacheImpl.AllKey public
- 20e5507d46:
  ExternalIdCache: Add method to get external IDs by account ID + scheme

Change-Id: I589242aad32a9c70718542ba950c0a351c594e54
Signed-off-by: Edwin Kempin <ekempin@google.com>
This commit is contained in:
Edwin Kempin
2017-02-01 11:39:17 +01:00
parent a461a3d45a
commit 79e63a39e4
22 changed files with 93 additions and 418 deletions

View File

@@ -20,7 +20,6 @@ import com.google.gerrit.reviewdb.server.ReviewDb;
import com.google.gerrit.server.IdentifiedUser;
import com.google.gerrit.server.account.AccountByEmailCache;
import com.google.gerrit.server.account.AccountCache;
import com.google.gerrit.server.account.ExternalIdCache;
import com.google.gwtorm.server.OrmException;
import com.google.inject.Inject;
import com.google.inject.assistedinject.Assisted;
@@ -43,24 +42,21 @@ class DeleteExternalIds extends Handler<Set<AccountExternalId.Key>> {
private final ExternalIdDetailFactory detailFactory;
private final AccountByEmailCache byEmailCache;
private final AccountCache accountCache;
private final ExternalIdCache externalIdCache;
private final Set<AccountExternalId.Key> keys;
@Inject
DeleteExternalIds(ReviewDb db,
IdentifiedUser user,
ExternalIdDetailFactory detailFactory,
AccountByEmailCache byEmailCache,
AccountCache accountCache,
ExternalIdCache externalIdCache,
@Assisted Set<AccountExternalId.Key> keys) {
DeleteExternalIds(final ReviewDb db, final IdentifiedUser user,
final ExternalIdDetailFactory detailFactory,
final AccountByEmailCache byEmailCache, final AccountCache accountCache,
@Assisted final Set<AccountExternalId.Key> keys) {
this.db = db;
this.user = user;
this.detailFactory = detailFactory;
this.byEmailCache = byEmailCache;
this.accountCache = accountCache;
this.externalIdCache = externalIdCache;
this.keys = keys;
}
@@ -78,7 +74,6 @@ class DeleteExternalIds extends Handler<Set<AccountExternalId.Key>> {
if (!toDelete.isEmpty()) {
db.accountExternalIds().delete(toDelete);
externalIdCache.onRemove(toDelete);
accountCache.evict(user.getAccountId());
for (AccountExternalId e : toDelete) {
byEmailCache.evict(e.getEmailAddress());

View File

@@ -20,13 +20,12 @@ import com.google.gerrit.extensions.registration.DynamicItem;
import com.google.gerrit.httpd.WebSession;
import com.google.gerrit.httpd.rpc.Handler;
import com.google.gerrit.reviewdb.client.AccountExternalId;
import com.google.gerrit.reviewdb.server.ReviewDb;
import com.google.gerrit.server.IdentifiedUser;
import com.google.gerrit.server.account.ExternalIdCache;
import com.google.gerrit.server.config.AuthConfig;
import com.google.gwtorm.server.OrmException;
import com.google.inject.Inject;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@@ -35,27 +34,25 @@ class ExternalIdDetailFactory extends Handler<List<AccountExternalId>> {
ExternalIdDetailFactory create();
}
private final ReviewDb db;
private final IdentifiedUser user;
private final AuthConfig authConfig;
private final DynamicItem<WebSession> session;
private final ExternalIdCache externalIdCache;
@Inject
ExternalIdDetailFactory(IdentifiedUser user,
AuthConfig authConfig,
DynamicItem<WebSession> session,
ExternalIdCache externalIdCache) {
ExternalIdDetailFactory(final ReviewDb db, final IdentifiedUser user,
final AuthConfig authConfig, final DynamicItem<WebSession> session) {
this.db = db;
this.user = user;
this.authConfig = authConfig;
this.session = session;
this.externalIdCache = externalIdCache;
}
@Override
public List<AccountExternalId> call() throws OrmException {
AccountExternalId.Key last = session.get().getLastLoginExternalId();
List<AccountExternalId> ids =
new ArrayList<>(externalIdCache.byAccount(user.getAccountId()));
final AccountExternalId.Key last = session.get().getLastLoginExternalId();
final List<AccountExternalId> ids =
db.accountExternalIds().byAccount(user.getAccountId()).toList();
for (final AccountExternalId e : ids) {
e.setTrusted(authConfig.isIdentityTrustable(Collections.singleton(e)));