Package com.google.gerrit.server.update
Class BatchUpdate
- java.lang.Object
-
- com.google.gerrit.server.update.BatchUpdate
-
- All Implemented Interfaces:
AutoCloseable
public class BatchUpdate extends Object implements AutoCloseable
Helper for a set of change updates that should be applied to the NoteDb database.An update operation can be divided into three phases:
- Git reference updates
- Review metadata updates
- Post-update steps
BatchRefUpdate.Similarly, all post-update steps, such as sending email, must run only after all storage mutations have completed.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceBatchUpdate.Factory
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description BatchUpdateaddOp(Change.Id id, BatchUpdateOp op)BatchUpdateaddRepoOnlyOp(RepoOnlyOp op)voidclose()voidexecute()voidexecute(BatchUpdateListener listener)static voidexecute(Collection<BatchUpdate> updates, com.google.common.collect.ImmutableList<BatchUpdateListener> listeners, boolean dryrun)Project.NameKeygetProject()Map<String,org.eclipse.jgit.transport.ReceiveCommand>getRefUpdates()Map<BranchNameKey,org.eclipse.jgit.transport.ReceiveCommand>getSuccessfullyUpdatedBranches(boolean dryrun)Return the references successfully updated by this BatchUpdate with their command.BatchUpdateinsertChange(InsertChangeOp op)booleanisExecuted()static com.google.inject.Modulemodule()org.eclipse.jgit.lib.BatchRefUpdateprepareRefUpdates()BatchUpdatesetNotify(NotifyResolver.Result notify)Set the default notification settings for all changes in the batch.BatchUpdatesetNotifyHandling(Change.Id changeId, NotifyHandling notifyHandling)Override theNotifyHandlingon a per-change basis.BatchUpdatesetOnSubmitValidators(OnSubmitValidators onSubmitValidators)Add a validation step for intended ref operations, which will be performed at the end ofRepoOnlyOp.updateRepo(RepoContext)step.BatchUpdatesetPushCertificate(org.eclipse.jgit.transport.PushCertificate pushCert)BatchUpdatesetRefLogMessage(String refLogMessage)BatchUpdatesetRepository(org.eclipse.jgit.lib.Repository repo, org.eclipse.jgit.revwalk.RevWalk revWalk, org.eclipse.jgit.lib.ObjectInserter inserter)
-
-
-
Method Detail
-
module
public static com.google.inject.Module module()
-
execute
public static void execute(Collection<BatchUpdate> updates, com.google.common.collect.ImmutableList<BatchUpdateListener> listeners, boolean dryrun) throws UpdateException, RestApiException
- Throws:
UpdateExceptionRestApiException
-
close
public void close()
- Specified by:
closein interfaceAutoCloseable
-
execute
public void execute(BatchUpdateListener listener) throws UpdateException, RestApiException
- Throws:
UpdateExceptionRestApiException
-
execute
public void execute() throws UpdateException, RestApiException- Throws:
UpdateExceptionRestApiException
-
prepareRefUpdates
public org.eclipse.jgit.lib.BatchRefUpdate prepareRefUpdates() throws Exception- Throws:
Exception
-
isExecuted
public boolean isExecuted()
-
setRepository
public BatchUpdate setRepository(org.eclipse.jgit.lib.Repository repo, org.eclipse.jgit.revwalk.RevWalk revWalk, org.eclipse.jgit.lib.ObjectInserter inserter)
-
setPushCertificate
public BatchUpdate setPushCertificate(org.eclipse.jgit.transport.PushCertificate pushCert)
-
setRefLogMessage
public BatchUpdate setRefLogMessage(String refLogMessage)
-
setNotify
public BatchUpdate setNotify(NotifyResolver.Result notify)
Set the default notification settings for all changes in the batch.- Parameters:
notify- notification settings.- Returns:
- this.
-
setNotifyHandling
public BatchUpdate setNotifyHandling(Change.Id changeId, NotifyHandling notifyHandling)
Override theNotifyHandlingon a per-change basis.Only the handling enum can be overridden; all changes share the same value for
NotifyResolver.Result.accounts().- Parameters:
changeId- change ID.notifyHandling- notify handling.- Returns:
- this.
-
setOnSubmitValidators
public BatchUpdate setOnSubmitValidators(OnSubmitValidators onSubmitValidators)
Add a validation step for intended ref operations, which will be performed at the end ofRepoOnlyOp.updateRepo(RepoContext)step.
-
getProject
public Project.NameKey getProject()
-
getSuccessfullyUpdatedBranches
public Map<BranchNameKey,org.eclipse.jgit.transport.ReceiveCommand> getSuccessfullyUpdatedBranches(boolean dryrun)
Return the references successfully updated by this BatchUpdate with their command. In dryrun, we assume all updates were successful.
-
addOp
public BatchUpdate addOp(Change.Id id, BatchUpdateOp op)
-
addRepoOnlyOp
public BatchUpdate addRepoOnlyOp(RepoOnlyOp op)
-
insertChange
public BatchUpdate insertChange(InsertChangeOp op) throws IOException
- Throws:
IOException
-
-