Standardize capitalization of "NoteDb"

Change-Id: I6b46af64267671cf458de07269bcc5b1f51d6fb0
This commit is contained in:
Dave Borowitz
2016-03-24 14:04:50 -04:00
parent 400d1de568
commit a2d40b836d
32 changed files with 94 additions and 95 deletions

View File

@@ -525,8 +525,8 @@ public class ChangeIT extends AbstractDaemonTest {
.id(r.getChangeId()) .id(r.getChangeId())
.get(); .get();
// When notedb is enabled adding a reviewer records that user as reviewer // When NoteDb is enabled adding a reviewer records that user as reviewer
// in notedb. When notedb is disabled adding a reviewer results in a dummy 0 // in NoteDb. When NoteDb is disabled adding a reviewer results in a dummy 0
// approval on the change which is treated as CC when the ChangeInfo is // approval on the change which is treated as CC when the ChangeInfo is
// created. // created.
Collection<AccountInfo> reviewers = isNoteDbTestEnabled() Collection<AccountInfo> reviewers = isNoteDbTestEnabled()
@@ -575,8 +575,8 @@ public class ChangeIT extends AbstractDaemonTest {
.get(); .get();
reviewers = c.reviewers.get(REVIEWER); reviewers = c.reviewers.get(REVIEWER);
if (isNoteDbTestEnabled()) { if (isNoteDbTestEnabled()) {
// When notedb is enabled adding a reviewer records that user as reviewer // When NoteDb is enabled adding a reviewer records that user as reviewer
// in notedb. // in NoteDb.
assertThat(reviewers).hasSize(2); assertThat(reviewers).hasSize(2);
Iterator<AccountInfo> reviewerIt = reviewers.iterator(); Iterator<AccountInfo> reviewerIt = reviewers.iterator();
assertThat(reviewerIt.next()._accountId) assertThat(reviewerIt.next()._accountId)
@@ -585,7 +585,7 @@ public class ChangeIT extends AbstractDaemonTest {
.isEqualTo(user.getId().get()); .isEqualTo(user.getId().get());
assertThat(c.reviewers).doesNotContainKey(CC); assertThat(c.reviewers).doesNotContainKey(CC);
} else { } else {
// When notedb is disabled adding a reviewer results in a dummy 0 approval // When NoteDb is disabled adding a reviewer results in a dummy 0 approval
// on the change which is treated as CC when the ChangeInfo is created. // on the change which is treated as CC when the ChangeInfo is created.
assertThat(reviewers).hasSize(1); assertThat(reviewers).hasSize(1);
assertThat(reviewers.iterator().next()._accountId) assertThat(reviewers.iterator().next()._accountId)
@@ -654,13 +654,13 @@ public class ChangeIT extends AbstractDaemonTest {
.votes(); .votes();
if (isNoteDbTestEnabled()) { if (isNoteDbTestEnabled()) {
// When notedb is enabled each reviewer is explicitly recorded in the // When NoteDb is enabled each reviewer is explicitly recorded in the
// notedb and this record stays even when all votes of that user have been // NoteDb and this record stays even when all votes of that user have been
// deleted, hence there is no dummy 0 approval left when a vote is // deleted, hence there is no dummy 0 approval left when a vote is
// deleted. // deleted.
assertThat(m).isEmpty(); assertThat(m).isEmpty();
} else { } else {
// When notedb is disabled there is a dummy 0 approval on the change so // When NoteDb is disabled there is a dummy 0 approval on the change so
// that the user is still returned as CC when all votes of that user have // that the user is still returned as CC when all votes of that user have
// been deleted. // been deleted.
assertThat(m).containsEntry("Code-Review", new Short((short)0)); assertThat(m).containsEntry("Code-Review", new Short((short)0));
@@ -675,14 +675,14 @@ public class ChangeIT extends AbstractDaemonTest {
assertThat(message.message).isEqualTo( assertThat(message.message).isEqualTo(
"Removed Code-Review+1 by User <user@example.com>\n"); "Removed Code-Review+1 by User <user@example.com>\n");
if (isNoteDbTestEnabled()) { if (isNoteDbTestEnabled()) {
// When notedb is enabled each reviewer is explicitly recorded in the // When NoteDb is enabled each reviewer is explicitly recorded in the
// notedb and this record stays even when all votes of that user have been // NoteDb and this record stays even when all votes of that user have been
// deleted. // deleted.
assertThat(getReviewers(c.reviewers.get(REVIEWER))) assertThat(getReviewers(c.reviewers.get(REVIEWER)))
.containsExactlyElementsIn( .containsExactlyElementsIn(
ImmutableSet.of(admin.getId(), user.getId())); ImmutableSet.of(admin.getId(), user.getId()));
} else { } else {
// When notedb is disabled users that have only dummy 0 approvals on the // When NoteDb is disabled users that have only dummy 0 approvals on the
// change are returned as CC and not as REVIEWER. // change are returned as CC and not as REVIEWER.
assertThat(getReviewers(c.reviewers.get(REVIEWER))) assertThat(getReviewers(c.reviewers.get(REVIEWER)))
.containsExactlyElementsIn(ImmutableSet.of(admin.getId())); .containsExactlyElementsIn(ImmutableSet.of(admin.getId()));
@@ -892,7 +892,7 @@ public class ChangeIT extends AbstractDaemonTest {
@Test @Test
public void check() throws Exception { public void check() throws Exception {
// TODO(dborowitz): Re-enable when ConsistencyChecker supports notedb. // TODO(dborowitz): Re-enable when ConsistencyChecker supports NoteDb.
assume().that(notesMigration.enabled()).isFalse(); assume().that(notesMigration.enabled()).isFalse();
PushOneCommit.Result r = createChange(); PushOneCommit.Result r = createChange();
assertThat(gApi.changes() assertThat(gApi.changes()
@@ -1067,7 +1067,7 @@ public class ChangeIT extends AbstractDaemonTest {
} }
@Test @Test
public void notedbCommitsOnPatchSetCreation() throws Exception { public void noteDbCommitsOnPatchSetCreation() throws Exception {
assume().that(notesMigration.enabled()).isTrue(); assume().that(notesMigration.enabled()).isTrue();
PushOneCommit.Result r = createChange(); PushOneCommit.Result r = createChange();

View File

@@ -256,8 +256,8 @@ public class VisibleRefFilterIT extends AbstractDaemonTest {
/** /**
* Assert that refs seen by a non-admin user match expected. * Assert that refs seen by a non-admin user match expected.
* *
* @param expectedWithMeta expected refs, in order. If notedb is disabled by * @param expectedWithMeta expected refs, in order. If NoteDb is disabled by
* the configuration, any notedb refs (i.e. ending in "/meta") are removed * the configuration, any NoteDb refs (i.e. ending in "/meta") are removed
* from the expected list before comparing to the actual results. * from the expected list before comparing to the actual results.
* @throws Exception * @throws Exception
*/ */

View File

@@ -28,7 +28,7 @@ import org.junit.Test;
import java.io.File; import java.io.File;
public class RebuildNotedbIT { public class RebuildNoteDbIT {
private File sitePath; private File sitePath;
@Before @Before
@@ -49,7 +49,7 @@ public class RebuildNotedbIT {
Files.append(ConfigNotesMigration.allEnabledConfig().toText(), Files.append(ConfigNotesMigration.allEnabledConfig().toText(),
new File(sitePath.toString(), "etc/gerrit.config"), new File(sitePath.toString(), "etc/gerrit.config"),
UTF_8); UTF_8);
runGerrit("RebuildNotedb", "-d", sitePath.toString(), runGerrit("RebuildNoteDb", "-d", sitePath.toString(),
"--show-stack-trace"); "--show-stack-trace");
} }

View File

@@ -115,7 +115,7 @@ public class CreateChangeIT extends AbstractDaemonTest {
} }
@Test @Test
public void notedbCommit() throws Exception { public void noteDbCommit() throws Exception {
assume().that(notesMigration.enabled()).isTrue(); assume().that(notesMigration.enabled()).isTrue();
ChangeInfo c = assertCreateSucceeds(newChangeInput(ChangeStatus.NEW)); ChangeInfo c = assertCreateSucceeds(newChangeInput(ChangeStatus.NEW));

View File

@@ -72,7 +72,7 @@ public class ConsistencyCheckerIT extends AbstractDaemonTest {
@Before @Before
public void setUp() throws Exception { public void setUp() throws Exception {
// TODO(dborowitz): Re-enable when ConsistencyChecker supports notedb. // TODO(dborowitz): Re-enable when ConsistencyChecker supports NoteDb.
// Note that we *do* want to enable these tests with GERRIT_CHECK_NOTEDB, as // Note that we *do* want to enable these tests with GERRIT_CHECK_NOTEDB, as
// we need to be able to convert old, corrupt changes. However, those tests // we need to be able to convert old, corrupt changes. However, those tests
// don't necessarily need to pass. // don't necessarily need to pass.

View File

@@ -74,7 +74,6 @@ public final class GerritLauncher {
System.err.println(); System.err.println();
System.err.println("The most commonly used commands are:"); System.err.println("The most commonly used commands are:");
System.err.println(" init Initialize a Gerrit installation"); System.err.println(" init Initialize a Gerrit installation");
System.err.println(" rebuild-notedb Rebuild the review notes database");
System.err.println(" reindex Rebuild the secondary index"); System.err.println(" reindex Rebuild the secondary index");
System.err.println(" daemon Run the Gerrit network daemons"); System.err.println(" daemon Run the Gerrit network daemons");
System.err.println(" gsql Run the interactive query console"); System.err.println(" gsql Run the interactive query console");

View File

@@ -358,7 +358,7 @@ public class LuceneChangeIndex implements ChangeIndex {
if (!schema.hasField(PROJECT)) { if (!schema.hasField(PROJECT)) {
// Schema is not new enough to have project field. Ensure we have ID // Schema is not new enough to have project field. Ensure we have ID
// field, and call createOnlyWhenNotedbDisabled from toChangeData below. // field, and call createOnlyWhenNoteDbDisabled from toChangeData below.
if (fs.contains(LEGACY_ID.getName())) { if (fs.contains(LEGACY_ID.getName())) {
return fs; return fs;
} else { } else {
@@ -389,9 +389,9 @@ public class LuceneChangeIndex implements ChangeIndex {
new Change.Id(doc.getField(idFieldName).numericValue().intValue()); new Change.Id(doc.getField(idFieldName).numericValue().intValue());
IndexableField project = doc.getField(PROJECT.getName()); IndexableField project = doc.getField(PROJECT.getName());
if (project == null) { if (project == null) {
// Old schema without project field: we can safely assume notedb is // Old schema without project field: we can safely assume NoteDb is
// disabled. // disabled.
cd = changeDataFactory.createOnlyWhenNotedbDisabled(db.get(), id); cd = changeDataFactory.createOnlyWhenNoteDbDisabled(db.get(), id);
} else { } else {
cd = changeDataFactory.create( cd = changeDataFactory.create(
db.get(), new Project.NameKey(project.stringValue()), id); db.get(), new Project.NameKey(project.stringValue()), id);

View File

@@ -75,9 +75,9 @@ import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicBoolean;
public class RebuildNotedb extends SiteProgram { public class RebuildNoteDb extends SiteProgram {
private static final Logger log = private static final Logger log =
LoggerFactory.getLogger(RebuildNotedb.class); LoggerFactory.getLogger(RebuildNoteDb.class);
@Option(name = "--threads", @Option(name = "--threads",
usage = "Number of threads to use for rebuilding NoteDb") usage = "Number of threads to use for rebuilding NoteDb")
@@ -121,14 +121,14 @@ public class RebuildNotedb extends SiteProgram {
sysInjector = createSysInjector(); sysInjector = createSysInjector();
sysInjector.injectMembers(this); sysInjector.injectMembers(this);
if (!notesMigration.enabled()) { if (!notesMigration.enabled()) {
die("Notedb is not enabled."); die("NoteDb is not enabled.");
} }
LifecycleManager sysManager = new LifecycleManager(); LifecycleManager sysManager = new LifecycleManager();
sysManager.add(sysInjector); sysManager.add(sysInjector);
sysManager.start(); sysManager.start();
ListeningExecutorService executor = newExecutor(); ListeningExecutorService executor = newExecutor();
System.out.println("Rebuilding the notedb"); System.out.println("Rebuilding the NoteDb");
Multimap<Project.NameKey, Change.Id> changesByProject = Multimap<Project.NameKey, Change.Id> changesByProject =
getChangesByProject(); getChangesByProject();
@@ -171,7 +171,7 @@ public class RebuildNotedb extends SiteProgram {
} }
})); }));
} catch (Exception e) { } catch (Exception e) {
log.error("Error rebuilding notedb", e); log.error("Error rebuilding NoteDb", e);
ok.set(false); ok.set(false);
break; break;
} }

View File

@@ -24,7 +24,7 @@ import org.eclipse.jgit.lib.Config;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
// TODO(dborowitz): Not necessary once we switch to notedb. // TODO(dborowitz): Not necessary once we switch to NoteDb.
/** Utility to limit threads used by a batch program. */ /** Utility to limit threads used by a batch program. */
public class ThreadLimiter { public class ThreadLimiter {
private static final Logger log = private static final Logger log =

View File

@@ -46,7 +46,7 @@ public class RefNames {
/** A change starred by a user */ /** A change starred by a user */
public static final String REFS_STARRED_CHANGES = "refs/starred-changes/"; public static final String REFS_STARRED_CHANGES = "refs/starred-changes/";
/** Sequence counters in notedb. */ /** Sequence counters in NoteDb. */
public static final String REFS_SEQUENCES = "refs/sequences/"; public static final String REFS_SEQUENCES = "refs/sequences/";
/** /**
@@ -61,7 +61,7 @@ public class RefNames {
*/ */
public static final String REFS_CACHE_AUTOMERGE = "refs/cache-automerge/"; public static final String REFS_CACHE_AUTOMERGE = "refs/cache-automerge/";
/** Suffix of a meta ref in the notedb. */ /** Suffix of a meta ref in the NoteDb. */
public static final String META_SUFFIX = "/meta"; public static final String META_SUFFIX = "/meta";
public static final String EDIT_PREFIX = "edit-"; public static final String EDIT_PREFIX = "edit-";

View File

@@ -55,7 +55,7 @@ import java.util.TreeMap;
* <p> * <p>
* The result of a copy may either be stored, as when stamping approvals in the * The result of a copy may either be stored, as when stamping approvals in the
* database at submit time, or refreshed on demand, as when reading approvals * database at submit time, or refreshed on demand, as when reading approvals
* from the notedb. * from the NoteDb.
*/ */
@Singleton @Singleton
public class ApprovalCopier { public class ApprovalCopier {

View File

@@ -313,7 +313,7 @@ public class PatchLineCommentsUtil {
bru.addCommand(new ReceiveCommand( bru.addCommand(new ReceiveCommand(
ref.getObjectId(), ObjectId.zeroId(), ref.getName())); ref.getObjectId(), ObjectId.zeroId(), ref.getName()));
} }
bru.setRefLogMessage("Delete drafts from notedb", false); bru.setRefLogMessage("Delete drafts from NoteDb", false);
bru.execute(rw, NullProgressMonitor.INSTANCE); bru.execute(rw, NullProgressMonitor.INSTANCE);
for (ReceiveCommand cmd : bru.getCommands()) { for (ReceiveCommand cmd : bru.getCommands()) {
if (cmd.getResult() != ReceiveCommand.Result.OK) { if (cmd.getResult() != ReceiveCommand.Result.OK) {

View File

@@ -97,7 +97,7 @@ public class ChangeResource implements RestResource, HasETag {
noteId = null; // This ETag will be invalidated if it loads next time. noteId = null; // This ETag will be invalidated if it loads next time.
} }
hashObjectId(h, noteId, buf); hashObjectId(h, noteId, buf);
// TODO(dborowitz): Include more notedb and other related refs, e.g. drafts // TODO(dborowitz): Include more NoteDb and other related refs, e.g. drafts
// and edits. // and edits.
for (ProjectState p : control.getProjectControl().getProjectState().tree()) { for (ProjectState p : control.getProjectControl().getProjectState().tree()) {

View File

@@ -68,7 +68,7 @@ public class Check implements RestReadView<ChangeResource>,
private void checkEnabled() throws NotImplementedException { private void checkEnabled() throws NotImplementedException {
if (notesMigration.readChanges()) { if (notesMigration.readChanges()) {
throw new NotImplementedException("check not implemented for notedb"); throw new NotImplementedException("check not implemented for NoteDb");
} }
} }
} }

View File

@@ -212,7 +212,7 @@ public class ConsistencyChecker {
private void checkImpl() { private void checkImpl() {
checkState(!notesMigration.readChanges(), checkState(!notesMigration.readChanges(),
"ConsistencyChecker for notedb not yet implemented"); "ConsistencyChecker for NoteDb not yet implemented");
checkOwner(); checkOwner();
checkCurrentPatchSetEntity(); checkCurrentPatchSetEntity();

View File

@@ -50,7 +50,7 @@ class DeleteDraftChangeOp extends BatchUpdate.Op {
static ReviewDb unwrap(ReviewDb db) { static ReviewDb unwrap(ReviewDb db) {
// This is special. We want to delete exactly the rows that are present in // This is special. We want to delete exactly the rows that are present in
// the database, even when reading everything else from notedb, so we need // the database, even when reading everything else from NoteDb, so we need
// to bypass the write-only wrapper. // to bypass the write-only wrapper.
if (db instanceof BatchUpdateReviewDb) { if (db instanceof BatchUpdateReviewDb) {
db = ((BatchUpdateReviewDb) db).unsafeGetDelegate(); db = ((BatchUpdateReviewDb) db).unsafeGetDelegate();
@@ -108,7 +108,7 @@ class DeleteDraftChangeOp extends BatchUpdate.Op {
db.accountPatchReviews().byPatchSet(ps.getId())); db.accountPatchReviews().byPatchSet(ps.getId()));
} }
// Only delete from reviewdb here; deletion from notedb is handled in // Only delete from ReviewDb here; deletion from NoteDb is handled in
// BatchUpdate. // BatchUpdate.
db.patchComments().delete(db.patchComments().byChange(id)); db.patchComments().delete(db.patchComments().byChange(id));
db.patchSetApprovals().delete(db.patchSetApprovals().byChange(id)); db.patchSetApprovals().delete(db.patchSetApprovals().byChange(id));

View File

@@ -136,7 +136,7 @@ public class DeleteDraftPatchSet implements RestModifyView<RevisionResource, Inp
private void deleteDraftPatchSet(PatchSet patchSet, ChangeContext ctx) private void deleteDraftPatchSet(PatchSet patchSet, ChangeContext ctx)
throws OrmException { throws OrmException {
// For notedb itself, no need to delete these entities, as they are // For NoteDb itself, no need to delete these entities, as they are
// automatically filtered out when patch sets are deleted. // automatically filtered out when patch sets are deleted.
psUtil.delete(ctx.getDb(), ctx.getUpdate(patchSet.getId()), patchSet); psUtil.delete(ctx.getDb(), ctx.getUpdate(patchSet.getId()), patchSet);

View File

@@ -480,7 +480,7 @@ public class PostReview implements RestModifyView<RevisionResource, ReviewInput>
} }
ChangeUpdate u = ctx.getUpdate(psId); ChangeUpdate u = ctx.getUpdate(psId);
// TODO(dborowitz): Currently doesn't work for PUBLISH_ALL_REVISIONS with // TODO(dborowitz): Currently doesn't work for PUBLISH_ALL_REVISIONS with
// notedb. // NoteDb.
plcUtil.deleteComments(ctx.getDb(), u, del); plcUtil.deleteComments(ctx.getDb(), u, del);
plcUtil.putComments(ctx.getDb(), u, ups); plcUtil.putComments(ctx.getDb(), u, ups);
comments.addAll(ups); comments.addAll(ups);

View File

@@ -279,7 +279,7 @@ public class LocalDiskRepositoryManager implements GitRepositoryManager,
@Override @Override
public Repository openMetadataRepository(Project.NameKey name) public Repository openMetadataRepository(Project.NameKey name)
throws RepositoryNotFoundException, IOException { throws RepositoryNotFoundException, IOException {
checkState(notesMigration.readChanges(), "notedb disabled"); checkState(notesMigration.readChanges(), "NoteDb disabled");
try { try {
return openRepository(noteDbPath, name); return openRepository(noteDbPath, name);
} catch (RepositoryNotFoundException e) { } catch (RepositoryNotFoundException e) {

View File

@@ -370,7 +370,7 @@ abstract class SubmitStrategyOp extends BatchUpdate.Op {
update.removeApprovalFor(psa.getAccountId(), psa.getLabel()); update.removeApprovalFor(psa.getAccountId(), psa.getLabel());
} }
// TODO(dborowitz): Don't use a label in notedb; just check when status // TODO(dborowitz): Don't use a label in NoteDb; just check when status
// change happened. // change happened.
for (PatchSetApproval psa : normalized.unchanged()) { for (PatchSetApproval psa : normalized.unchanged()) {
if (includeUnchanged || psa.isLegacySubmit()) { if (includeUnchanged || psa.isLegacySubmit()) {

View File

@@ -59,7 +59,7 @@ public class IndexedChangeQuery extends Predicate<ChangeData>
public static QueryOptions createOptions(IndexConfig config, int start, public static QueryOptions createOptions(IndexConfig config, int start,
int limit, Set<String> fields) { int limit, Set<String> fields) {
// Always include project since it is needed to load the change from notedb. // Always include project since it is needed to load the change from NoteDb.
if (!fields.contains(CHANGE.getName()) if (!fields.contains(CHANGE.getName())
&& !fields.contains(PROJECT.getName())) { && !fields.contains(PROJECT.getName())) {
fields = new HashSet<>(fields); fields = new HashSet<>(fields);

View File

@@ -82,7 +82,7 @@ public abstract class AbstractChangeNotes<T> extends VersionedMetaData {
} }
} }
/** Load default values for any instance variables when notedb is disabled. */ /** Load default values for any instance variables when NoteDb is disabled. */
protected abstract void loadDefaults(); protected abstract void loadDefaults();
/** /**

View File

@@ -42,7 +42,7 @@ public class ChangeDelete {
ru.setExpectedOldObjectId(notes.load().getRevision()); ru.setExpectedOldObjectId(notes.load().getRevision());
ru.setNewObjectId(ObjectId.zeroId()); ru.setNewObjectId(ObjectId.zeroId());
ru.setForceUpdate(true); ru.setForceUpdate(true);
ru.setRefLogMessage("Delete change from notedb", false); ru.setRefLogMessage("Delete change from NoteDb", false);
RefUpdate.Result result = ru.delete(); RefUpdate.Result result = ru.delete();
switch (result) { switch (result) {
case FAST_FORWARD: case FAST_FORWARD:

View File

@@ -202,10 +202,10 @@ public class ChangeNotes extends AbstractChangeNotes<ChangeNotes> {
} }
// TODO(dborowitz): Remove when deleting index schemas <27. // TODO(dborowitz): Remove when deleting index schemas <27.
public ChangeNotes createFromIdOnlyWhenNotedbDisabled( public ChangeNotes createFromIdOnlyWhenNoteDbDisabled(
ReviewDb db, Change.Id changeId) throws OrmException { ReviewDb db, Change.Id changeId) throws OrmException {
checkState(!migration.readChanges(), "do not call" checkState(!migration.readChanges(), "do not call"
+ " createFromIdOnlyWhenNotedbDisabled when notedb is enabled"); + " createFromIdOnlyWhenNoteDbDisabled when NoteDb is enabled");
Change change = unwrap(db).changes().get(changeId); Change change = unwrap(db).changes().get(changeId);
return new ChangeNotes(repoManager, migration, allUsers, noteUtil, return new ChangeNotes(repoManager, migration, allUsers, noteUtil,
change.getProject(), change).load(); change.getProject(), change).load();
@@ -216,10 +216,10 @@ public class ChangeNotes extends AbstractChangeNotes<ChangeNotes> {
* Instantiate ChangeNotes for a change that has been loaded by a batch read * Instantiate ChangeNotes for a change that has been loaded by a batch read
* from the database. * from the database.
*/ */
private ChangeNotes createFromChangeOnlyWhenNotedbDisabled(Change change) private ChangeNotes createFromChangeOnlyWhenNoteDbDisabled(Change change)
throws OrmException { throws OrmException {
checkState(!migration.readChanges(), "do not call" checkState(!migration.readChanges(), "do not call"
+ " createFromChangeWhenNotedbDisabled when notedb is enabled"); + " createFromChangeWhenNoteDbDisabled when NoteDb is enabled");
return new ChangeNotes(repoManager, migration, allUsers, noteUtil, return new ChangeNotes(repoManager, migration, allUsers, noteUtil,
change.getProject(), change).load(); change.getProject(), change).load();
} }
@@ -271,7 +271,7 @@ public class ChangeNotes extends AbstractChangeNotes<ChangeNotes> {
} }
for (Change c : unwrap(db).changes().get(changeIds)) { for (Change c : unwrap(db).changes().get(changeIds)) {
notes.add(createFromChangeOnlyWhenNotedbDisabled(c)); notes.add(createFromChangeOnlyWhenNoteDbDisabled(c));
} }
return notes; return notes;
} }
@@ -292,7 +292,7 @@ public class ChangeNotes extends AbstractChangeNotes<ChangeNotes> {
for (Change c : unwrap(db).changes().get(changeIds)) { for (Change c : unwrap(db).changes().get(changeIds)) {
if (c != null && project.equals(c.getDest().getParentKey())) { if (c != null && project.equals(c.getDest().getParentKey())) {
ChangeNotes cn = createFromChangeOnlyWhenNotedbDisabled(c); ChangeNotes cn = createFromChangeOnlyWhenNoteDbDisabled(c);
if (predicate.apply(cn)) { if (predicate.apply(cn)) {
notes.add(cn); notes.add(cn);
} }
@@ -307,7 +307,7 @@ public class ChangeNotes extends AbstractChangeNotes<ChangeNotes> {
if (migration.readChanges()) { if (migration.readChanges()) {
for (Project.NameKey project : projectCache.all()) { for (Project.NameKey project : projectCache.all()) {
try (Repository repo = repoManager.openRepository(project)) { try (Repository repo = repoManager.openRepository(project)) {
List<ChangeNotes> changes = scanNotedb(repo, db, project); List<ChangeNotes> changes = scanNoteDb(repo, db, project);
for (ChangeNotes cn : changes) { for (ChangeNotes cn : changes) {
if (predicate.apply(cn)) { if (predicate.apply(cn)) {
m.put(project, cn); m.put(project, cn);
@@ -317,7 +317,7 @@ public class ChangeNotes extends AbstractChangeNotes<ChangeNotes> {
} }
} else { } else {
for (Change change : unwrap(db).changes().all()) { for (Change change : unwrap(db).changes().all()) {
ChangeNotes notes = createFromChangeOnlyWhenNotedbDisabled(change); ChangeNotes notes = createFromChangeOnlyWhenNoteDbDisabled(change);
if (predicate.apply(notes)) { if (predicate.apply(notes)) {
m.put(change.getProject(), notes); m.put(change.getProject(), notes);
} }
@@ -332,7 +332,7 @@ public class ChangeNotes extends AbstractChangeNotes<ChangeNotes> {
return scanDb(repo, db); return scanDb(repo, db);
} }
return scanNotedb(repo, db, project); return scanNoteDb(repo, db, project);
} }
private List<ChangeNotes> scanDb(Repository repo, ReviewDb db) private List<ChangeNotes> scanDb(Repository repo, ReviewDb db)
@@ -343,13 +343,13 @@ public class ChangeNotes extends AbstractChangeNotes<ChangeNotes> {
// but still >1. // but still >1.
for (List<Change.Id> batch : Iterables.partition(ids, 30)) { for (List<Change.Id> batch : Iterables.partition(ids, 30)) {
for (Change change : unwrap(db).changes().get(batch)) { for (Change change : unwrap(db).changes().get(batch)) {
notes.add(createFromChangeOnlyWhenNotedbDisabled(change)); notes.add(createFromChangeOnlyWhenNoteDbDisabled(change));
} }
} }
return notes; return notes;
} }
private List<ChangeNotes> scanNotedb(Repository repo, ReviewDb db, private List<ChangeNotes> scanNoteDb(Repository repo, ReviewDb db,
Project.NameKey project) throws OrmException, IOException { Project.NameKey project) throws OrmException, IOException {
Set<Change.Id> ids = scan(repo); Set<Change.Id> ids = scan(repo);
List<ChangeNotes> changeNotes = new ArrayList<>(ids.size()); List<ChangeNotes> changeNotes = new ArrayList<>(ids.size());

View File

@@ -189,15 +189,15 @@ public class ChangeRebuilder {
events.add(new ApprovalEvent(psa, change.getCreatedOn())); events.add(new ApprovalEvent(psa, change.getCreatedOn()));
} }
Change notedbChange = new Change(null, null, null, null, null); Change noteDbChange = new Change(null, null, null, null, null);
for (ChangeMessage msg : db.changeMessages().byChange(changeId)) { for (ChangeMessage msg : db.changeMessages().byChange(changeId)) {
events.add( events.add(
new ChangeMessageEvent(msg, notedbChange, change.getCreatedOn())); new ChangeMessageEvent(msg, noteDbChange, change.getCreatedOn()));
} }
Collections.sort(events, EVENT_ORDER); Collections.sort(events, EVENT_ORDER);
events.add(new FinalUpdatesEvent(change, notedbChange)); events.add(new FinalUpdatesEvent(change, noteDbChange));
EventList<Event> el = new EventList<>(); EventList<Event> el = new EventList<>();
for (Event e : events) { for (Event e : events) {
@@ -632,14 +632,14 @@ public class ChangeRebuilder {
Pattern.compile("^Restored(\n.*)*$"); Pattern.compile("^Restored(\n.*)*$");
private final ChangeMessage message; private final ChangeMessage message;
private final Change notedbChange; private final Change noteDbChange;
ChangeMessageEvent(ChangeMessage message, Change notedbChange, ChangeMessageEvent(ChangeMessage message, Change noteDbChange,
Timestamp changeCreatedOn) { Timestamp changeCreatedOn) {
super(message.getPatchSetId(), message.getAuthor(), super(message.getPatchSetId(), message.getAuthor(),
message.getWrittenOn(), changeCreatedOn); message.getWrittenOn(), changeCreatedOn);
this.message = message; this.message = message;
this.notedbChange = notedbChange; this.noteDbChange = noteDbChange;
} }
@Override @Override
@@ -661,7 +661,7 @@ public class ChangeRebuilder {
if (m.matches()) { if (m.matches()) {
String topic = m.group(1); String topic = m.group(1);
update.setTopic(topic); update.setTopic(topic);
notedbChange.setTopic(topic); noteDbChange.setTopic(topic);
return; return;
} }
@@ -669,13 +669,13 @@ public class ChangeRebuilder {
if (m.matches()) { if (m.matches()) {
String topic = m.group(2); String topic = m.group(2);
update.setTopic(topic); update.setTopic(topic);
notedbChange.setTopic(topic); noteDbChange.setTopic(topic);
return; return;
} }
if (TOPIC_REMOVED_REGEXP.matcher(msg).matches()) { if (TOPIC_REMOVED_REGEXP.matcher(msg).matches()) {
update.setTopic(null); update.setTopic(null);
notedbChange.setTopic(null); noteDbChange.setTopic(null);
} }
} }
@@ -683,26 +683,26 @@ public class ChangeRebuilder {
String msg = message.getMessage(); String msg = message.getMessage();
if (STATUS_ABANDONED_REGEXP.matcher(msg).matches()) { if (STATUS_ABANDONED_REGEXP.matcher(msg).matches()) {
update.setStatus(Change.Status.ABANDONED); update.setStatus(Change.Status.ABANDONED);
notedbChange.setStatus(Change.Status.ABANDONED); noteDbChange.setStatus(Change.Status.ABANDONED);
return; return;
} }
if (STATUS_RESTORED_REGEXP.matcher(msg).matches()) { if (STATUS_RESTORED_REGEXP.matcher(msg).matches()) {
update.setStatus(Change.Status.NEW); update.setStatus(Change.Status.NEW);
notedbChange.setStatus(Change.Status.NEW); noteDbChange.setStatus(Change.Status.NEW);
} }
} }
} }
private static class FinalUpdatesEvent extends Event { private static class FinalUpdatesEvent extends Event {
private final Change change; private final Change change;
private final Change notedbChange; private final Change noteDbChange;
FinalUpdatesEvent(Change change, Change notedbChange) { FinalUpdatesEvent(Change change, Change noteDbChange) {
super(change.currentPatchSetId(), change.getOwner(), super(change.currentPatchSetId(), change.getOwner(),
change.getLastUpdatedOn(), change.getCreatedOn()); change.getLastUpdatedOn(), change.getCreatedOn());
this.change = change; this.change = change;
this.notedbChange = notedbChange; this.noteDbChange = noteDbChange;
} }
@Override @Override
@@ -713,10 +713,10 @@ public class ChangeRebuilder {
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
@Override @Override
void apply(ChangeUpdate update) throws OrmException { void apply(ChangeUpdate update) throws OrmException {
if (!Objects.equals(change.getTopic(), notedbChange.getTopic())) { if (!Objects.equals(change.getTopic(), noteDbChange.getTopic())) {
update.setTopic(change.getTopic()); update.setTopic(change.getTopic());
} }
if (!Objects.equals(change.getStatus(), notedbChange.getStatus())) { if (!Objects.equals(change.getStatus(), noteDbChange.getStatus())) {
// TODO(dborowitz): Stamp approximate approvals at this time. // TODO(dborowitz): Stamp approximate approvals at this time.
update.fixStatus(change.getStatus()); update.fixStatus(change.getStatus());
} }
@@ -724,7 +724,7 @@ public class ChangeRebuilder {
update.setSubmissionId(change.getSubmissionId()); update.setSubmissionId(change.getSubmissionId());
} }
if (!update.isEmpty()) { if (!update.isEmpty()) {
update.setSubjectForCommit("Final notedb migration updates"); update.setSubjectForCommit("Final NoteDb migration updates");
} }
} }
} }

View File

@@ -53,7 +53,7 @@ public class ConfigNotesMigration extends NotesMigration {
} }
} }
private static final String NOTEDB = "notedb"; private static final String NOTE_DB = "noteDb";
private static final String READ = "read"; private static final String READ = "read";
private static final String WRITE = "write"; private static final String WRITE = "write";
@@ -62,16 +62,16 @@ public class ConfigNotesMigration extends NotesMigration {
for (Table t : Table.values()) { for (Table t : Table.values()) {
keys.add(t.key()); keys.add(t.key());
} }
for (String t : cfg.getSubsections(NOTEDB)) { for (String t : cfg.getSubsections(NOTE_DB)) {
checkArgument(keys.contains(t.toLowerCase()), checkArgument(keys.contains(t.toLowerCase()),
"invalid notedb table: %s", t); "invalid NoteDb table: %s", t);
for (String key : cfg.getNames(NOTEDB, t)) { for (String key : cfg.getNames(NOTE_DB, t)) {
String lk = key.toLowerCase(); String lk = key.toLowerCase();
checkArgument(lk.equals(WRITE) || lk.equals(READ), checkArgument(lk.equals(WRITE) || lk.equals(READ),
"invalid notedb key: %s.%s", t, key); "invalid NoteDb key: %s.%s", t, key);
} }
boolean write = cfg.getBoolean(NOTEDB, t, WRITE, false); boolean write = cfg.getBoolean(NOTE_DB, t, WRITE, false);
boolean read = cfg.getBoolean(NOTEDB, t, READ, false); boolean read = cfg.getBoolean(NOTE_DB, t, READ, false);
checkArgument(!(read && !write), checkArgument(!(read && !write),
"must have write enabled when read enabled: %s", t); "must have write enabled when read enabled: %s", t);
} }
@@ -80,8 +80,8 @@ public class ConfigNotesMigration extends NotesMigration {
public static Config allEnabledConfig() { public static Config allEnabledConfig() {
Config cfg = new Config(); Config cfg = new Config();
for (Table t : Table.values()) { for (Table t : Table.values()) {
cfg.setBoolean(NOTEDB, t.key(), WRITE, true); cfg.setBoolean(NOTE_DB, t.key(), WRITE, true);
cfg.setBoolean(NOTEDB, t.key(), READ, true); cfg.setBoolean(NOTE_DB, t.key(), READ, true);
} }
return cfg; return cfg;
} }
@@ -92,8 +92,8 @@ public class ConfigNotesMigration extends NotesMigration {
@Inject @Inject
ConfigNotesMigration(@GerritServerConfig Config cfg) { ConfigNotesMigration(@GerritServerConfig Config cfg) {
checkConfig(cfg); checkConfig(cfg);
writeChanges = cfg.getBoolean(NOTEDB, Table.CHANGES.key(), WRITE, false); writeChanges = cfg.getBoolean(NOTE_DB, Table.CHANGES.key(), WRITE, false);
readChanges = cfg.getBoolean(NOTEDB, Table.CHANGES.key(), READ, false); readChanges = cfg.getBoolean(NOTE_DB, Table.CHANGES.key(), READ, false);
} }
@Override @Override

View File

@@ -24,7 +24,7 @@ public enum PatchSetState {
/** /**
* Deleted patch set. * Deleted patch set.
* <p> * <p>
* Used internally as a tombstone; patch sets exposed by public notedb * Used internally as a tombstone; patch sets exposed by public NoteDb
* interfaces never have this state. * interfaces never have this state.
*/ */
DELETED; DELETED;

View File

@@ -281,7 +281,7 @@ public class ChangeData {
ChangeData create(ReviewDb db, ChangeControl c); ChangeData create(ReviewDb db, ChangeControl c);
// TODO(dborowitz): Remove when deleting index schemas <27. // TODO(dborowitz): Remove when deleting index schemas <27.
ChangeData createOnlyWhenNotedbDisabled(ReviewDb db, Change.Id id); ChangeData createOnlyWhenNoteDbDisabled(ReviewDb db, Change.Id id);
} }
/** /**
@@ -506,7 +506,7 @@ public class ChangeData {
@Assisted ReviewDb db, @Assisted ReviewDb db,
@Assisted Change.Id id) { @Assisted Change.Id id) {
checkState(!notesMigration.readChanges(), checkState(!notesMigration.readChanges(),
"do not call createOnlyWhenNotedbDisabled when notedb is enabled"); "do not call createOnlyWhenNoteDbDisabled when NoteDb is enabled");
this.db = db; this.db = db;
this.repoManager = repoManager; this.repoManager = repoManager;
this.changeControlFactory = changeControlFactory; this.changeControlFactory = changeControlFactory;
@@ -629,7 +629,7 @@ public class ChangeData {
public Project.NameKey project() throws OrmException { public Project.NameKey project() throws OrmException {
if (project == null) { if (project == null) {
checkState(!notesMigration.readChanges(), "should not have created " checkState(!notesMigration.readChanges(), "should not have created "
+ " ChangeData without a project when notedb is enabled"); + " ChangeData without a project when NoteDb is enabled");
project = change().getProject(); project = change().getProject();
} }
return project; return project;
@@ -699,7 +699,7 @@ public class ChangeData {
public Change reloadChange() throws OrmException { public Change reloadChange() throws OrmException {
if (project == null) { if (project == null) {
notes = notesFactory.createFromIdOnlyWhenNotedbDisabled(db, legacyId); notes = notesFactory.createFromIdOnlyWhenNoteDbDisabled(db, legacyId);
} else { } else {
notes = notesFactory.create(db, project, legacyId); notes = notesFactory.create(db, project, legacyId);
} }

View File

@@ -32,7 +32,7 @@ import com.google.gwtorm.server.OrmException;
import com.google.gwtorm.server.ResultSet; import com.google.gwtorm.server.ResultSet;
public class DisabledChangesReviewDbWrapper extends ReviewDbWrapper { public class DisabledChangesReviewDbWrapper extends ReviewDbWrapper {
private static final String MSG = "This table has been migrated to notedb"; private static final String MSG = "This table has been migrated to NoteDb";
private final DisabledChangeAccess changes; private final DisabledChangeAccess changes;
private final DisabledPatchSetApprovalAccess patchSetApprovals; private final DisabledPatchSetApprovalAccess patchSetApprovals;

View File

@@ -25,7 +25,7 @@ import java.lang.annotation.Retention;
* that talks to the underlying traditional {@link * that talks to the underlying traditional {@link
* com.google.gerrit.reviewdb.server.ReviewDb} database. * com.google.gerrit.reviewdb.server.ReviewDb} database.
* <p> * <p>
* During the migration to notedb, the actual {@code ReviewDb} will be a wrapper * During the migration to NoteDb, the actual {@code ReviewDb} will be a wrapper
* with certain tables enabled/disabled; this marker goes on the low-level * with certain tables enabled/disabled; this marker goes on the low-level
* implementation that has all tables. * implementation that has all tables.
*/ */

View File

@@ -1019,7 +1019,7 @@ public abstract class AbstractQueryChangesTest extends GerritServerTests {
} }
@Test @Test
public void byHashtagWithNotedb() throws Exception { public void byHashtagWithNoteDb() throws Exception {
assume().that(notesMigration.enabled()).isTrue(); assume().that(notesMigration.enabled()).isTrue();
List<Change> changes = setUpHashtagChanges(); List<Change> changes = setUpHashtagChanges();
assertQuery("hashtag:foo", changes.get(1), changes.get(0)); assertQuery("hashtag:foo", changes.get(1), changes.get(0));
@@ -1032,7 +1032,7 @@ public abstract class AbstractQueryChangesTest extends GerritServerTests {
} }
@Test @Test
public void byHashtagWithoutNotedb() throws Exception { public void byHashtagWithoutNoteDb() throws Exception {
assume().that(notesMigration.enabled()).isFalse(); assume().that(notesMigration.enabled()).isFalse();
setUpHashtagChanges(); setUpHashtagChanges();
assertQuery("hashtag:foo"); assertQuery("hashtag:foo");
@@ -1335,7 +1335,7 @@ public abstract class AbstractQueryChangesTest extends GerritServerTests {
cd.reviewedBy(); cd.reviewedBy();
// TODO(dborowitz): Swap out GitRepositoryManager somehow? Will probably be // TODO(dborowitz): Swap out GitRepositoryManager somehow? Will probably be
// necessary for notedb anyway. // necessary for NoteDb anyway.
cd.isMergeable(); cd.isMergeable();
exception.expect(DisabledReviewDb.Disabled.class); exception.expect(DisabledReviewDb.Disabled.class);

View File

@@ -114,7 +114,7 @@ public class TestChanges {
return update; return update;
} }
// Change doesn't exist yet. Notedb requires that there be a commit for the // Change doesn't exist yet. NoteDb requires that there be a commit for the
// first patch set, so create one. // first patch set, so create one.
try (Repository repo = repoManager.openRepository(c.getProject())) { try (Repository repo = repoManager.openRepository(c.getProject())) {
TestRepository<Repository> tr = new TestRepository<>(repo); TestRepository<Repository> tr = new TestRepository<>(repo);