Package com.google.gerrit.server.update
Class BatchUpdate
- java.lang.Object
-
- com.google.gerrit.server.update.BatchUpdate
-
- All Implemented Interfaces:
AutoCloseable
- Direct Known Subclasses:
NoteDbBatchUpdate,ReviewDbBatchUpdate
public abstract class BatchUpdate extends Object implements AutoCloseable
Helper for a set of updates that should be applied for a site.An update operation can be divided into three phases:
- Git reference updates
- Database updates
- Post-update steps
Depending on the backend used, each step might support batching, for example in a
BatchRefUpdateor one or more database transactions. All operations in one phase must complete successfully before proceeding to the next phase.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classBatchUpdate.Factory
-
Field Summary
Fields Modifier and Type Field Description protected org.eclipse.jgit.lib.BatchRefUpdatebatchRefUpdateprotected Map<Change.Id,Change>newChangesprotected OnSubmitValidatorsonSubmitValidatorsprotected com.google.common.collect.ListMultimap<Change.Id,BatchUpdateOp>opsprotected Orderorderprotected Project.NameKeyprojectprotected org.eclipse.jgit.transport.PushCertificatepushCertprotected StringrefLogMessageprotected GitRepositoryManagerrepoManagerprotected List<RepoOnlyOp>repoOnlyOpsprotected RepoViewrepoViewprotected TimeZonetzprotected CurrentUseruserprotected Timestampwhen
-
Constructor Summary
Constructors Modifier Constructor Description protectedBatchUpdate(GitRepositoryManager repoManager, org.eclipse.jgit.lib.PersonIdent serverIdent, Project.NameKey project, CurrentUser user, Timestamp when)
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description BatchUpdateaddOp(Change.Id id, BatchUpdateOp op)BatchUpdateaddRepoOnlyOp(RepoOnlyOp op)voidclose()voidexecute()abstract voidexecute(BatchUpdateListener listener)protected Optional<AccountState>getAccount()Map<String,org.eclipse.jgit.transport.ReceiveCommand>getRefUpdates()protected RepoViewgetRepoView()protected org.eclipse.jgit.revwalk.RevWalkgetRevWalk()protected CurrentUsergetUser()protected voidinitRepository()BatchUpdateinsertChange(InsertChangeOp op)protected static voidlogDebug(String msg)protected static voidlogDebug(String msg, Object arg)protected static voidlogDebug(String msg, Object arg1, Object arg2)protected static voidlogDebug(String msg, Object arg1, Object arg2, Object arg3)protected static voidlogDebug(String msg, Throwable t)static com.google.inject.Modulemodule()protected abstract ContextnewContext()BatchUpdatesetOnSubmitValidators(OnSubmitValidators onSubmitValidators)Add a validation step for intended ref operations, which will be performed at the end ofRepoOnlyOp.updateRepo(RepoContext)step.BatchUpdatesetOrder(Order order)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)BatchUpdateupdateChangesInParallel()ExecuteBatchUpdateOp.updateChange(ChangeContext)in parallel for each change.
-
-
-
Field Detail
-
repoManager
protected GitRepositoryManager repoManager
-
project
protected final Project.NameKey project
-
user
protected final CurrentUser user
-
when
protected final Timestamp when
-
tz
protected final TimeZone tz
-
ops
protected final com.google.common.collect.ListMultimap<Change.Id,BatchUpdateOp> ops
-
repoOnlyOps
protected final List<RepoOnlyOp> repoOnlyOps
-
repoView
protected RepoView repoView
-
batchRefUpdate
protected org.eclipse.jgit.lib.BatchRefUpdate batchRefUpdate
-
order
protected Order order
-
onSubmitValidators
protected OnSubmitValidators onSubmitValidators
-
pushCert
protected org.eclipse.jgit.transport.PushCertificate pushCert
-
refLogMessage
protected String refLogMessage
-
-
Constructor Detail
-
BatchUpdate
protected BatchUpdate(GitRepositoryManager repoManager, org.eclipse.jgit.lib.PersonIdent serverIdent, Project.NameKey project, CurrentUser user, Timestamp when)
-
-
Method Detail
-
module
public static com.google.inject.Module module()
-
close
public void close()
- Specified by:
closein interfaceAutoCloseable
-
execute
public abstract void execute(BatchUpdateListener listener) throws UpdateException, RestApiException
- Throws:
UpdateExceptionRestApiException
-
execute
public void execute() throws UpdateException, RestApiException- Throws:
UpdateExceptionRestApiException
-
newContext
protected abstract Context newContext()
-
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)
-
setOrder
public BatchUpdate setOrder(Order order)
-
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.
-
updateChangesInParallel
public BatchUpdate updateChangesInParallel()
ExecuteBatchUpdateOp.updateChange(ChangeContext)in parallel for each change.This improves performance of writing to multiple changes in separate ReviewDb transactions. When only NoteDb is used, updates to all changes are written in a single batch ref update, so parallelization is not used and this option is ignored.
-
initRepository
protected void initRepository() throws IOException- Throws:
IOException
-
getRepoView
protected RepoView getRepoView() throws IOException
- Throws:
IOException
-
getUser
protected CurrentUser getUser()
-
getAccount
protected Optional<AccountState> getAccount()
-
getRevWalk
protected org.eclipse.jgit.revwalk.RevWalk getRevWalk() throws IOException- Throws:
IOException
-
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
-
logDebug
protected static void logDebug(String msg)
-
-