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

@@ -41,7 +41,6 @@ import com.google.gerrit.server.IdentifiedUser;
import com.google.gerrit.server.account.AccountCache;
import com.google.gerrit.server.account.AccountManager;
import com.google.gerrit.server.account.AuthRequest;
import com.google.gerrit.server.account.ExternalIdCache;
import com.google.gerrit.server.schema.SchemaCreator;
import com.google.gerrit.server.util.RequestContext;
import com.google.gerrit.server.util.ThreadLocalRequestContext;
@@ -70,7 +69,6 @@ import org.junit.Test;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
@@ -97,9 +95,6 @@ public class GerritPublicKeyCheckerTest {
@Inject
private ThreadLocalRequestContext requestContext;
@Inject
private ExternalIdCache externalIdCache;
private LifecycleManager lifecycle;
private ReviewDb db;
private Account.Id userId;
@@ -234,10 +229,8 @@ public class GerritPublicKeyCheckerTest {
@Test
public void noExternalIds() throws Exception {
Collection<AccountExternalId> extIds =
externalIdCache.byAccount(user.getAccountId());
db.accountExternalIds().delete(extIds);
externalIdCache.onRemove(extIds);
db.accountExternalIds().delete(
db.accountExternalIds().byAccount(user.getAccountId()));
reloadUser();
TestKey key = validKeyWithSecondUserId();
@@ -255,10 +248,9 @@ public class GerritPublicKeyCheckerTest {
checker.check(key.getPublicKey()), Status.BAD,
"Key is not associated with any users");
AccountExternalId extId = new AccountExternalId(user.getAccountId(),
toExtIdKey(key.getPublicKey()));
db.accountExternalIds().insert(Collections.singleton(extId));
externalIdCache.onCreate(extId);
db.accountExternalIds().insert(Collections.singleton(
new AccountExternalId(
user.getAccountId(), toExtIdKey(key.getPublicKey()))));
reloadUser();
assertProblems(
checker.check(key.getPublicKey()), Status.BAD,
@@ -435,7 +427,6 @@ public class GerritPublicKeyCheckerTest {
assertThat(store.save(cb)).isAnyOf(NEW, FAST_FORWARD, FORCED);
db.accountExternalIds().insert(newExtIds);
externalIdCache.onCreate(newExtIds);
accountCache.evict(user.getAccountId());
}
@@ -468,7 +459,6 @@ public class GerritPublicKeyCheckerTest {
extId.setEmailAddress(email);
}
db.accountExternalIds().insert(Collections.singleton(extId));
externalIdCache.onCreate(extId);
reloadUser();
}
}