Package org.eclipse.jgit.internal.ketch
Class StageBuilder
- java.lang.Object
-
- org.eclipse.jgit.internal.ketch.StageBuilder
-
public class StageBuilder extends java.lang.Object
Constructs a set of commands to stage content during a proposal.
-
-
Field Summary
Fields Modifier and Type Field Description private static byte[]
PEEL
private static int
SMALL_BATCH_SIZE
Acceptable number of references to send in a single stage transaction.private static int
TEMP_PARENT_BATCH_SIZE
Acceptable number of commits to chain together using parent pointers.private java.lang.String
txnId
private java.lang.String
txnStage
-
Constructor Summary
Constructors Constructor Description StageBuilder(java.lang.String txnStageNamespace, ObjectId txnId)
Construct a stage builder for a transaction.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.List<ReceiveCommand>
makeStageList(java.util.Set<ObjectId> newObjs, Repository git, ObjectInserter inserter)
Construct a set of commands to stage objects on a replica.java.util.List<ReceiveCommand>
makeStageList(Repository git, ObjectId oldTree, ObjectId newTree)
Compare two RefTrees and return commands to stage new objects.private void
reduceObjects(java.util.List<ReceiveCommand> cmds, java.util.List<RevCommit> commits, Repository git, java.util.Set<ObjectId> newObjs)
private void
stage(java.util.List<ReceiveCommand> cmds, ObjectId id)
private static PersonIdent
tmpAuthor(java.util.List<RevCommit> commits)
-
-
-
Field Detail
-
SMALL_BATCH_SIZE
private static final int SMALL_BATCH_SIZE
Acceptable number of references to send in a single stage transaction.If the number of unique objects exceeds this amount the builder will attempt to decrease the reference count by chaining commits..
- See Also:
- Constant Field Values
-
TEMP_PARENT_BATCH_SIZE
private static final int TEMP_PARENT_BATCH_SIZE
Acceptable number of commits to chain together using parent pointers.When staging many unique commits the
StageBuilder
batches together unrelated commits as parents of a temporary commit. After the proposal completes the temporary commit is discarded and can be garbage collected by all replicas.- See Also:
- Constant Field Values
-
PEEL
private static final byte[] PEEL
-
txnStage
private final java.lang.String txnStage
-
txnId
private final java.lang.String txnId
-
-
Constructor Detail
-
StageBuilder
public StageBuilder(java.lang.String txnStageNamespace, ObjectId txnId)
Construct a stage builder for a transaction.- Parameters:
txnStageNamespace
- namespace for transaction references to build"txnStageNamespace/txnId.n"
style names.txnId
- identifier used to name temporary staging refs.
-
-
Method Detail
-
makeStageList
public java.util.List<ReceiveCommand> makeStageList(Repository git, ObjectId oldTree, ObjectId newTree) throws java.io.IOException
Compare two RefTrees and return commands to stage new objects.This method ignores the lineage between the two RefTrees and does a straight diff on the two trees. New objects will be staged. The diff strategy is useful to catch-up a lagging replica, without sending every intermediate step. This may mean the replica does not have the same object set as other replicas if there are rewinds or branch deletes.
- Parameters:
git
- source repository to readoldTree
andnewTree
from.oldTree
- accepted RefTree on the replica (refs/txn/accepted
). UseObjectId.zeroId()
if the remote does not have any ref tree, e.g. a new replica catching up.newTree
- RefTree being sent to the replica. The trees will be compared.- Returns:
- list of commands to create
"refs/txn/stage/..."
references on replicas anchoring new objects into the repository while a transaction gains consensus. - Throws:
java.io.IOException
-git
cannot be accessed to compareoldTree
andnewTree
to build the object set.
-
makeStageList
public java.util.List<ReceiveCommand> makeStageList(java.util.Set<ObjectId> newObjs, @Nullable Repository git, @Nullable ObjectInserter inserter) throws java.io.IOException
Construct a set of commands to stage objects on a replica.- Parameters:
newObjs
- objects to send to a replica.git
- local repository to read source objects from. Required to perform minification ofnewObjs
.inserter
- inserter to write temporary commit objects during minification if many new branches are created bynewObjs
.- Returns:
- list of commands to create
"refs/txn/stage/..."
references on replicas anchoringnewObjs
into the repository while a transaction gains consensus. - Throws:
java.io.IOException
-git
cannot be accessed to perform minification ofnewObjs
.
-
tmpAuthor
private static PersonIdent tmpAuthor(java.util.List<RevCommit> commits)
-
reduceObjects
private void reduceObjects(java.util.List<ReceiveCommand> cmds, java.util.List<RevCommit> commits, Repository git, java.util.Set<ObjectId> newObjs) throws java.io.IOException
- Throws:
java.io.IOException
-
stage
private void stage(java.util.List<ReceiveCommand> cmds, ObjectId id)
-
-