Sequences: Remove ReviewDb support

Change-Id: I41bc697c3cab890005ceab596e28a1addc87d248
This commit is contained in:
Dave Borowitz
2018-11-16 14:05:17 -08:00
parent 7397e6956d
commit 29f2c634fa
2 changed files with 8 additions and 47 deletions

View File

@@ -14,8 +14,6 @@
package com.google.gerrit.server;
import static com.google.common.base.Preconditions.checkArgument;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.collect.ImmutableList;
import com.google.gerrit.metrics.Description;
@@ -29,14 +27,10 @@ import com.google.gerrit.server.config.AllUsersName;
import com.google.gerrit.server.config.GerritServerConfig;
import com.google.gerrit.server.extensions.events.GitReferenceUpdated;
import com.google.gerrit.server.git.GitRepositoryManager;
import com.google.gerrit.server.notedb.NotesMigration;
import com.google.gerrit.server.notedb.RepoSequence;
import com.google.gwtorm.server.OrmException;
import com.google.inject.Inject;
import com.google.inject.Provider;
import com.google.inject.Singleton;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.jgit.lib.Config;
@Singleton
@@ -55,8 +49,6 @@ public class Sequences {
GROUPS;
}
private final Provider<ReviewDb> db;
private final NotesMigration migration;
private final RepoSequence accountSeq;
private final RepoSequence changeSeq;
private final RepoSequence groupSeq;
@@ -65,15 +57,11 @@ public class Sequences {
@Inject
public Sequences(
@GerritServerConfig Config cfg,
Provider<ReviewDb> db,
NotesMigration migration,
GitRepositoryManager repoManager,
GitReferenceUpdated gitRefUpdated,
AllProjectsName allProjects,
AllUsersName allUsers,
MetricMaker metrics) {
this.db = db;
this.migration = migration;
int accountBatchSize = cfg.getInt("noteDb", "accounts", "sequenceBatchSize", 1);
accountSeq =
@@ -85,13 +73,15 @@ public class Sequences {
() -> ReviewDb.FIRST_ACCOUNT_ID,
accountBatchSize);
int gap = getChangeSequenceGap(cfg);
@SuppressWarnings("deprecation")
RepoSequence.Seed changeSeed = () -> db.get().nextChangeId() + gap;
int changeBatchSize = cfg.getInt("noteDb", "changes", "sequenceBatchSize", 20);
changeSeq =
new RepoSequence(
repoManager, gitRefUpdated, allProjects, NAME_CHANGES, changeSeed, changeBatchSize);
repoManager,
gitRefUpdated,
allProjects,
NAME_CHANGES,
() -> ReviewDb.FIRST_CHANGE_ID,
changeBatchSize);
int groupBatchSize = 1;
groupSeq =
@@ -120,31 +110,15 @@ public class Sequences {
}
public int nextChangeId() throws OrmException {
if (!migration.readChangeSequence()) {
return nextChangeId(db.get());
}
try (Timer2.Context timer = nextIdLatency.start(SequenceType.CHANGES, false)) {
return changeSeq.next();
}
}
public ImmutableList<Integer> nextChangeIds(int count) throws OrmException {
if (migration.readChangeSequence()) {
try (Timer2.Context timer = nextIdLatency.start(SequenceType.CHANGES, count > 1)) {
return changeSeq.next(count);
}
try (Timer2.Context timer = nextIdLatency.start(SequenceType.CHANGES, count > 1)) {
return changeSeq.next(count);
}
if (count == 0) {
return ImmutableList.of();
}
checkArgument(count > 0, "count is negative: %s", count);
List<Integer> ids = new ArrayList<>(count);
ReviewDb db = this.db.get();
for (int i = 0; i < count; i++) {
ids.add(nextChangeId(db));
}
return ImmutableList.copyOf(ids);
}
public int nextGroupId() throws OrmException {
@@ -157,9 +131,4 @@ public class Sequences {
public RepoSequence getChangeIdRepoSequence() {
return changeSeq;
}
@SuppressWarnings("deprecation")
private static int nextChangeId(ReviewDb db) throws OrmException {
return db.nextChangeId();
}
}

View File

@@ -42,7 +42,6 @@ import com.google.gerrit.server.group.db.InternalGroupCreation;
import com.google.gerrit.server.group.db.InternalGroupUpdate;
import com.google.gerrit.server.index.group.GroupIndex;
import com.google.gerrit.server.index.group.GroupIndexCollection;
import com.google.gerrit.server.notedb.NotesMigration;
import com.google.gwtorm.jdbc.JdbcExecutor;
import com.google.gwtorm.jdbc.JdbcSchema;
import com.google.gwtorm.server.OrmDuplicateKeyException;
@@ -72,7 +71,6 @@ public class ReviewDbSchemaCreator {
private final Config config;
private final MetricMaker metricMaker;
private final NotesMigration migration;
private final AllProjectsName allProjectsName;
@Inject
@@ -88,7 +86,6 @@ public class ReviewDbSchemaCreator {
@GerritServerId String serverId,
@GerritServerConfig Config config,
MetricMaker metricMaker,
NotesMigration migration,
AllProjectsName apName) {
this(
site.site_path,
@@ -102,7 +99,6 @@ public class ReviewDbSchemaCreator {
serverId,
config,
metricMaker,
migration,
apName);
}
@@ -118,7 +114,6 @@ public class ReviewDbSchemaCreator {
String serverId,
Config config,
MetricMaker metricMaker,
NotesMigration migration,
AllProjectsName apName) {
site_path = site;
this.repoManager = repoManager;
@@ -132,7 +127,6 @@ public class ReviewDbSchemaCreator {
this.config = config;
this.allProjectsName = apName;
this.migration = migration;
this.metricMaker = metricMaker;
}
@@ -157,8 +151,6 @@ public class ReviewDbSchemaCreator {
Sequences seqs =
new Sequences(
config,
() -> db,
migration,
repoManager,
GitReferenceUpdated.DISABLED,
allProjectsName,