public abstract class BatchUpdate extends Object implements 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 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 RequestId |
requestId |
protected TimeZone |
tz |
protected CurrentUser |
user |
protected Timestamp |
when |
Modifier | Constructor and Description |
---|---|
protected |
BatchUpdate(GitRepositoryManager repoManager,
org.eclipse.jgit.lib.PersonIdent serverIdent,
Project.NameKey project,
CurrentUser user,
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 Optional<Account> |
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 void |
logDebug(String msg,
Object... args) |
protected 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 of
RepoOnlyOp.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 |
setRequestId(RequestId requestId) |
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 Timestamp when
protected final TimeZone tz
protected final com.google.common.collect.ListMultimap<Change.Id,BatchUpdateOp> ops
protected final List<RepoOnlyOp> repoOnlyOps
protected RepoView repoView
protected org.eclipse.jgit.lib.BatchRefUpdate batchRefUpdate
protected Order order
protected OnSubmitValidators onSubmitValidators
protected RequestId requestId
protected org.eclipse.jgit.transport.PushCertificate pushCert
protected String refLogMessage
protected BatchUpdate(GitRepositoryManager repoManager, org.eclipse.jgit.lib.PersonIdent serverIdent, Project.NameKey project, CurrentUser user, Timestamp when)
public static com.google.inject.Module module()
public void close()
close
in interface 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 setRequestId(RequestId requestId)
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(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 IOException
IOException
protected RepoView getRepoView() throws IOException
IOException
protected CurrentUser getUser()
protected org.eclipse.jgit.revwalk.RevWalk getRevWalk() throws IOException
IOException
public BatchUpdate addOp(Change.Id id, BatchUpdateOp op)
public BatchUpdate addRepoOnlyOp(RepoOnlyOp op)
public BatchUpdate insertChange(InsertChangeOp op) throws IOException
IOException