Package com.google.gerrit.server
Class DeleteZombieComments<KeyT>
java.lang.Object
com.google.gerrit.server.DeleteZombieComments<KeyT>
- All Implemented Interfaces:
AutoCloseable
- Direct Known Subclasses:
DeleteZombieCommentsRefs
This class can be used to clean zombie draft comments. More context in
https://gerrit-review.googlesource.com/c/gerrit/+/246233
The implementation has two cases for detecting zombie drafts:
- An earlier bug in the deletion of draft comments caused some draft refs to remain empty but not get deleted.
- Inspecting all draft-comments. Check for each draft if there exists a published comment
with the same UUID. These comments are called zombie drafts. If the program is run in
dryRun
mode, the zombie draft IDs will only be logged for tracking, otherwise they will also be deleted.
-
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
DeleteZombieComments
(Integer cleanupPercentage, boolean dryRun, Consumer<String> uiConsumer, GitRepositoryManager repoManager, DraftCommentsReader draftCommentsReader, ChangeNotes.Factory changeNotesFactory, CommentsUtil commentsUtil) -
Method Summary
Modifier and TypeMethodDescriptionabstract void
close()
protected abstract void
deleteEmptyDraftsByKey
(Collection<KeyT> keys) protected abstract void
deleteZombieDrafts
(com.google.common.collect.ListMultimap<KeyT, HumanComment> drafts) int
execute()
Deletes all draft comments.protected abstract Account.Id
getAccountId
(KeyT key) protected abstract Change.Id
getChangeId
(KeyT key) protected ChangeNotes
getChangeNotes
(Change.Id changeId) com.google.common.collect.ListMultimap<KeyT,
HumanComment> protected abstract String
protected void
abstract void
setup()
-
Field Details
-
dryRun
protected final boolean dryRun
-
-
Constructor Details
-
DeleteZombieComments
protected DeleteZombieComments(Integer cleanupPercentage, boolean dryRun, Consumer<String> uiConsumer, GitRepositoryManager repoManager, DraftCommentsReader draftCommentsReader, ChangeNotes.Factory changeNotesFactory, CommentsUtil commentsUtil)
-
-
Method Details
-
execute
Deletes all draft comments. Returns the number of zombie draft comments that were deleted.- Throws:
IOException
-
setup
- Throws:
IOException
-
close
- Specified by:
close
in interfaceAutoCloseable
- Throws:
IOException
-
listAllDrafts
- Throws:
IOException
-
listEmptyDrafts
- Throws:
IOException
-
deleteEmptyDraftsByKey
- Throws:
IOException
-
deleteZombieDrafts
protected abstract void deleteZombieDrafts(com.google.common.collect.ListMultimap<KeyT, HumanComment> drafts) throws IOException- Throws:
IOException
-
getChangeId
-
getAccountId
-
loggable
-
getChangeNotes
-
listDraftCommentsThatAreAlsoPublished
public com.google.common.collect.ListMultimap<KeyT,HumanComment> listDraftCommentsThatAreAlsoPublished() throws IOException- Throws:
IOException
-
logInfo
-