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 interface
BatchUpdate.Factory
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description BatchUpdate
addOp(Change.Id id, BatchUpdateOp op)
BatchUpdate
addRepoOnlyOp(RepoOnlyOp op)
void
close()
void
execute()
void
execute(BatchUpdateListener listener)
static void
execute(Collection<BatchUpdate> updates, com.google.common.collect.ImmutableList<BatchUpdateListener> listeners, boolean dryrun)
Project.NameKey
getProject()
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.BatchUpdate
insertChange(InsertChangeOp op)
boolean
isExecuted()
static com.google.inject.Module
module()
BatchUpdate
setNotify(NotifyResolver.Result notify)
Set the default notification settings for all changes in the batch.BatchUpdate
setNotifyHandling(Change.Id changeId, NotifyHandling notifyHandling)
Override theNotifyHandling
on a per-change basis.BatchUpdate
setOnSubmitValidators(OnSubmitValidators onSubmitValidators)
Add a validation step for intended ref operations, which will be performed at the end ofRepoOnlyOp.updateRepo(RepoContext)
step.BatchUpdate
setPushCertificate(org.eclipse.jgit.transport.PushCertificate pushCert)
BatchUpdate
setRefLogMessage(String refLogMessage)
BatchUpdate
setRepository(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:
UpdateException
RestApiException
-
close
public void close()
- Specified by:
close
in interfaceAutoCloseable
-
execute
public void execute(BatchUpdateListener listener) throws UpdateException, RestApiException
- Throws:
UpdateException
RestApiException
-
execute
public void execute() throws UpdateException, RestApiException
- Throws:
UpdateException
RestApiException
-
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 theNotifyHandling
on 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
-
-