public abstract class BatchUpdate
extends java.lang.Object
implements java.lang.AutoCloseable
An update operation can be divided into three phases:
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.
Modifier and Type | Class and Description |
---|---|
static class |
BatchUpdate.Factory |
Modifier and Type | Field and Description |
---|---|
protected org.eclipse.jgit.lib.BatchRefUpdate |
batchRefUpdate |
protected java.util.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 java.lang.String |
refLogMessage |
protected GitRepositoryManager |
repoManager |
protected java.util.List<RepoOnlyOp> |
repoOnlyOps |
protected RepoView |
repoView |
protected java.util.TimeZone |
tz |
protected CurrentUser |
user |
protected java.sql.Timestamp |
when |
Modifier | Constructor and Description |
---|---|
protected |
BatchUpdate(GitRepositoryManager repoManager,
org.eclipse.jgit.lib.PersonIdent serverIdent,
Project.NameKey project,
CurrentUser user,
java.sql.Timestamp when) |
Modifier and Type | Method and Description |
---|---|
BatchUpdate |
addOp(Change.Id id,
BatchUpdateOp op) |
BatchUpdate |
addRepoOnlyOp(RepoOnlyOp op) |
void |
close() |
void |
execute() |
abstract void |
execute(BatchUpdateListener listener) |
protected java.util.Optional<AccountState> |
getAccount() |
java.util.Map<java.lang.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(java.lang.String msg) |
protected static void |
logDebug(java.lang.String msg,
java.lang.Object arg) |
protected static void |
logDebug(java.lang.String msg,
java.lang.Object arg1,
java.lang.Object arg2) |
protected static void |
logDebug(java.lang.String msg,
java.lang.Object arg1,
java.lang.Object arg2,
java.lang.Object arg3) |
protected static void |
logDebug(java.lang.String msg,
java.lang.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 of
RepoOnlyOp.updateRepo(RepoContext) step. |
BatchUpdate |
setOrder(Order order) |
BatchUpdate |
setPushCertificate(org.eclipse.jgit.transport.PushCertificate pushCert) |
BatchUpdate |
setRefLogMessage(java.lang.String refLogMessage) |
BatchUpdate |
setRepository(org.eclipse.jgit.lib.Repository repo,
org.eclipse.jgit.revwalk.RevWalk revWalk,
org.eclipse.jgit.lib.ObjectInserter inserter) |
BatchUpdate |
updateChangesInParallel()
Execute
BatchUpdateOp.updateChange(ChangeContext) in parallel for each change. |
protected GitRepositoryManager repoManager
protected final Project.NameKey project
protected final CurrentUser user
protected final java.sql.Timestamp when
protected final java.util.TimeZone tz
protected final com.google.common.collect.ListMultimap<Change.Id,BatchUpdateOp> ops
protected final java.util.List<RepoOnlyOp> repoOnlyOps
protected RepoView repoView
protected org.eclipse.jgit.lib.BatchRefUpdate batchRefUpdate
protected Order order
protected OnSubmitValidators onSubmitValidators
protected org.eclipse.jgit.transport.PushCertificate pushCert
protected java.lang.String refLogMessage
protected BatchUpdate(GitRepositoryManager repoManager, org.eclipse.jgit.lib.PersonIdent serverIdent, Project.NameKey project, CurrentUser user, java.sql.Timestamp when)
public static com.google.inject.Module module()
public void close()
close
in interface java.lang.AutoCloseable
public abstract void execute(BatchUpdateListener listener) throws UpdateException, RestApiException
UpdateException
RestApiException
public void execute() throws UpdateException, RestApiException
UpdateException
RestApiException
protected abstract Context newContext()
public BatchUpdate setRepository(org.eclipse.jgit.lib.Repository repo, org.eclipse.jgit.revwalk.RevWalk revWalk, org.eclipse.jgit.lib.ObjectInserter inserter)
public BatchUpdate setPushCertificate(org.eclipse.jgit.transport.PushCertificate pushCert)
public BatchUpdate setRefLogMessage(java.lang.String refLogMessage)
public BatchUpdate setOrder(Order order)
public BatchUpdate setOnSubmitValidators(OnSubmitValidators onSubmitValidators)
RepoOnlyOp.updateRepo(RepoContext)
step.public BatchUpdate updateChangesInParallel()
BatchUpdateOp.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.
protected void initRepository() throws java.io.IOException
java.io.IOException
protected RepoView getRepoView() throws java.io.IOException
java.io.IOException
protected CurrentUser getUser()
protected java.util.Optional<AccountState> getAccount()
protected org.eclipse.jgit.revwalk.RevWalk getRevWalk() throws java.io.IOException
java.io.IOException
public java.util.Map<java.lang.String,org.eclipse.jgit.transport.ReceiveCommand> getRefUpdates()
public BatchUpdate addOp(Change.Id id, BatchUpdateOp op)
public BatchUpdate addRepoOnlyOp(RepoOnlyOp op)
public BatchUpdate insertChange(InsertChangeOp op) throws java.io.IOException
java.io.IOException
protected static void logDebug(java.lang.String msg, java.lang.Throwable t)
protected static void logDebug(java.lang.String msg)
protected static void logDebug(java.lang.String msg, java.lang.Object arg)
protected static void logDebug(java.lang.String msg, java.lang.Object arg1, java.lang.Object arg2)
protected static void logDebug(java.lang.String msg, java.lang.Object arg1, java.lang.Object arg2, java.lang.Object arg3)