diff --git a/java/com/google/gerrit/acceptance/AbstractDaemonTest.java b/java/com/google/gerrit/acceptance/AbstractDaemonTest.java index c4947a4866..72b5361901 100644 --- a/java/com/google/gerrit/acceptance/AbstractDaemonTest.java +++ b/java/com/google/gerrit/acceptance/AbstractDaemonTest.java @@ -115,7 +115,6 @@ import com.google.gerrit.server.index.group.GroupIndexer; import com.google.gerrit.server.notedb.AbstractChangeNotes; import com.google.gerrit.server.notedb.ChangeNoteUtil; import com.google.gerrit.server.notedb.ChangeNotes; -import com.google.gerrit.server.notedb.NotesMigration; import com.google.gerrit.server.project.ProjectCache; import com.google.gerrit.server.project.ProjectConfig; import com.google.gerrit.server.project.testing.Util; @@ -261,7 +260,6 @@ public abstract class AbstractDaemonTest { @Inject protected PluginConfigFactory pluginConfig; @Inject protected Revisions revisions; @Inject protected SystemGroupBackend systemGroupBackend; - @Inject protected NotesMigration notesMigration; @Inject protected ChangeNotes.Factory notesFactory; @Inject protected BatchAbandon batchAbandon; @Inject protected TestSshKeys sshKeys; diff --git a/java/com/google/gerrit/server/config/GerritServerConfigProvider.java b/java/com/google/gerrit/server/config/GerritServerConfigProvider.java index 8df21da1b3..952f7d38ee 100644 --- a/java/com/google/gerrit/server/config/GerritServerConfigProvider.java +++ b/java/com/google/gerrit/server/config/GerritServerConfigProvider.java @@ -18,7 +18,6 @@ import static java.util.stream.Collectors.joining; import com.google.common.flogger.FluentLogger; import com.google.gerrit.common.Nullable; -import com.google.gerrit.server.notedb.NotesMigration; import com.google.gerrit.server.securestore.SecureStore; import com.google.inject.Inject; import com.google.inject.Provider; @@ -99,7 +98,7 @@ public class GerritServerConfigProvider implements Provider { private static void checkNoteDbConfig(FileBasedConfig noteDbConfig) { List bad = new ArrayList<>(); for (String section : noteDbConfig.getSections()) { - if (section.equals(NotesMigration.SECTION_NOTE_DB)) { + if (section.equals("noteDb")) { continue; } for (String subsection : noteDbConfig.getSubsections(section)) { diff --git a/java/com/google/gerrit/server/git/receive/ReceiveCommits.java b/java/com/google/gerrit/server/git/receive/ReceiveCommits.java index c90c77a43a..c958fcc3ac 100644 --- a/java/com/google/gerrit/server/git/receive/ReceiveCommits.java +++ b/java/com/google/gerrit/server/git/receive/ReceiveCommits.java @@ -122,7 +122,6 @@ import com.google.gerrit.server.logging.RequestId; import com.google.gerrit.server.logging.TraceContext; import com.google.gerrit.server.mail.MailUtil.MailRecipients; import com.google.gerrit.server.notedb.ChangeNotes; -import com.google.gerrit.server.notedb.NotesMigration; import com.google.gerrit.server.patch.PatchSetInfoFactory; import com.google.gerrit.server.permissions.ChangePermission; import com.google.gerrit.server.permissions.GlobalPermission; @@ -304,7 +303,6 @@ class ReceiveCommits { private final DynamicMap pluginConfigEntries; private final PluginSetContext initializers; private final MergedByPushOp.Factory mergedByPushOpFactory; - private final NotesMigration notesMigration; private final PatchSetInfoFactory patchSetInfoFactory; private final PatchSetUtil psUtil; private final PermissionBackend permissionBackend; @@ -381,7 +379,6 @@ class ReceiveCommits { DynamicMap pluginConfigEntries, PluginSetContext initializers, MergedByPushOp.Factory mergedByPushOpFactory, - NotesMigration notesMigration, PatchSetInfoFactory patchSetInfoFactory, PatchSetUtil psUtil, PermissionBackend permissionBackend, @@ -423,7 +420,6 @@ class ReceiveCommits { this.mergeOpProvider = mergeOpProvider; this.mergedByPushOpFactory = mergedByPushOpFactory; this.notesFactory = notesFactory; - this.notesMigration = notesMigration; this.optionParserFactory = optionParserFactory; this.ormProvider = ormProvider; this.patchSetInfoFactory = patchSetInfoFactory; @@ -1327,7 +1323,6 @@ class ReceiveCommits { boolean deprecatedTopicSeen; final ReceiveCommand cmd; final LabelTypes labelTypes; - final NotesMigration notesMigration; private final boolean defaultPublishComments; Branch.NameKey dest; PermissionBackend.ForRef perm; @@ -1481,16 +1476,11 @@ class ReceiveCommits { // TODO(dpursehouse): validate hashtags } - MagicBranchInput( - IdentifiedUser user, - ReceiveCommand cmd, - LabelTypes labelTypes, - NotesMigration notesMigration) { + MagicBranchInput(IdentifiedUser user, ReceiveCommand cmd, LabelTypes labelTypes) { this.deprecatedTopicSeen = false; this.cmd = cmd; this.draft = cmd.getRefName().startsWith(MagicBranch.NEW_DRAFT_CHANGE); this.labelTypes = labelTypes; - this.notesMigration = notesMigration; GeneralPreferencesInfo prefs = user.state().getGeneralPreferences(); this.defaultPublishComments = prefs != null @@ -1629,7 +1619,7 @@ class ReceiveCommits { */ private void parseMagicBranch(ReceiveCommand cmd) throws PermissionBackendException { logger.atFine().log("Found magic branch %s", cmd.getRefName()); - MagicBranchInput magicBranch = new MagicBranchInput(user, cmd, labelTypes, notesMigration); + MagicBranchInput magicBranch = new MagicBranchInput(user, cmd, labelTypes); String ref; magicBranch.cmdLineParser = optionParserFactory.create(magicBranch); diff --git a/java/com/google/gerrit/server/notedb/AbstractChangeUpdate.java b/java/com/google/gerrit/server/notedb/AbstractChangeUpdate.java index 1e90447294..046f2f7706 100644 --- a/java/com/google/gerrit/server/notedb/AbstractChangeUpdate.java +++ b/java/com/google/gerrit/server/notedb/AbstractChangeUpdate.java @@ -44,7 +44,6 @@ import org.eclipse.jgit.revwalk.RevWalk; public abstract class AbstractChangeUpdate { private static final FluentLogger logger = FluentLogger.forEnclosingClass(); - protected final NotesMigration migration; protected final ChangeNoteUtil noteUtil; protected final Account.Id accountId; protected final Account.Id realAccountId; @@ -62,13 +61,11 @@ public abstract class AbstractChangeUpdate { protected AbstractChangeUpdate( Config cfg, - NotesMigration migration, ChangeNotes notes, CurrentUser user, PersonIdent serverIdent, ChangeNoteUtil noteUtil, Date when) { - this.migration = migration; this.noteUtil = noteUtil; this.serverIdent = new PersonIdent(serverIdent, when); this.notes = notes; @@ -83,7 +80,6 @@ public abstract class AbstractChangeUpdate { protected AbstractChangeUpdate( Config cfg, - NotesMigration migration, ChangeNoteUtil noteUtil, PersonIdent serverIdent, @Nullable ChangeNotes notes, @@ -95,7 +91,6 @@ public abstract class AbstractChangeUpdate { checkArgument( (notes != null && change == null) || (notes == null && change != null), "exactly one of notes or change required"); - this.migration = migration; this.noteUtil = noteUtil; this.serverIdent = new PersonIdent(serverIdent, when); this.notes = notes; diff --git a/java/com/google/gerrit/server/notedb/ChangeDraftUpdate.java b/java/com/google/gerrit/server/notedb/ChangeDraftUpdate.java index a4c5428bfb..75531bc887 100644 --- a/java/com/google/gerrit/server/notedb/ChangeDraftUpdate.java +++ b/java/com/google/gerrit/server/notedb/ChangeDraftUpdate.java @@ -94,7 +94,6 @@ public class ChangeDraftUpdate extends AbstractChangeUpdate { private ChangeDraftUpdate( @GerritServerConfig Config cfg, @GerritPersonIdent PersonIdent serverIdent, - NotesMigration migration, AllUsersName allUsers, ChangeNoteUtil noteUtil, @Assisted ChangeNotes notes, @@ -102,17 +101,7 @@ public class ChangeDraftUpdate extends AbstractChangeUpdate { @Assisted("real") Account.Id realAccountId, @Assisted PersonIdent authorIdent, @Assisted Date when) { - super( - cfg, - migration, - noteUtil, - serverIdent, - notes, - null, - accountId, - realAccountId, - authorIdent, - when); + super(cfg, noteUtil, serverIdent, notes, null, accountId, realAccountId, authorIdent, when); this.draftsProject = allUsers; } @@ -120,7 +109,6 @@ public class ChangeDraftUpdate extends AbstractChangeUpdate { private ChangeDraftUpdate( @GerritServerConfig Config cfg, @GerritPersonIdent PersonIdent serverIdent, - NotesMigration migration, AllUsersName allUsers, ChangeNoteUtil noteUtil, @Assisted Change change, @@ -128,17 +116,7 @@ public class ChangeDraftUpdate extends AbstractChangeUpdate { @Assisted("real") Account.Id realAccountId, @Assisted PersonIdent authorIdent, @Assisted Date when) { - super( - cfg, - migration, - noteUtil, - serverIdent, - null, - change, - accountId, - realAccountId, - authorIdent, - when); + super(cfg, noteUtil, serverIdent, null, change, accountId, realAccountId, authorIdent, when); this.draftsProject = allUsers; } diff --git a/java/com/google/gerrit/server/notedb/ChangeUpdate.java b/java/com/google/gerrit/server/notedb/ChangeUpdate.java index 56ccf7fa3a..468e4814fb 100644 --- a/java/com/google/gerrit/server/notedb/ChangeUpdate.java +++ b/java/com/google/gerrit/server/notedb/ChangeUpdate.java @@ -166,7 +166,6 @@ public class ChangeUpdate extends AbstractChangeUpdate { private ChangeUpdate( @GerritServerConfig Config cfg, @GerritPersonIdent PersonIdent serverIdent, - NotesMigration migration, NoteDbUpdateManager.Factory updateManagerFactory, ChangeDraftUpdate.Factory draftUpdateFactory, RobotCommentUpdate.Factory robotCommentUpdateFactory, @@ -178,7 +177,6 @@ public class ChangeUpdate extends AbstractChangeUpdate { this( cfg, serverIdent, - migration, updateManagerFactory, draftUpdateFactory, robotCommentUpdateFactory, @@ -194,7 +192,6 @@ public class ChangeUpdate extends AbstractChangeUpdate { private ChangeUpdate( @GerritServerConfig Config cfg, @GerritPersonIdent PersonIdent serverIdent, - NotesMigration migration, NoteDbUpdateManager.Factory updateManagerFactory, ChangeDraftUpdate.Factory draftUpdateFactory, RobotCommentUpdate.Factory robotCommentUpdateFactory, @@ -207,7 +204,6 @@ public class ChangeUpdate extends AbstractChangeUpdate { this( cfg, serverIdent, - migration, updateManagerFactory, draftUpdateFactory, robotCommentUpdateFactory, @@ -228,7 +224,6 @@ public class ChangeUpdate extends AbstractChangeUpdate { private ChangeUpdate( @GerritServerConfig Config cfg, @GerritPersonIdent PersonIdent serverIdent, - NotesMigration migration, NoteDbUpdateManager.Factory updateManagerFactory, ChangeDraftUpdate.Factory draftUpdateFactory, RobotCommentUpdate.Factory robotCommentUpdateFactory, @@ -238,7 +233,7 @@ public class ChangeUpdate extends AbstractChangeUpdate { @Assisted Date when, @Assisted Comparator labelNameComparator, ChangeNoteUtil noteUtil) { - super(cfg, migration, notes, user, serverIdent, noteUtil, when); + super(cfg, notes, user, serverIdent, noteUtil, when); this.updateManagerFactory = updateManagerFactory; this.draftUpdateFactory = draftUpdateFactory; this.robotCommentUpdateFactory = robotCommentUpdateFactory; @@ -250,7 +245,6 @@ public class ChangeUpdate extends AbstractChangeUpdate { private ChangeUpdate( @GerritServerConfig Config cfg, @GerritPersonIdent PersonIdent serverIdent, - NotesMigration migration, NoteDbUpdateManager.Factory updateManagerFactory, ChangeDraftUpdate.Factory draftUpdateFactory, RobotCommentUpdate.Factory robotCommentUpdateFactory, @@ -262,17 +256,7 @@ public class ChangeUpdate extends AbstractChangeUpdate { @Assisted PersonIdent authorIdent, @Assisted Date when, @Assisted Comparator labelNameComparator) { - super( - cfg, - migration, - noteUtil, - serverIdent, - null, - change, - accountId, - realAccountId, - authorIdent, - when); + super(cfg, noteUtil, serverIdent, null, change, accountId, realAccountId, authorIdent, when); this.draftUpdateFactory = draftUpdateFactory; this.robotCommentUpdateFactory = robotCommentUpdateFactory; this.updateManagerFactory = updateManagerFactory; diff --git a/java/com/google/gerrit/server/notedb/NotesMigration.java b/java/com/google/gerrit/server/notedb/NotesMigration.java deleted file mode 100644 index 26e764a7f9..0000000000 --- a/java/com/google/gerrit/server/notedb/NotesMigration.java +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright (C) 2017 The Android Open Source Project -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package com.google.gerrit.server.notedb; - -import com.google.inject.Singleton; -import java.util.Objects; - -/** - * Current low-level settings of the NoteDb migration for changes. - * - *

This class is a stub and will be removed soon; NoteDb is the only mode. - */ -@Singleton -public class NotesMigration { - public static final String SECTION_NOTE_DB = "noteDb"; - private static final String READ = "read"; - private static final String WRITE = "write"; - private static final String DISABLE_REVIEW_DB = "disableReviewDb"; - private static final String PRIMARY_STORAGE = "primaryStorage"; - private static final String SEQUENCE = "sequence"; - - /** - * Read changes from NoteDb. - * - *

Change data is read from NoteDb refs, but ReviewDb is still the source of truth. If the - * loader determines NoteDb is out of date, the change data in NoteDb will be transparently - * rebuilt. This means that some code paths that look read-only may in fact attempt to write. - * - *

If true and {@code writeChanges() = false}, changes can still be read from NoteDb, but any - * attempts to write will generate an error. - */ - public final boolean readChanges() { - return true; - } - - public final boolean commitChangeWrites() { - return true; - } - - @Override - public final boolean equals(Object o) { - return o instanceof NotesMigration; - } - - @Override - public final int hashCode() { - return Objects.hash(); - } - - public NotesMigration() {} -} diff --git a/java/com/google/gerrit/server/notedb/RobotCommentUpdate.java b/java/com/google/gerrit/server/notedb/RobotCommentUpdate.java index 73779bf6e1..28ac9c4333 100644 --- a/java/com/google/gerrit/server/notedb/RobotCommentUpdate.java +++ b/java/com/google/gerrit/server/notedb/RobotCommentUpdate.java @@ -76,48 +76,26 @@ public class RobotCommentUpdate extends AbstractChangeUpdate { private RobotCommentUpdate( @GerritServerConfig Config cfg, @GerritPersonIdent PersonIdent serverIdent, - NotesMigration migration, ChangeNoteUtil noteUtil, @Assisted ChangeNotes notes, @Assisted("effective") Account.Id accountId, @Assisted("real") Account.Id realAccountId, @Assisted PersonIdent authorIdent, @Assisted Date when) { - super( - cfg, - migration, - noteUtil, - serverIdent, - notes, - null, - accountId, - realAccountId, - authorIdent, - when); + super(cfg, noteUtil, serverIdent, notes, null, accountId, realAccountId, authorIdent, when); } @AssistedInject private RobotCommentUpdate( @GerritServerConfig Config cfg, @GerritPersonIdent PersonIdent serverIdent, - NotesMigration migration, ChangeNoteUtil noteUtil, @Assisted Change change, @Assisted("effective") Account.Id accountId, @Assisted("real") Account.Id realAccountId, @Assisted PersonIdent authorIdent, @Assisted Date when) { - super( - cfg, - migration, - noteUtil, - serverIdent, - null, - change, - accountId, - realAccountId, - authorIdent, - when); + super(cfg, noteUtil, serverIdent, null, change, accountId, realAccountId, authorIdent, when); } public void putComment(RobotComment c) { diff --git a/java/com/google/gerrit/server/query/change/ChangeQueryBuilder.java b/java/com/google/gerrit/server/query/change/ChangeQueryBuilder.java index 5b4c8fdb61..637f5564ee 100644 --- a/java/com/google/gerrit/server/query/change/ChangeQueryBuilder.java +++ b/java/com/google/gerrit/server/query/change/ChangeQueryBuilder.java @@ -68,7 +68,6 @@ import com.google.gerrit.server.index.change.ChangeIndex; import com.google.gerrit.server.index.change.ChangeIndexCollection; import com.google.gerrit.server.index.change.ChangeIndexRewriter; import com.google.gerrit.server.notedb.ChangeNotes; -import com.google.gerrit.server.notedb.NotesMigration; import com.google.gerrit.server.notedb.ReviewerStateInternal; import com.google.gerrit.server.patch.PatchListCache; import com.google.gerrit.server.permissions.PermissionBackend; @@ -208,7 +207,6 @@ public class ChangeQueryBuilder extends QueryBuilder { final GroupBackend groupBackend; final IdentifiedUser.GenericFactory userFactory; final IndexConfig indexConfig; - final NotesMigration notesMigration; final PatchListCache patchListCache; final ProjectCache projectCache; final Provider queryProvider; @@ -249,7 +247,6 @@ public class ChangeQueryBuilder extends QueryBuilder { IndexConfig indexConfig, StarredChangesUtil starredChangesUtil, AccountCache accountCache, - NotesMigration notesMigration, GroupMembers groupMembers, Provider anonymousUserProvider) { this( @@ -278,7 +275,6 @@ public class ChangeQueryBuilder extends QueryBuilder { indexConfig, starredChangesUtil, accountCache, - notesMigration, groupMembers, anonymousUserProvider); } @@ -309,7 +305,6 @@ public class ChangeQueryBuilder extends QueryBuilder { IndexConfig indexConfig, StarredChangesUtil starredChangesUtil, AccountCache accountCache, - NotesMigration notesMigration, GroupMembers groupMembers, Provider anonymousUserProvider) { this.db = db; @@ -337,7 +332,6 @@ public class ChangeQueryBuilder extends QueryBuilder { this.starredChangesUtil = starredChangesUtil; this.accountCache = accountCache; this.hasOperands = hasOperands; - this.notesMigration = notesMigration; this.groupMembers = groupMembers; this.anonymousUserProvider = anonymousUserProvider; } @@ -369,7 +363,6 @@ public class ChangeQueryBuilder extends QueryBuilder { indexConfig, starredChangesUtil, accountCache, - notesMigration, groupMembers, anonymousUserProvider); } diff --git a/java/com/google/gerrit/server/schema/NotesMigrationSchemaFactory.java b/java/com/google/gerrit/server/schema/NotesMigrationSchemaFactory.java index 63b3eaaffd..77d71f547d 100644 --- a/java/com/google/gerrit/server/schema/NotesMigrationSchemaFactory.java +++ b/java/com/google/gerrit/server/schema/NotesMigrationSchemaFactory.java @@ -16,7 +16,6 @@ package com.google.gerrit.server.schema; import com.google.gerrit.reviewdb.server.DisallowedReviewDb; import com.google.gerrit.reviewdb.server.ReviewDb; -import com.google.gerrit.server.notedb.NotesMigration; import com.google.gwtorm.server.OrmException; import com.google.gwtorm.server.SchemaFactory; import com.google.inject.Inject; @@ -24,12 +23,8 @@ import com.google.inject.Singleton; @Singleton public class NotesMigrationSchemaFactory implements SchemaFactory { - private final NotesMigration migration; - @Inject - NotesMigrationSchemaFactory(NotesMigration migration) { - this.migration = migration; - } + NotesMigrationSchemaFactory() {} @Override public ReviewDb open() throws OrmException { @@ -63,11 +58,10 @@ public class NotesMigrationSchemaFactory implements SchemaFactory { ReviewDb db = new NoChangesReviewDb(); // Second create the wrappers which can be removed by ReviewDbUtil#unwrapDb(ReviewDb). - if (migration.readChanges()) { - // If reading changes from NoteDb is configured, changes should not be read from ReviewDb. - // Make sure that any attempt to read a change from ReviewDb anyway fails with an exception. - db = new DisallowedReviewDb(db); - } + // ReviewDb is no longer supported, make sure that any attempt to read a change from ReviewDb + // anyway fails with an exception. + db = new DisallowedReviewDb(db); + return db; } } diff --git a/java/com/google/gerrit/testing/GerritServerTests.java b/java/com/google/gerrit/testing/GerritServerTests.java index 75479d2dcb..c8b6f969ad 100644 --- a/java/com/google/gerrit/testing/GerritServerTests.java +++ b/java/com/google/gerrit/testing/GerritServerTests.java @@ -14,7 +14,6 @@ package com.google.gerrit.testing; -import com.google.gerrit.server.notedb.NotesMigration; import org.eclipse.jgit.lib.Config; import org.junit.Rule; import org.junit.rules.TestRule; @@ -28,8 +27,6 @@ public class GerritServerTests extends GerritBaseTests { @ConfigSuite.Name private String configName; - protected NotesMigration notesMigration; - @Rule public TestRule testRunner = new TestRule() { @@ -38,14 +35,9 @@ public class GerritServerTests extends GerritBaseTests { return new Statement() { @Override public void evaluate() throws Throwable { - beforeTest(); base.evaluate(); } }; } }; - - public void beforeTest() { - notesMigration = new NotesMigration(); - } } diff --git a/javatests/com/google/gerrit/server/index/change/FakeQueryBuilder.java b/javatests/com/google/gerrit/server/index/change/FakeQueryBuilder.java index b5255049d4..edd4abfb4e 100644 --- a/javatests/com/google/gerrit/server/index/change/FakeQueryBuilder.java +++ b/javatests/com/google/gerrit/server/index/change/FakeQueryBuilder.java @@ -27,7 +27,7 @@ public class FakeQueryBuilder extends ChangeQueryBuilder { new FakeQueryBuilder.Definition<>(FakeQueryBuilder.class), new ChangeQueryBuilder.Arguments( null, null, null, null, null, null, null, null, null, null, null, null, null, null, - null, null, null, null, null, indexes, null, null, null, null, null, null, null, null)); + null, null, null, null, null, indexes, null, null, null, null, null, null, null)); } @Operator