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
BatchRefUpdate
or 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 class
BatchUpdate.Factory
-
Field Summary
Fields Modifier and Type Field Description protected org.eclipse.jgit.lib.BatchRefUpdate
batchRefUpdate
protected Map<Change.Id,Change>
newChanges
protected OnSubmitValidators
onSubmitValidators
protected com.google.common.collect.ListMultimap<Change.Id,BatchUpdateOp>
ops
protected Order
order
protected Project.NameKey
project
protected org.eclipse.jgit.transport.PushCertificate
pushCert
protected String
refLogMessage
protected GitRepositoryManager
repoManager
protected List<RepoOnlyOp>
repoOnlyOps
protected RepoView
repoView
protected TimeZone
tz
protected CurrentUser
user
protected Timestamp
when
-
Constructor Summary
Constructors Modifier Constructor Description protected
BatchUpdate(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 BatchUpdate
addOp(Change.Id id, BatchUpdateOp op)
BatchUpdate
addRepoOnlyOp(RepoOnlyOp op)
void
close()
void
execute()
abstract void
execute(BatchUpdateListener listener)
protected Optional<AccountState>
getAccount()
Map<String,org.eclipse.jgit.transport.ReceiveCommand>
getRefUpdates()
protected RepoView
getRepoView()
protected org.eclipse.jgit.revwalk.RevWalk
getRevWalk()
protected CurrentUser
getUser()
protected void
initRepository()
BatchUpdate
insertChange(InsertChangeOp op)
protected static void
logDebug(String msg)
protected static void
logDebug(String msg, Object arg)
protected static void
logDebug(String msg, Object arg1, Object arg2)
protected static void
logDebug(String msg, Object arg1, Object arg2, Object arg3)
protected static void
logDebug(String msg, Throwable t)
static com.google.inject.Module
module()
protected abstract Context
newContext()
BatchUpdate
setOnSubmitValidators(OnSubmitValidators onSubmitValidators)
Add a validation step for intended ref operations, which will be performed at the end ofRepoOnlyOp.updateRepo(RepoContext)
step.BatchUpdate
setOrder(Order order)
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)
BatchUpdate
updateChangesInParallel()
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:
close
in interfaceAutoCloseable
-
execute
public abstract void execute(BatchUpdateListener listener) throws UpdateException, RestApiException
- Throws:
UpdateException
RestApiException
-
execute
public void execute() throws UpdateException, RestApiException
- Throws:
UpdateException
RestApiException
-
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)
-
-