Move BatchUpdate *Op and Listener to new files
Also make them interfaces, which is a more natural fit. We now have default method implementations, so an abstract class is not required here. Since we have new public interfaces, document them more thoroughly. Change-Id: Ida16b36cbecffffd9170ecdeaf130b4c9294cebb
This commit is contained in:
parent
b91cf223be
commit
b5aea604d6
|
@ -109,6 +109,7 @@ import com.google.gerrit.server.notedb.NoteDbChangeState.PrimaryStorage;
|
|||
import com.google.gerrit.server.project.ChangeControl;
|
||||
import com.google.gerrit.server.project.Util;
|
||||
import com.google.gerrit.server.update.BatchUpdate;
|
||||
import com.google.gerrit.server.update.BatchUpdateOp;
|
||||
import com.google.gerrit.server.update.ChangeContext;
|
||||
import com.google.gerrit.testutil.FakeEmailSender.Message;
|
||||
import com.google.gerrit.testutil.TestTimeUtil;
|
||||
|
@ -2510,7 +2511,7 @@ public class ChangeIT extends AbstractDaemonTest {
|
|||
assertThat(changeStatus).isEqualTo(newStatus.asChangeStatus());
|
||||
}
|
||||
|
||||
private static class ChangeStatusUpdateOp extends BatchUpdate.Op {
|
||||
private static class ChangeStatusUpdateOp implements BatchUpdateOp {
|
||||
private final Change.Status newStatus;
|
||||
|
||||
ChangeStatusUpdateOp(Change.Status newStatus) {
|
||||
|
|
|
@ -70,6 +70,7 @@ import com.google.gerrit.server.git.validators.OnSubmitValidationListener;
|
|||
import com.google.gerrit.server.notedb.ChangeNotes;
|
||||
import com.google.gerrit.server.project.Util;
|
||||
import com.google.gerrit.server.update.BatchUpdate;
|
||||
import com.google.gerrit.server.update.BatchUpdateOp;
|
||||
import com.google.gerrit.server.update.ChangeContext;
|
||||
import com.google.gerrit.server.validators.ValidationException;
|
||||
import com.google.gerrit.testutil.ConfigSuite;
|
||||
|
@ -744,7 +745,7 @@ public abstract class AbstractSubmit extends AbstractDaemonTest {
|
|||
updateFactory.create(db, project, userFactory.create(admin.id), TimeUtil.nowTs())) {
|
||||
bu.addOp(
|
||||
change.getChange().getId(),
|
||||
new BatchUpdate.Op() {
|
||||
new BatchUpdateOp() {
|
||||
@Override
|
||||
public boolean updateChange(ChangeContext ctx) throws OrmException {
|
||||
ctx.getChange().setStatus(Change.Status.NEW);
|
||||
|
|
|
@ -42,6 +42,7 @@ import com.google.gerrit.reviewdb.client.Change;
|
|||
import com.google.gerrit.reviewdb.client.PatchSet;
|
||||
import com.google.gerrit.server.notedb.PatchSetState;
|
||||
import com.google.gerrit.server.update.BatchUpdate;
|
||||
import com.google.gerrit.server.update.BatchUpdateOp;
|
||||
import com.google.gerrit.server.update.ChangeContext;
|
||||
import com.google.gerrit.testutil.ConfigSuite;
|
||||
import com.google.inject.Inject;
|
||||
|
@ -276,7 +277,7 @@ public class DraftChangeIT extends AbstractDaemonTest {
|
|||
return revisionInfos.stream().map(revisionInfo -> revisionInfo.draft).collect(toList());
|
||||
}
|
||||
|
||||
private class MarkChangeAsDraftUpdateOp extends BatchUpdate.Op {
|
||||
private class MarkChangeAsDraftUpdateOp implements BatchUpdateOp {
|
||||
@Override
|
||||
public boolean updateChange(ChangeContext ctx) throws Exception {
|
||||
Change change = ctx.getChange();
|
||||
|
@ -292,7 +293,7 @@ public class DraftChangeIT extends AbstractDaemonTest {
|
|||
}
|
||||
}
|
||||
|
||||
private class DraftStatusOfPatchSetsUpdateOp extends BatchUpdate.Op {
|
||||
private class DraftStatusOfPatchSetsUpdateOp implements BatchUpdateOp {
|
||||
private final boolean draftStatus;
|
||||
|
||||
DraftStatusOfPatchSetsUpdateOp(boolean draftStatus) {
|
||||
|
|
|
@ -50,6 +50,7 @@ import com.google.gerrit.server.notedb.ChangeNoteUtil;
|
|||
import com.google.gerrit.server.notedb.NoteDbChangeState.PrimaryStorage;
|
||||
import com.google.gerrit.server.project.ChangeControl;
|
||||
import com.google.gerrit.server.update.BatchUpdate;
|
||||
import com.google.gerrit.server.update.BatchUpdateOp;
|
||||
import com.google.gerrit.server.update.ChangeContext;
|
||||
import com.google.gerrit.server.update.RepoContext;
|
||||
import com.google.gerrit.testutil.InMemoryRepositoryManager;
|
||||
|
@ -360,7 +361,7 @@ public class ConsistencyCheckerIT extends AbstractDaemonTest {
|
|||
try (BatchUpdate bu = newUpdate(adminId)) {
|
||||
bu.addOp(
|
||||
ctl.getId(),
|
||||
new BatchUpdate.Op() {
|
||||
new BatchUpdateOp() {
|
||||
@Override
|
||||
public boolean updateChange(ChangeContext ctx) throws OrmException {
|
||||
ctx.getChange().setStatus(Change.Status.MERGED);
|
||||
|
@ -916,7 +917,7 @@ public class ConsistencyCheckerIT extends AbstractDaemonTest {
|
|||
try (BatchUpdate bu = newUpdate(adminId)) {
|
||||
bu.addOp(
|
||||
ctl.getId(),
|
||||
new BatchUpdate.Op() {
|
||||
new BatchUpdateOp() {
|
||||
@Override
|
||||
public void updateRepo(RepoContext ctx) throws IOException {
|
||||
ctx.addRefUpdate(new ReceiveCommand(oldId, newId, dest));
|
||||
|
|
|
@ -36,6 +36,7 @@ import com.google.gerrit.server.change.GetRelated.ChangeAndCommit;
|
|||
import com.google.gerrit.server.change.GetRelated.RelatedInfo;
|
||||
import com.google.gerrit.server.query.change.ChangeData;
|
||||
import com.google.gerrit.server.update.BatchUpdate;
|
||||
import com.google.gerrit.server.update.BatchUpdateOp;
|
||||
import com.google.gerrit.server.update.ChangeContext;
|
||||
import com.google.gerrit.testutil.TestTimeUtil;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
|
@ -580,7 +581,7 @@ public class GetRelatedIT extends AbstractDaemonTest {
|
|||
try (BatchUpdate bu = updateFactory.create(db, project, user(user), TimeUtil.nowTs())) {
|
||||
bu.addOp(
|
||||
psId.getParentKey(),
|
||||
new BatchUpdate.Op() {
|
||||
new BatchUpdateOp() {
|
||||
@Override
|
||||
public boolean updateChange(ChangeContext ctx) throws OrmException {
|
||||
PatchSet ps = psUtil.get(ctx.getDb(), ctx.getNotes(), psId);
|
||||
|
|
|
@ -78,6 +78,7 @@ import com.google.gerrit.server.patch.PatchSetInfoNotAvailableException;
|
|||
import com.google.gerrit.server.project.Util;
|
||||
import com.google.gerrit.server.query.change.ChangeData;
|
||||
import com.google.gerrit.server.update.BatchUpdate;
|
||||
import com.google.gerrit.server.update.BatchUpdateOp;
|
||||
import com.google.gerrit.server.update.ChangeContext;
|
||||
import com.google.gerrit.server.update.UpdateException;
|
||||
import com.google.gerrit.testutil.ConfigSuite;
|
||||
|
@ -455,7 +456,7 @@ public class ChangeRebuilderIT extends AbstractDaemonTest {
|
|||
db, project, identifiedUserFactory.create(user.getId()), TimeUtil.nowTs())) {
|
||||
bu.addOp(
|
||||
id,
|
||||
new BatchUpdate.Op() {
|
||||
new BatchUpdateOp() {
|
||||
@Override
|
||||
public boolean updateChange(ChangeContext ctx) throws OrmException {
|
||||
PatchSet.Id psId = ctx.getChange().currentPatchSetId();
|
||||
|
@ -1147,7 +1148,7 @@ public class ChangeRebuilderIT extends AbstractDaemonTest {
|
|||
db, project, identifiedUserFactory.create(user.getId()), TimeUtil.nowTs())) {
|
||||
bu.addOp(
|
||||
id,
|
||||
new BatchUpdate.Op() {
|
||||
new BatchUpdateOp() {
|
||||
@Override
|
||||
public boolean updateChange(ChangeContext ctx)
|
||||
throws PatchSetInfoNotAvailableException {
|
||||
|
|
|
@ -57,9 +57,9 @@ import com.google.gerrit.server.project.NoSuchProjectException;
|
|||
import com.google.gerrit.server.project.ProjectControl;
|
||||
import com.google.gerrit.server.project.RefControl;
|
||||
import com.google.gerrit.server.ssh.NoSshInfo;
|
||||
import com.google.gerrit.server.update.BatchUpdate;
|
||||
import com.google.gerrit.server.update.ChangeContext;
|
||||
import com.google.gerrit.server.update.Context;
|
||||
import com.google.gerrit.server.update.InsertChangeOp;
|
||||
import com.google.gerrit.server.update.RepoContext;
|
||||
import com.google.gerrit.server.util.RequestScopePropagator;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
|
@ -80,7 +80,7 @@ import org.eclipse.jgit.util.ChangeIdUtil;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class ChangeInserter extends BatchUpdate.InsertChangeOp {
|
||||
public class ChangeInserter implements InsertChangeOp {
|
||||
public interface Factory {
|
||||
ChangeInserter create(Change.Id cid, RevCommit rc, String refName);
|
||||
}
|
||||
|
|
|
@ -48,6 +48,7 @@ import com.google.gerrit.server.project.RefControl;
|
|||
import com.google.gerrit.server.query.change.ChangeData;
|
||||
import com.google.gerrit.server.query.change.InternalChangeQuery;
|
||||
import com.google.gerrit.server.update.BatchUpdate;
|
||||
import com.google.gerrit.server.update.BatchUpdateOp;
|
||||
import com.google.gerrit.server.update.ChangeContext;
|
||||
import com.google.gerrit.server.update.UpdateException;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
|
@ -279,7 +280,7 @@ public class CherryPickChange {
|
|||
return changeId;
|
||||
}
|
||||
|
||||
private static class AddMessageToSourceChangeOp extends BatchUpdate.Op {
|
||||
private static class AddMessageToSourceChangeOp implements BatchUpdateOp {
|
||||
private final ChangeMessagesUtil cmUtil;
|
||||
private final PatchSet.Id psId;
|
||||
private final String destBranch;
|
||||
|
|
|
@ -51,6 +51,7 @@ import com.google.gerrit.server.patch.PatchSetInfoFactory;
|
|||
import com.google.gerrit.server.patch.PatchSetInfoNotAvailableException;
|
||||
import com.google.gerrit.server.project.ChangeControl;
|
||||
import com.google.gerrit.server.update.BatchUpdate;
|
||||
import com.google.gerrit.server.update.BatchUpdateOp;
|
||||
import com.google.gerrit.server.update.ChangeContext;
|
||||
import com.google.gerrit.server.update.RepoContext;
|
||||
import com.google.gerrit.server.update.UpdateException;
|
||||
|
@ -498,7 +499,7 @@ public class ConsistencyChecker {
|
|||
// PatchSetInserter will reinsert the same ref, making it a no-op.
|
||||
bu.addOp(
|
||||
ctl.getId(),
|
||||
new BatchUpdate.Op() {
|
||||
new BatchUpdateOp() {
|
||||
@Override
|
||||
public void updateRepo(RepoContext ctx) throws IOException {
|
||||
ctx.addRefUpdate(
|
||||
|
@ -536,7 +537,7 @@ public class ConsistencyChecker {
|
|||
}
|
||||
}
|
||||
|
||||
private static class FixMergedOp extends BatchUpdate.Op {
|
||||
private static class FixMergedOp implements BatchUpdateOp {
|
||||
private final ProblemInfo p;
|
||||
|
||||
private FixMergedOp(ProblemInfo p) {
|
||||
|
@ -632,7 +633,7 @@ public class ConsistencyChecker {
|
|||
}
|
||||
}
|
||||
|
||||
private class DeletePatchSetFromDbOp extends BatchUpdate.Op {
|
||||
private class DeletePatchSetFromDbOp implements BatchUpdateOp {
|
||||
private final ProblemInfo p;
|
||||
private final PatchSet.Id psId;
|
||||
|
||||
|
@ -670,7 +671,7 @@ public class ConsistencyChecker {
|
|||
}
|
||||
}
|
||||
|
||||
private class UpdateCurrentPatchSetOp extends BatchUpdate.Op {
|
||||
private class UpdateCurrentPatchSetOp implements BatchUpdateOp {
|
||||
private final Set<PatchSet.Id> toDelete;
|
||||
|
||||
private UpdateCurrentPatchSetOp(List<DeletePatchSetFromDbOp> deleteOps) {
|
||||
|
|
|
@ -35,6 +35,7 @@ import com.google.gerrit.server.CommentsUtil;
|
|||
import com.google.gerrit.server.PatchSetUtil;
|
||||
import com.google.gerrit.server.patch.PatchListCache;
|
||||
import com.google.gerrit.server.update.BatchUpdate;
|
||||
import com.google.gerrit.server.update.BatchUpdateOp;
|
||||
import com.google.gerrit.server.update.ChangeContext;
|
||||
import com.google.gerrit.server.update.UpdateException;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
|
@ -91,7 +92,7 @@ public class CreateDraftComment implements RestModifyView<RevisionResource, Draf
|
|||
}
|
||||
}
|
||||
|
||||
private class Op extends BatchUpdate.Op {
|
||||
private class Op implements BatchUpdateOp {
|
||||
private final PatchSet.Id psId;
|
||||
private final DraftInput in;
|
||||
|
||||
|
|
|
@ -31,6 +31,7 @@ import com.google.gerrit.server.change.DeleteAssignee.Input;
|
|||
import com.google.gerrit.server.extensions.events.AssigneeChanged;
|
||||
import com.google.gerrit.server.notedb.ChangeUpdate;
|
||||
import com.google.gerrit.server.update.BatchUpdate;
|
||||
import com.google.gerrit.server.update.BatchUpdateOp;
|
||||
import com.google.gerrit.server.update.ChangeContext;
|
||||
import com.google.gerrit.server.update.Context;
|
||||
import com.google.gerrit.server.update.UpdateException;
|
||||
|
@ -81,7 +82,7 @@ public class DeleteAssignee implements RestModifyView<ChangeResource, Input> {
|
|||
}
|
||||
}
|
||||
|
||||
private class Op extends BatchUpdate.Op {
|
||||
private class Op implements BatchUpdateOp {
|
||||
private Change change;
|
||||
private Account deletedAssignee;
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ import com.google.gerrit.server.PatchSetUtil;
|
|||
import com.google.gerrit.server.StarredChangesUtil;
|
||||
import com.google.gerrit.server.config.GerritServerConfig;
|
||||
import com.google.gerrit.server.project.NoSuchChangeException;
|
||||
import com.google.gerrit.server.update.BatchUpdate;
|
||||
import com.google.gerrit.server.update.BatchUpdateOp;
|
||||
import com.google.gerrit.server.update.BatchUpdateReviewDb;
|
||||
import com.google.gerrit.server.update.ChangeContext;
|
||||
import com.google.gerrit.server.update.Order;
|
||||
|
@ -47,7 +47,7 @@ import org.eclipse.jgit.revwalk.RevCommit;
|
|||
import org.eclipse.jgit.revwalk.RevWalk;
|
||||
import org.eclipse.jgit.transport.ReceiveCommand;
|
||||
|
||||
class DeleteChangeOp extends BatchUpdate.Op {
|
||||
class DeleteChangeOp implements BatchUpdateOp {
|
||||
static boolean allowDrafts(Config cfg) {
|
||||
return cfg.getBoolean("change", "allowDrafts", true);
|
||||
}
|
||||
|
|
|
@ -30,6 +30,7 @@ import com.google.gerrit.server.PatchSetUtil;
|
|||
import com.google.gerrit.server.change.DeleteDraftComment.Input;
|
||||
import com.google.gerrit.server.patch.PatchListCache;
|
||||
import com.google.gerrit.server.update.BatchUpdate;
|
||||
import com.google.gerrit.server.update.BatchUpdateOp;
|
||||
import com.google.gerrit.server.update.ChangeContext;
|
||||
import com.google.gerrit.server.update.UpdateException;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
|
@ -79,7 +80,7 @@ public class DeleteDraftComment implements RestModifyView<DraftCommentResource,
|
|||
return Response.none();
|
||||
}
|
||||
|
||||
private class Op extends BatchUpdate.Op {
|
||||
private class Op implements BatchUpdateOp {
|
||||
private final Comment.Key key;
|
||||
|
||||
private Op(Comment.Key key) {
|
||||
|
|
|
@ -34,6 +34,7 @@ import com.google.gerrit.server.patch.PatchSetInfoFactory;
|
|||
import com.google.gerrit.server.patch.PatchSetInfoNotAvailableException;
|
||||
import com.google.gerrit.server.project.NoSuchChangeException;
|
||||
import com.google.gerrit.server.update.BatchUpdate;
|
||||
import com.google.gerrit.server.update.BatchUpdateOp;
|
||||
import com.google.gerrit.server.update.ChangeContext;
|
||||
import com.google.gerrit.server.update.Order;
|
||||
import com.google.gerrit.server.update.RepoContext;
|
||||
|
@ -91,7 +92,7 @@ public class DeleteDraftPatchSet
|
|||
return Response.none();
|
||||
}
|
||||
|
||||
private class Op extends BatchUpdate.Op {
|
||||
private class Op implements BatchUpdateOp {
|
||||
private final PatchSet.Id psId;
|
||||
|
||||
private Collection<PatchSet> patchSetsBeforeDeletion;
|
||||
|
|
|
@ -43,6 +43,7 @@ import com.google.gerrit.server.notedb.ChangeUpdate;
|
|||
import com.google.gerrit.server.notedb.NoteDbChangeState.PrimaryStorage;
|
||||
import com.google.gerrit.server.notedb.NotesMigration;
|
||||
import com.google.gerrit.server.update.BatchUpdate;
|
||||
import com.google.gerrit.server.update.BatchUpdateOp;
|
||||
import com.google.gerrit.server.update.BatchUpdateReviewDb;
|
||||
import com.google.gerrit.server.update.ChangeContext;
|
||||
import com.google.gerrit.server.update.Context;
|
||||
|
@ -125,7 +126,7 @@ public class DeleteReviewer implements RestModifyView<ReviewerResource, DeleteRe
|
|||
return Response.none();
|
||||
}
|
||||
|
||||
private class Op extends BatchUpdate.Op {
|
||||
private class Op implements BatchUpdateOp {
|
||||
private final Account reviewer;
|
||||
private final DeleteReviewerInput input;
|
||||
ChangeMessage changeMessage;
|
||||
|
|
|
@ -43,6 +43,7 @@ import com.google.gerrit.server.mail.send.DeleteVoteSender;
|
|||
import com.google.gerrit.server.mail.send.ReplyToChangeSender;
|
||||
import com.google.gerrit.server.project.ChangeControl;
|
||||
import com.google.gerrit.server.update.BatchUpdate;
|
||||
import com.google.gerrit.server.update.BatchUpdateOp;
|
||||
import com.google.gerrit.server.update.ChangeContext;
|
||||
import com.google.gerrit.server.update.Context;
|
||||
import com.google.gerrit.server.update.UpdateException;
|
||||
|
@ -122,7 +123,7 @@ public class DeleteVote implements RestModifyView<VoteResource, DeleteVoteInput>
|
|||
return Response.none();
|
||||
}
|
||||
|
||||
private class Op extends BatchUpdate.Op {
|
||||
private class Op implements BatchUpdateOp {
|
||||
private final Account.Id accountId;
|
||||
private final String label;
|
||||
private final DeleteVoteInput input;
|
||||
|
|
|
@ -39,6 +39,7 @@ import com.google.gerrit.server.notedb.ChangeUpdate;
|
|||
import com.google.gerrit.server.project.ChangeControl;
|
||||
import com.google.gerrit.server.query.change.InternalChangeQuery;
|
||||
import com.google.gerrit.server.update.BatchUpdate;
|
||||
import com.google.gerrit.server.update.BatchUpdateOp;
|
||||
import com.google.gerrit.server.update.ChangeContext;
|
||||
import com.google.gerrit.server.update.UpdateException;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
|
@ -99,7 +100,7 @@ public class Move implements RestModifyView<ChangeResource, MoveInput> {
|
|||
return json.noOptions().format(req.getChange());
|
||||
}
|
||||
|
||||
private class Op extends BatchUpdate.Op {
|
||||
private class Op implements BatchUpdateOp {
|
||||
private final MoveInput input;
|
||||
|
||||
private Change change;
|
||||
|
|
|
@ -45,7 +45,7 @@ import com.google.gerrit.server.notedb.ChangeUpdate;
|
|||
import com.google.gerrit.server.patch.PatchSetInfoFactory;
|
||||
import com.google.gerrit.server.project.ChangeControl;
|
||||
import com.google.gerrit.server.ssh.NoSshInfo;
|
||||
import com.google.gerrit.server.update.BatchUpdate;
|
||||
import com.google.gerrit.server.update.BatchUpdateOp;
|
||||
import com.google.gerrit.server.update.ChangeContext;
|
||||
import com.google.gerrit.server.update.Context;
|
||||
import com.google.gerrit.server.update.RepoContext;
|
||||
|
@ -61,7 +61,7 @@ import org.eclipse.jgit.transport.ReceiveCommand;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class PatchSetInserter extends BatchUpdate.Op {
|
||||
public class PatchSetInserter implements BatchUpdateOp {
|
||||
private static final Logger log = LoggerFactory.getLogger(PatchSetInserter.class);
|
||||
|
||||
public interface Factory {
|
||||
|
|
|
@ -93,6 +93,7 @@ import com.google.gerrit.server.patch.PatchListCache;
|
|||
import com.google.gerrit.server.project.ChangeControl;
|
||||
import com.google.gerrit.server.query.change.ChangeData;
|
||||
import com.google.gerrit.server.update.BatchUpdate;
|
||||
import com.google.gerrit.server.update.BatchUpdateOp;
|
||||
import com.google.gerrit.server.update.ChangeContext;
|
||||
import com.google.gerrit.server.update.Context;
|
||||
import com.google.gerrit.server.update.UpdateException;
|
||||
|
@ -676,7 +677,7 @@ public class PostReview implements RestModifyView<RevisionResource, ReviewInput>
|
|||
abstract Comment.Range range();
|
||||
}
|
||||
|
||||
private class Op extends BatchUpdate.Op {
|
||||
private class Op implements BatchUpdateOp {
|
||||
private final PatchSet.Id psId;
|
||||
private final ReviewInput in;
|
||||
private final ListMultimap<RecipientType, Account.Id> accountsToNotify;
|
||||
|
|
|
@ -59,6 +59,7 @@ import com.google.gerrit.server.notedb.NotesMigration;
|
|||
import com.google.gerrit.server.project.ChangeControl;
|
||||
import com.google.gerrit.server.project.NoSuchProjectException;
|
||||
import com.google.gerrit.server.update.BatchUpdate;
|
||||
import com.google.gerrit.server.update.BatchUpdateOp;
|
||||
import com.google.gerrit.server.update.ChangeContext;
|
||||
import com.google.gerrit.server.update.Context;
|
||||
import com.google.gerrit.server.update.UpdateException;
|
||||
|
@ -359,7 +360,7 @@ public class PostReviewers implements RestModifyView<ChangeResource, AddReviewer
|
|||
}
|
||||
}
|
||||
|
||||
public class Op extends BatchUpdate.Op {
|
||||
public class Op implements BatchUpdateOp {
|
||||
final Map<Account.Id, ChangeControl> reviewers;
|
||||
final ReviewerState state;
|
||||
final NotifyHandling notify;
|
||||
|
|
|
@ -46,6 +46,7 @@ import com.google.gerrit.server.mail.send.ReplacePatchSetSender;
|
|||
import com.google.gerrit.server.notedb.ChangeUpdate;
|
||||
import com.google.gerrit.server.patch.PatchSetInfoFactory;
|
||||
import com.google.gerrit.server.update.BatchUpdate;
|
||||
import com.google.gerrit.server.update.BatchUpdateOp;
|
||||
import com.google.gerrit.server.update.ChangeContext;
|
||||
import com.google.gerrit.server.update.Context;
|
||||
import com.google.gerrit.server.update.UpdateException;
|
||||
|
@ -149,7 +150,7 @@ public class PublishDraftPatchSet
|
|||
}
|
||||
}
|
||||
|
||||
private class Op extends BatchUpdate.Op {
|
||||
private class Op implements BatchUpdateOp {
|
||||
private final PatchSet.Id psId;
|
||||
|
||||
private PatchSet patchSet;
|
||||
|
|
|
@ -30,6 +30,7 @@ import com.google.gerrit.server.PatchSetUtil;
|
|||
import com.google.gerrit.server.notedb.ChangeUpdate;
|
||||
import com.google.gerrit.server.project.ChangeControl;
|
||||
import com.google.gerrit.server.update.BatchUpdate;
|
||||
import com.google.gerrit.server.update.BatchUpdateOp;
|
||||
import com.google.gerrit.server.update.ChangeContext;
|
||||
import com.google.gerrit.server.update.UpdateException;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
|
@ -81,7 +82,7 @@ public class PutDescription
|
|||
: Response.ok(op.newDescription);
|
||||
}
|
||||
|
||||
private class Op extends BatchUpdate.Op {
|
||||
private class Op implements BatchUpdateOp {
|
||||
private final Input input;
|
||||
private final PatchSet.Id psId;
|
||||
|
||||
|
|
|
@ -34,6 +34,7 @@ import com.google.gerrit.server.PatchSetUtil;
|
|||
import com.google.gerrit.server.notedb.ChangeUpdate;
|
||||
import com.google.gerrit.server.patch.PatchListCache;
|
||||
import com.google.gerrit.server.update.BatchUpdate;
|
||||
import com.google.gerrit.server.update.BatchUpdateOp;
|
||||
import com.google.gerrit.server.update.ChangeContext;
|
||||
import com.google.gerrit.server.update.UpdateException;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
|
@ -100,7 +101,7 @@ public class PutDraftComment implements RestModifyView<DraftCommentResource, Dra
|
|||
}
|
||||
}
|
||||
|
||||
private class Op extends BatchUpdate.Op {
|
||||
private class Op implements BatchUpdateOp {
|
||||
private final Comment.Key key;
|
||||
private final DraftInput in;
|
||||
|
||||
|
|
|
@ -31,6 +31,7 @@ import com.google.gerrit.server.extensions.events.TopicEdited;
|
|||
import com.google.gerrit.server.notedb.ChangeUpdate;
|
||||
import com.google.gerrit.server.project.ChangeControl;
|
||||
import com.google.gerrit.server.update.BatchUpdate;
|
||||
import com.google.gerrit.server.update.BatchUpdateOp;
|
||||
import com.google.gerrit.server.update.ChangeContext;
|
||||
import com.google.gerrit.server.update.Context;
|
||||
import com.google.gerrit.server.update.UpdateException;
|
||||
|
@ -82,7 +83,7 @@ public class PutTopic implements RestModifyView<ChangeResource, Input>, UiAction
|
|||
: Response.ok(op.newTopicName);
|
||||
}
|
||||
|
||||
private class Op extends BatchUpdate.Op {
|
||||
private class Op implements BatchUpdateOp {
|
||||
private final Input input;
|
||||
|
||||
private Change change;
|
||||
|
|
|
@ -31,7 +31,7 @@ import com.google.gerrit.server.project.ChangeControl;
|
|||
import com.google.gerrit.server.project.InvalidChangeOperationException;
|
||||
import com.google.gerrit.server.project.NoSuchChangeException;
|
||||
import com.google.gerrit.server.project.ProjectState;
|
||||
import com.google.gerrit.server.update.BatchUpdate;
|
||||
import com.google.gerrit.server.update.BatchUpdateOp;
|
||||
import com.google.gerrit.server.update.ChangeContext;
|
||||
import com.google.gerrit.server.update.Context;
|
||||
import com.google.gerrit.server.update.RepoContext;
|
||||
|
@ -46,7 +46,7 @@ import org.eclipse.jgit.merge.ThreeWayMerger;
|
|||
import org.eclipse.jgit.revwalk.RevCommit;
|
||||
import org.eclipse.jgit.revwalk.RevWalk;
|
||||
|
||||
public class RebaseChangeOp extends BatchUpdate.Op {
|
||||
public class RebaseChangeOp implements BatchUpdateOp {
|
||||
public interface Factory {
|
||||
RebaseChangeOp create(
|
||||
ChangeControl ctl, PatchSet originalPatchSet, @Nullable String baseCommitish);
|
||||
|
|
|
@ -36,6 +36,7 @@ import com.google.gerrit.server.mail.send.RestoredSender;
|
|||
import com.google.gerrit.server.notedb.ChangeUpdate;
|
||||
import com.google.gerrit.server.project.ChangeControl;
|
||||
import com.google.gerrit.server.update.BatchUpdate;
|
||||
import com.google.gerrit.server.update.BatchUpdateOp;
|
||||
import com.google.gerrit.server.update.ChangeContext;
|
||||
import com.google.gerrit.server.update.Context;
|
||||
import com.google.gerrit.server.update.UpdateException;
|
||||
|
@ -94,7 +95,7 @@ public class Restore
|
|||
return json.noOptions().format(op.change);
|
||||
}
|
||||
|
||||
private class Op extends BatchUpdate.Op {
|
||||
private class Op implements BatchUpdateOp {
|
||||
private final RestoreInput input;
|
||||
|
||||
private Change change;
|
||||
|
|
|
@ -47,6 +47,7 @@ import com.google.gerrit.server.project.NoSuchChangeException;
|
|||
import com.google.gerrit.server.project.ProjectControl;
|
||||
import com.google.gerrit.server.project.RefControl;
|
||||
import com.google.gerrit.server.update.BatchUpdate;
|
||||
import com.google.gerrit.server.update.BatchUpdateOp;
|
||||
import com.google.gerrit.server.update.ChangeContext;
|
||||
import com.google.gerrit.server.update.Context;
|
||||
import com.google.gerrit.server.update.UpdateException;
|
||||
|
@ -237,7 +238,7 @@ public class Revert
|
|||
return change != null ? change.getStatus().name().toLowerCase() : "deleted";
|
||||
}
|
||||
|
||||
private class NotifyOp extends BatchUpdate.Op {
|
||||
private class NotifyOp implements BatchUpdateOp {
|
||||
private final Change change;
|
||||
private final ChangeInserter ins;
|
||||
|
||||
|
@ -261,7 +262,7 @@ public class Revert
|
|||
}
|
||||
}
|
||||
|
||||
private class PostRevertedMessageOp extends BatchUpdate.Op {
|
||||
private class PostRevertedMessageOp implements BatchUpdateOp {
|
||||
private final ObjectId computedChangeId;
|
||||
|
||||
PostRevertedMessageOp(ObjectId computedChangeId) {
|
||||
|
|
|
@ -30,7 +30,7 @@ import com.google.gerrit.server.account.AccountsCollection;
|
|||
import com.google.gerrit.server.extensions.events.AssigneeChanged;
|
||||
import com.google.gerrit.server.mail.send.SetAssigneeSender;
|
||||
import com.google.gerrit.server.notedb.ChangeUpdate;
|
||||
import com.google.gerrit.server.update.BatchUpdate;
|
||||
import com.google.gerrit.server.update.BatchUpdateOp;
|
||||
import com.google.gerrit.server.update.ChangeContext;
|
||||
import com.google.gerrit.server.update.Context;
|
||||
import com.google.gerrit.server.validators.AssigneeValidationListener;
|
||||
|
@ -42,7 +42,7 @@ import com.google.inject.assistedinject.AssistedInject;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class SetAssigneeOp extends BatchUpdate.Op {
|
||||
public class SetAssigneeOp implements BatchUpdateOp {
|
||||
private static final Logger log = LoggerFactory.getLogger(SetAssigneeOp.class);
|
||||
|
||||
public interface Factory {
|
||||
|
|
|
@ -33,7 +33,7 @@ import com.google.gerrit.server.extensions.events.HashtagsEdited;
|
|||
import com.google.gerrit.server.notedb.ChangeNotes;
|
||||
import com.google.gerrit.server.notedb.ChangeUpdate;
|
||||
import com.google.gerrit.server.notedb.NotesMigration;
|
||||
import com.google.gerrit.server.update.BatchUpdate;
|
||||
import com.google.gerrit.server.update.BatchUpdateOp;
|
||||
import com.google.gerrit.server.update.ChangeContext;
|
||||
import com.google.gerrit.server.update.Context;
|
||||
import com.google.gerrit.server.validators.HashtagValidationListener;
|
||||
|
@ -46,7 +46,7 @@ import java.util.Collection;
|
|||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
public class SetHashtagsOp extends BatchUpdate.Op {
|
||||
public class SetHashtagsOp implements BatchUpdateOp {
|
||||
public interface Factory {
|
||||
SetHashtagsOp create(HashtagsInput input);
|
||||
}
|
||||
|
|
|
@ -41,6 +41,7 @@ import com.google.gerrit.server.index.change.ChangeIndexer;
|
|||
import com.google.gerrit.server.project.ChangeControl;
|
||||
import com.google.gerrit.server.project.NoSuchChangeException;
|
||||
import com.google.gerrit.server.update.BatchUpdate;
|
||||
import com.google.gerrit.server.update.BatchUpdateOp;
|
||||
import com.google.gerrit.server.update.RepoContext;
|
||||
import com.google.gerrit.server.update.UpdateException;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
|
@ -214,7 +215,7 @@ public class ChangeEditUtil {
|
|||
.setMessage(message.toString()));
|
||||
bu.addOp(
|
||||
change.getId(),
|
||||
new BatchUpdate.Op() {
|
||||
new BatchUpdateOp() {
|
||||
@Override
|
||||
public void updateRepo(RepoContext ctx) throws Exception {
|
||||
deleteRef(ctx.getRepository(), edit);
|
||||
|
|
|
@ -30,7 +30,7 @@ import com.google.gerrit.server.extensions.events.ChangeAbandoned;
|
|||
import com.google.gerrit.server.mail.send.AbandonedSender;
|
||||
import com.google.gerrit.server.mail.send.ReplyToChangeSender;
|
||||
import com.google.gerrit.server.notedb.ChangeUpdate;
|
||||
import com.google.gerrit.server.update.BatchUpdate;
|
||||
import com.google.gerrit.server.update.BatchUpdateOp;
|
||||
import com.google.gerrit.server.update.ChangeContext;
|
||||
import com.google.gerrit.server.update.Context;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
|
@ -39,7 +39,7 @@ import com.google.inject.assistedinject.AssistedInject;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class AbandonOp extends BatchUpdate.Op {
|
||||
public class AbandonOp implements BatchUpdateOp {
|
||||
private static final Logger log = LoggerFactory.getLogger(AbandonOp.class);
|
||||
|
||||
private final AbandonedSender.Factory abandonedSenderFactory;
|
||||
|
|
|
@ -14,12 +14,12 @@
|
|||
|
||||
package com.google.gerrit.server.git;
|
||||
|
||||
import com.google.gerrit.server.update.BatchUpdate;
|
||||
import com.google.gerrit.server.update.BatchUpdateOp;
|
||||
import com.google.gerrit.server.update.ChangeContext;
|
||||
import org.eclipse.jgit.lib.ProgressMonitor;
|
||||
|
||||
/** Trivial op to update a counter during {@code updateChange} */
|
||||
class ChangeProgressOp extends BatchUpdate.Op {
|
||||
class ChangeProgressOp implements BatchUpdateOp {
|
||||
private final ProgressMonitor progress;
|
||||
|
||||
ChangeProgressOp(ProgressMonitor progress) {
|
||||
|
|
|
@ -64,6 +64,7 @@ import com.google.gerrit.server.project.SubmitRuleOptions;
|
|||
import com.google.gerrit.server.query.change.ChangeData;
|
||||
import com.google.gerrit.server.query.change.InternalChangeQuery;
|
||||
import com.google.gerrit.server.update.BatchUpdate;
|
||||
import com.google.gerrit.server.update.BatchUpdateOp;
|
||||
import com.google.gerrit.server.update.ChangeContext;
|
||||
import com.google.gerrit.server.update.UpdateException;
|
||||
import com.google.gerrit.server.util.RequestId;
|
||||
|
@ -749,7 +750,7 @@ public class MergeOp implements AutoCloseable {
|
|||
bu.setRequestId(submissionId);
|
||||
bu.addOp(
|
||||
cd.getId(),
|
||||
new BatchUpdate.Op() {
|
||||
new BatchUpdateOp() {
|
||||
@Override
|
||||
public boolean updateChange(ChangeContext ctx) throws OrmException {
|
||||
Change change = ctx.getChange();
|
||||
|
|
|
@ -29,7 +29,7 @@ import com.google.gerrit.server.extensions.events.ChangeMerged;
|
|||
import com.google.gerrit.server.mail.send.MergedSender;
|
||||
import com.google.gerrit.server.notedb.ChangeUpdate;
|
||||
import com.google.gerrit.server.patch.PatchSetInfoFactory;
|
||||
import com.google.gerrit.server.update.BatchUpdate;
|
||||
import com.google.gerrit.server.update.BatchUpdateOp;
|
||||
import com.google.gerrit.server.update.ChangeContext;
|
||||
import com.google.gerrit.server.update.Context;
|
||||
import com.google.gerrit.server.util.RequestScopePropagator;
|
||||
|
@ -49,7 +49,7 @@ import org.eclipse.jgit.revwalk.RevWalk;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class MergedByPushOp extends BatchUpdate.Op {
|
||||
public class MergedByPushOp implements BatchUpdateOp {
|
||||
private static final Logger log = LoggerFactory.getLogger(MergedByPushOp.class);
|
||||
|
||||
public interface Factory {
|
||||
|
|
|
@ -115,6 +115,7 @@ import com.google.gerrit.server.query.change.ChangeData;
|
|||
import com.google.gerrit.server.query.change.InternalChangeQuery;
|
||||
import com.google.gerrit.server.ssh.SshInfo;
|
||||
import com.google.gerrit.server.update.BatchUpdate;
|
||||
import com.google.gerrit.server.update.BatchUpdateOp;
|
||||
import com.google.gerrit.server.update.ChangeContext;
|
||||
import com.google.gerrit.server.update.UpdateException;
|
||||
import com.google.gerrit.server.util.LabelVote;
|
||||
|
@ -2187,7 +2188,7 @@ public class ReceiveCommits {
|
|||
if (!Strings.isNullOrEmpty(magicBranch.topic)) {
|
||||
bu.addOp(
|
||||
changeId,
|
||||
new BatchUpdate.Op() {
|
||||
new BatchUpdateOp() {
|
||||
@Override
|
||||
public boolean updateChange(ChangeContext ctx) {
|
||||
ctx.getUpdate(psId).setTopic(magicBranch.topic);
|
||||
|
@ -2197,7 +2198,7 @@ public class ReceiveCommits {
|
|||
}
|
||||
bu.addOp(
|
||||
changeId,
|
||||
new BatchUpdate.Op() {
|
||||
new BatchUpdateOp() {
|
||||
@Override
|
||||
public boolean updateChange(ChangeContext ctx) {
|
||||
change = ctx.getChange();
|
||||
|
@ -2504,7 +2505,7 @@ public class ReceiveCommits {
|
|||
if (magicBranch != null && magicBranch.edit) {
|
||||
bu.addOp(
|
||||
notes.getChangeId(),
|
||||
new BatchUpdate.Op() {
|
||||
new BatchUpdateOp() {
|
||||
@Override
|
||||
public boolean updateChange(ChangeContext ctx) throws Exception {
|
||||
// return pseudo dirty state to trigger reindexing
|
||||
|
@ -2571,7 +2572,7 @@ public class ReceiveCommits {
|
|||
private void addOps(BatchUpdate bu) {
|
||||
bu.addOp(
|
||||
psId.getParentKey(),
|
||||
new BatchUpdate.Op() {
|
||||
new BatchUpdateOp() {
|
||||
@Override
|
||||
public boolean updateChange(ChangeContext ctx) throws OrmException {
|
||||
PatchSet ps = psUtil.get(ctx.getDb(), ctx.getNotes(), psId);
|
||||
|
|
|
@ -49,7 +49,7 @@ import com.google.gerrit.server.notedb.ChangeUpdate;
|
|||
import com.google.gerrit.server.project.ChangeControl;
|
||||
import com.google.gerrit.server.project.ProjectControl;
|
||||
import com.google.gerrit.server.query.change.ChangeData;
|
||||
import com.google.gerrit.server.update.BatchUpdate;
|
||||
import com.google.gerrit.server.update.BatchUpdateOp;
|
||||
import com.google.gerrit.server.update.ChangeContext;
|
||||
import com.google.gerrit.server.update.Context;
|
||||
import com.google.gerrit.server.update.RepoContext;
|
||||
|
@ -76,7 +76,7 @@ import org.eclipse.jgit.transport.ReceiveCommand;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class ReplaceOp extends BatchUpdate.Op {
|
||||
public class ReplaceOp implements BatchUpdateOp {
|
||||
public interface Factory {
|
||||
ReplaceOp create(
|
||||
ProjectControl projectControl,
|
||||
|
|
|
@ -31,8 +31,9 @@ import com.google.gerrit.server.project.NoSuchProjectException;
|
|||
import com.google.gerrit.server.project.ProjectCache;
|
||||
import com.google.gerrit.server.project.ProjectState;
|
||||
import com.google.gerrit.server.update.BatchUpdate;
|
||||
import com.google.gerrit.server.update.BatchUpdate.Listener;
|
||||
import com.google.gerrit.server.update.BatchUpdateListener;
|
||||
import com.google.gerrit.server.update.RepoContext;
|
||||
import com.google.gerrit.server.update.RepoOnlyOp;
|
||||
import com.google.gerrit.server.update.UpdateException;
|
||||
import com.google.inject.assistedinject.Assisted;
|
||||
import com.google.inject.assistedinject.AssistedInject;
|
||||
|
@ -70,7 +71,7 @@ import org.slf4j.LoggerFactory;
|
|||
public class SubmoduleOp {
|
||||
|
||||
/** Only used for branches without code review changes */
|
||||
public class GitlinkOp extends BatchUpdate.RepoOnlyOp {
|
||||
public class GitlinkOp implements RepoOnlyOp {
|
||||
private final Branch.NameKey branch;
|
||||
|
||||
GitlinkOp(Branch.NameKey branch) {
|
||||
|
@ -338,7 +339,7 @@ public class SubmoduleOp {
|
|||
}
|
||||
}
|
||||
BatchUpdate.execute(
|
||||
orm.batchUpdates(superProjects), Listener.NONE, orm.getSubmissionId(), false);
|
||||
orm.batchUpdates(superProjects), BatchUpdateListener.NONE, orm.getSubmissionId(), false);
|
||||
} catch (RestApiException | UpdateException | IOException | NoSuchProjectException e) {
|
||||
throw new SubmoduleException("Cannot update gitlinks", e);
|
||||
}
|
||||
|
|
|
@ -23,14 +23,14 @@ import com.google.gerrit.server.change.Submit.TestSubmitInput;
|
|||
import com.google.gerrit.server.git.CodeReviewCommit;
|
||||
import com.google.gerrit.server.git.IntegrationException;
|
||||
import com.google.gerrit.server.git.MergeOp.CommitStatus;
|
||||
import com.google.gerrit.server.update.BatchUpdate;
|
||||
import com.google.gerrit.server.update.BatchUpdateListener;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import org.eclipse.jgit.revwalk.RevCommit;
|
||||
|
||||
public class SubmitStrategyListener extends BatchUpdate.Listener {
|
||||
public class SubmitStrategyListener implements BatchUpdateListener {
|
||||
private final Collection<SubmitStrategy> strategies;
|
||||
private final CommitStatus commitStatus;
|
||||
private final boolean failAfterRefUpdates;
|
||||
|
|
|
@ -46,7 +46,7 @@ import com.google.gerrit.server.git.ProjectConfig;
|
|||
import com.google.gerrit.server.git.SubmoduleException;
|
||||
import com.google.gerrit.server.notedb.ChangeUpdate;
|
||||
import com.google.gerrit.server.project.ProjectState;
|
||||
import com.google.gerrit.server.update.BatchUpdate;
|
||||
import com.google.gerrit.server.update.BatchUpdateOp;
|
||||
import com.google.gerrit.server.update.ChangeContext;
|
||||
import com.google.gerrit.server.update.Context;
|
||||
import com.google.gerrit.server.update.RepoContext;
|
||||
|
@ -68,7 +68,7 @@ import org.eclipse.jgit.transport.ReceiveCommand;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
abstract class SubmitStrategyOp extends BatchUpdate.Op {
|
||||
abstract class SubmitStrategyOp implements BatchUpdateOp {
|
||||
private static final Logger log = LoggerFactory.getLogger(SubmitStrategyOp.class);
|
||||
|
||||
protected final SubmitStrategy.Arguments args;
|
||||
|
|
|
@ -47,6 +47,7 @@ import com.google.gerrit.server.project.ChangeControl;
|
|||
import com.google.gerrit.server.query.change.ChangeData;
|
||||
import com.google.gerrit.server.query.change.InternalChangeQuery;
|
||||
import com.google.gerrit.server.update.BatchUpdate;
|
||||
import com.google.gerrit.server.update.BatchUpdateOp;
|
||||
import com.google.gerrit.server.update.ChangeContext;
|
||||
import com.google.gerrit.server.update.Context;
|
||||
import com.google.gerrit.server.update.UpdateException;
|
||||
|
@ -207,7 +208,7 @@ public class MailProcessor {
|
|||
}
|
||||
}
|
||||
|
||||
private class Op extends BatchUpdate.Op {
|
||||
private class Op implements BatchUpdateOp {
|
||||
private final PatchSet.Id psId;
|
||||
private final List<MailComment> parsedComments;
|
||||
private final String tag;
|
||||
|
|
|
@ -50,6 +50,7 @@ import com.google.gerrit.server.project.ChangeControl;
|
|||
import com.google.gerrit.server.query.change.ChangeData;
|
||||
import com.google.gerrit.server.query.change.InternalChangeQuery;
|
||||
import com.google.gerrit.server.update.BatchUpdate;
|
||||
import com.google.gerrit.server.update.BatchUpdateOp;
|
||||
import com.google.gerrit.server.update.ChangeContext;
|
||||
import com.google.gerrit.server.update.UpdateException;
|
||||
import com.google.gwtorm.server.AtomicUpdate;
|
||||
|
@ -455,7 +456,7 @@ public class PrimaryStorageMigrator {
|
|||
db.get(), project, internalUserFactory.create(), TimeUtil.nowTs())) {
|
||||
bu.addOp(
|
||||
id,
|
||||
new BatchUpdate.Op() {
|
||||
new BatchUpdateOp() {
|
||||
@Override
|
||||
public boolean updateChange(ChangeContext ctx) {
|
||||
ctx.getUpdate(ctx.getChange().currentPatchSetId()).setReadOnlyUntil(new Timestamp(0));
|
||||
|
|
|
@ -256,58 +256,6 @@ public class BatchUpdate implements AutoCloseable {
|
|||
}
|
||||
}
|
||||
|
||||
public static class RepoOnlyOp {
|
||||
/**
|
||||
* Override this method to update the repo.
|
||||
*
|
||||
* @param ctx context
|
||||
*/
|
||||
public void updateRepo(RepoContext ctx) throws Exception {}
|
||||
|
||||
/**
|
||||
* Override this method to do something after the update e.g. send email or run hooks
|
||||
*
|
||||
* @param ctx context
|
||||
*/
|
||||
//TODO(dborowitz): Support async operations?
|
||||
public void postUpdate(Context ctx) throws Exception {}
|
||||
}
|
||||
|
||||
public static class Op extends RepoOnlyOp {
|
||||
/**
|
||||
* Override this method to modify a change.
|
||||
*
|
||||
* @param ctx context
|
||||
* @return whether anything was changed that might require a write to the metadata storage.
|
||||
*/
|
||||
public boolean updateChange(ChangeContext ctx) throws Exception {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public abstract static class InsertChangeOp extends Op {
|
||||
public abstract Change createChange(Context ctx);
|
||||
}
|
||||
|
||||
/**
|
||||
* Interface for listening during batch update execution.
|
||||
*
|
||||
* <p>When used during execution of multiple batch updates, the {@code after*} methods are called
|
||||
* after that phase has been completed for <em>all</em> updates.
|
||||
*/
|
||||
public static class Listener {
|
||||
public static final Listener NONE = new Listener();
|
||||
|
||||
/** Called after updating all repositories and flushing objects but before updating any refs. */
|
||||
public void afterUpdateRepos() throws Exception {}
|
||||
|
||||
/** Called after updating all refs. */
|
||||
public void afterRefUpdates() throws Exception {}
|
||||
|
||||
/** Called after updating all changes. */
|
||||
public void afterUpdateChanges() throws Exception {}
|
||||
}
|
||||
|
||||
@Singleton
|
||||
private static class Metrics {
|
||||
final Timer1<Boolean> executeChangeOpsLatency;
|
||||
|
@ -357,7 +305,7 @@ public class BatchUpdate implements AutoCloseable {
|
|||
|
||||
public static void execute(
|
||||
Collection<BatchUpdate> updates,
|
||||
Listener listener,
|
||||
BatchUpdateListener listener,
|
||||
@Nullable RequestId requestId,
|
||||
boolean dryrun)
|
||||
throws UpdateException, RestApiException {
|
||||
|
@ -472,7 +420,7 @@ public class BatchUpdate implements AutoCloseable {
|
|||
private final Timestamp when;
|
||||
private final TimeZone tz;
|
||||
|
||||
private final ListMultimap<Change.Id, Op> ops =
|
||||
private final ListMultimap<Change.Id, BatchUpdateOp> ops =
|
||||
MultimapBuilder.linkedHashKeys().arrayListValues().build();
|
||||
private final Map<Change.Id, Change> newChanges = new HashMap<>();
|
||||
private final List<CheckedFuture<?, IOException>> indexFutures = new ArrayList<>();
|
||||
|
@ -568,7 +516,7 @@ public class BatchUpdate implements AutoCloseable {
|
|||
return this;
|
||||
}
|
||||
|
||||
/** Execute {@link Op#updateChange(ChangeContext)} in parallel for each change. */
|
||||
/** Execute {@link BatchUpdateOp#updateChange(ChangeContext)} in parallel for each change. */
|
||||
public BatchUpdate updateChangesInParallel() {
|
||||
this.updateChangesInParallel = true;
|
||||
return this;
|
||||
|
@ -603,7 +551,7 @@ public class BatchUpdate implements AutoCloseable {
|
|||
return inserter;
|
||||
}
|
||||
|
||||
public BatchUpdate addOp(Change.Id id, Op op) {
|
||||
public BatchUpdate addOp(Change.Id id, BatchUpdateOp op) {
|
||||
checkArgument(!(op instanceof InsertChangeOp), "use insertChange");
|
||||
checkNotNull(op);
|
||||
ops.put(id, op);
|
||||
|
@ -611,7 +559,7 @@ public class BatchUpdate implements AutoCloseable {
|
|||
}
|
||||
|
||||
public BatchUpdate addRepoOnlyOp(RepoOnlyOp op) {
|
||||
checkArgument(!(op instanceof Op), "use addOp()");
|
||||
checkArgument(!(op instanceof BatchUpdateOp), "use addOp()");
|
||||
repoOnlyOps.add(op);
|
||||
return this;
|
||||
}
|
||||
|
@ -631,10 +579,11 @@ public class BatchUpdate implements AutoCloseable {
|
|||
}
|
||||
|
||||
public void execute() throws UpdateException, RestApiException {
|
||||
execute(Listener.NONE);
|
||||
execute(BatchUpdateListener.NONE);
|
||||
}
|
||||
|
||||
public void execute(Listener listener) throws UpdateException, RestApiException {
|
||||
public void execute(BatchUpdateListener listener)
|
||||
throws UpdateException, RestApiException {
|
||||
execute(ImmutableList.of(this), listener, requestId, false);
|
||||
}
|
||||
|
||||
|
@ -642,7 +591,7 @@ public class BatchUpdate implements AutoCloseable {
|
|||
try {
|
||||
logDebug("Executing updateRepo on {} ops", ops.size());
|
||||
RepoContextImpl ctx = new RepoContextImpl();
|
||||
for (Op op : ops.values()) {
|
||||
for (BatchUpdateOp op : ops.values()) {
|
||||
op.updateRepo(ctx);
|
||||
}
|
||||
|
||||
|
@ -728,7 +677,7 @@ public class BatchUpdate implements AutoCloseable {
|
|||
throw new OrmException(NoteDbUpdateManager.CHANGES_READ_ONLY);
|
||||
}
|
||||
List<ListenableFuture<?>> futures = new ArrayList<>(ops.keySet().size());
|
||||
for (Map.Entry<Change.Id, Collection<Op>> e : ops.asMap().entrySet()) {
|
||||
for (Map.Entry<Change.Id, Collection<BatchUpdateOp>> e : ops.asMap().entrySet()) {
|
||||
ChangeTask task =
|
||||
new ChangeTask(e.getKey(), e.getValue(), Thread.currentThread(), dryrun);
|
||||
tasks.add(task);
|
||||
|
@ -870,7 +819,7 @@ public class BatchUpdate implements AutoCloseable {
|
|||
|
||||
private class ChangeTask implements Callable<Void> {
|
||||
final Change.Id id;
|
||||
private final Collection<Op> changeOps;
|
||||
private final Collection<BatchUpdateOp> changeOps;
|
||||
private final Thread mainThread;
|
||||
private final boolean dryrun;
|
||||
|
||||
|
@ -880,7 +829,8 @@ public class BatchUpdate implements AutoCloseable {
|
|||
boolean deleted;
|
||||
private String taskId;
|
||||
|
||||
private ChangeTask(Change.Id id, Collection<Op> changeOps, Thread mainThread, boolean dryrun) {
|
||||
private ChangeTask(
|
||||
Change.Id id, Collection<BatchUpdateOp> changeOps, Thread mainThread, boolean dryrun) {
|
||||
this.id = id;
|
||||
this.changeOps = changeOps;
|
||||
this.mainThread = mainThread;
|
||||
|
@ -929,7 +879,7 @@ public class BatchUpdate implements AutoCloseable {
|
|||
|
||||
// Call updateChange on each op.
|
||||
logDebug("Calling updateChange on {} ops", changeOps.size());
|
||||
for (Op op : changeOps) {
|
||||
for (BatchUpdateOp op : changeOps) {
|
||||
dirty |= op.updateChange(ctx);
|
||||
}
|
||||
if (!dirty) {
|
||||
|
@ -1105,7 +1055,7 @@ public class BatchUpdate implements AutoCloseable {
|
|||
|
||||
private void executePostOps() throws Exception {
|
||||
ContextImpl ctx = new ContextImpl();
|
||||
for (Op op : ops.values()) {
|
||||
for (BatchUpdateOp op : ops.values()) {
|
||||
op.postUpdate(ctx);
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
// 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.update;
|
||||
|
||||
/**
|
||||
* Interface for listening during batch update execution.
|
||||
*
|
||||
* <p>When used during execution of multiple batch updates, the {@code after*} methods are called
|
||||
* after that phase has been completed for <em>all</em> updates.
|
||||
*/
|
||||
public interface BatchUpdateListener {
|
||||
public static final BatchUpdateListener NONE = new BatchUpdateListener() {};
|
||||
|
||||
/** Called after updating all repositories and flushing objects but before updating any refs. */
|
||||
default void afterUpdateRepos() throws Exception {}
|
||||
|
||||
/** Called after updating all refs. */
|
||||
default void afterRefUpdates() throws Exception {}
|
||||
|
||||
/** Called after updating all changes. */
|
||||
default void afterUpdateChanges() throws Exception {}
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
// 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.update;
|
||||
|
||||
/**
|
||||
* Interface for {@link BatchUpdate} operations that touch a change.
|
||||
*
|
||||
* <p>Each operation has {@link #updateChange(ChangeContext)} called once the change is read in a
|
||||
* transaction. Ops are associated with updates via {@link
|
||||
* BatchUpdate#addOp(com.google.gerrit.reviewdb.client.Change.Id, BatchUpdateOp)}.
|
||||
*
|
||||
* <p>Usually, a single {@code BatchUpdateOp} instance is only associated with a single change, i.e.
|
||||
* {@code addOp} is only called once with that instance. This allows an instance to communicate
|
||||
* between phases by storing data in private fields.
|
||||
*/
|
||||
public interface BatchUpdateOp extends RepoOnlyOp {
|
||||
/**
|
||||
* Override this method to modify a change.
|
||||
*
|
||||
* @param ctx context
|
||||
* @return whether anything was changed that might require a write to the metadata storage.
|
||||
*/
|
||||
default boolean updateChange(ChangeContext ctx) throws Exception {
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -23,7 +23,7 @@ import com.google.gerrit.server.notedb.ChangeUpdate;
|
|||
import com.google.gerrit.server.project.ChangeControl;
|
||||
|
||||
/**
|
||||
* Context for performing the {@link BatchUpdate.Op#updateChange} phase.
|
||||
* Context for performing the {@link BatchUpdateOp#updateChange} phase.
|
||||
*
|
||||
* <p>A single {@code ChangeContext} corresponds to updating a single change; if a {@link
|
||||
* BatchUpdate} spans multiple changes, then multiple {@code ChangeContext} instances will be
|
||||
|
|
|
@ -40,7 +40,7 @@ public interface Context {
|
|||
* Get an open repository instance for this project.
|
||||
*
|
||||
* <p>Will be opened lazily if necessary; callers should not close the repo. In some phases of the
|
||||
* update, the repository might be read-only; see {@link BatchUpdate.Op} for details.
|
||||
* update, the repository might be read-only; see {@link BatchUpdateOp} for details.
|
||||
*
|
||||
* @return repository instance.
|
||||
* @throws IOException if an error occurred opening the repo.
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
// 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.update;
|
||||
|
||||
import com.google.gerrit.reviewdb.client.Change;
|
||||
|
||||
/**
|
||||
* Specialization of {@link BatchUpdateOp} for creating changes.
|
||||
*
|
||||
* <p>A typical {@code BatchUpdateOp} operates on a change that has been read from a transaction;
|
||||
* this type, by contrast, is responsible for creating the change from scratch.
|
||||
*
|
||||
* <p>Ops of this type must be used via {@link BatchUpdate#insertChange(InsertChangeOp)}. They may
|
||||
* be mixed with other {@link BatchUpdateOp}s for the same change, in which case the insert op runs
|
||||
* first.
|
||||
*/
|
||||
public interface InsertChangeOp extends BatchUpdateOp {
|
||||
Change createChange(Context ctx);
|
||||
}
|
|
@ -18,7 +18,7 @@ import java.io.IOException;
|
|||
import org.eclipse.jgit.lib.ObjectInserter;
|
||||
import org.eclipse.jgit.transport.ReceiveCommand;
|
||||
|
||||
/** Context for performing the {@link BatchUpdate.Op#updateRepo} phase. */
|
||||
/** Context for performing the {@link BatchUpdateOp#updateRepo} phase. */
|
||||
public interface RepoContext extends Context {
|
||||
/**
|
||||
* @return inserter for writing to the repo. Callers should not flush; the walk returned by {@link
|
||||
|
|
|
@ -0,0 +1,39 @@
|
|||
// 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.update;
|
||||
|
||||
/**
|
||||
* Base interface for operations performed as part of a {@link BatchUpdate}.
|
||||
*
|
||||
* <p>Operations that implement this type only touch the repository; they cannot touch change
|
||||
* storage, nor are they even associated with a change ID. To modify a change, implement {@link
|
||||
* BatchUpdateOp} instead.
|
||||
*/
|
||||
public interface RepoOnlyOp {
|
||||
/**
|
||||
* Override this method to update the repo.
|
||||
*
|
||||
* @param ctx context
|
||||
*/
|
||||
default void updateRepo(RepoContext ctx) throws Exception {}
|
||||
|
||||
/**
|
||||
* Override this method to do something after the update e.g. send email or run hooks
|
||||
*
|
||||
* @param ctx context
|
||||
*/
|
||||
//TODO(dborowitz): Support async operations?
|
||||
default void postUpdate(Context ctx) throws Exception {}
|
||||
}
|
|
@ -12,7 +12,6 @@ import com.google.gerrit.server.IdentifiedUser;
|
|||
import com.google.gerrit.server.account.AccountManager;
|
||||
import com.google.gerrit.server.account.AuthRequest;
|
||||
import com.google.gerrit.server.schema.SchemaCreator;
|
||||
import com.google.gerrit.server.update.BatchUpdate.RepoOnlyOp;
|
||||
import com.google.gerrit.server.util.RequestContext;
|
||||
import com.google.gerrit.server.util.ThreadLocalRequestContext;
|
||||
import com.google.gerrit.testutil.InMemoryDatabase;
|
||||
|
|
Loading…
Reference in New Issue