Include a UUID portion in NoteDb author identities

Author identities include per-server specific account IDs, so it is
not safe to mix IDs from different servers. Ensure each server only
ever produces identities with one ID during its lifetime, by writing
out a random UUID to gerrit.config as gerrit.serverId. This happens
during init, and optionally lazily during startup.

For now NoteDb changes can be migrated between servers as long as this
file is kept intact. Eventually, when federating changes between
servers, we will need come up with some mechanism for coalescing
various per-server identities into a single account, like the current
AccountExternalId mapping (except not exactly that because Shawn
regrets it). Such a mechanism will simply need to know how to handle
this kind of UUID format.

Change-Id: I9492c9c561892488703d15f7cde6094aa03f957b
This commit is contained in:
Dave Borowitz
2016-03-08 20:45:44 -05:00
parent f531d0aeb9
commit f367b5d3ae
24 changed files with 317 additions and 162 deletions

View File

@@ -48,34 +48,40 @@ public class DraftCommentNotes extends AbstractChangeNotes<DraftCommentNotes> {
private final GitRepositoryManager repoManager;
private final NotesMigration migration;
private final AllUsersName draftsProject;
private final CommentsInNotesUtil commentsUtil;
@VisibleForTesting
@Inject
public Factory(GitRepositoryManager repoManager,
NotesMigration migration,
AllUsersName allUsers) {
AllUsersName allUsers,
CommentsInNotesUtil commentsUtil) {
this.repoManager = repoManager;
this.migration = migration;
this.draftsProject = allUsers;
this.commentsUtil = commentsUtil;
}
public DraftCommentNotes create(Change.Id changeId, Account.Id accountId) {
return new DraftCommentNotes(repoManager, migration, draftsProject,
changeId, accountId);
commentsUtil, changeId, accountId);
}
}
private final AllUsersName draftsProject;
private final CommentsInNotesUtil commentsUtil;
private final Account.Id author;
private ImmutableListMultimap<RevId, PatchLineComment> comments;
private RevisionNoteMap revisionNoteMap;
DraftCommentNotes(GitRepositoryManager repoManager, NotesMigration migration,
AllUsersName draftsProject, Change.Id changeId, Account.Id author) {
AllUsersName draftsProject, CommentsInNotesUtil commentsUtil,
Change.Id changeId, Account.Id author) {
super(repoManager, migration, changeId);
this.draftsProject = draftsProject;
this.author = author;
this.commentsUtil = commentsUtil;
}
RevisionNoteMap getRevisionNoteMap() {
@@ -116,7 +122,8 @@ public class DraftCommentNotes extends AbstractChangeNotes<DraftCommentNotes> {
try (RevWalk walk = new RevWalk(reader)) {
RevCommit tipCommit = walk.parseCommit(rev);
revisionNoteMap = RevisionNoteMap.parse(
getChangeId(), reader, NoteMap.read(reader, tipCommit), true);
commentsUtil, getChangeId(), reader, NoteMap.read(reader, tipCommit),
true);
Multimap<RevId, PatchLineComment> cs = ArrayListMultimap.create();
for (RevisionNote rn : revisionNoteMap.revisionNotes.values()) {
for (PatchLineComment c : rn.comments) {