Package com.google.gerrit.server.notedb
Class RepoSequence
- java.lang.Object
-
- com.google.gerrit.server.notedb.RepoSequence
-
public class RepoSequence extends Object
Class for managing an incrementing sequence backed by a git repository.The current sequence number is stored as UTF-8 text in a blob pointed to by a ref in the
refs/sequences/*
namespace. Multiple processes can share the same sequence by incrementing the counter using normal git ref updates. To amortize the cost of these ref updates, processes can increment the counter by a larger number and hand out numbers from that range in memory until they run out. This means concurrent processes will hand out somewhat non-monotonic numbers.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
RepoSequence.Seed
-
Constructor Summary
Constructors Constructor Description RepoSequence(GitRepositoryManager repoManager, GitReferenceUpdated gitRefUpdated, Project.NameKey projectName, String name, RepoSequence.Seed seed, int batchSize)
RepoSequence(GitRepositoryManager repoManager, GitReferenceUpdated gitRefUpdated, Project.NameKey projectName, String name, RepoSequence.Seed seed, int batchSize, int floor)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description int
next()
Retrieves the next available sequence number.com.google.common.collect.ImmutableList<Integer>
next(int count)
Retrieves the next N available sequence number.static org.eclipse.jgit.transport.ReceiveCommand
storeNew(org.eclipse.jgit.lib.ObjectInserter ins, String name, int val)
-
-
-
Constructor Detail
-
RepoSequence
public RepoSequence(GitRepositoryManager repoManager, GitReferenceUpdated gitRefUpdated, Project.NameKey projectName, String name, RepoSequence.Seed seed, int batchSize)
-
RepoSequence
public RepoSequence(GitRepositoryManager repoManager, GitReferenceUpdated gitRefUpdated, Project.NameKey projectName, String name, RepoSequence.Seed seed, int batchSize, int floor)
-
-
Method Detail
-
next
public int next()
Retrieves the next available sequence number.This method is thread-safe.
- Returns:
- the next available sequence number
-
next
public com.google.common.collect.ImmutableList<Integer> next(int count)
Retrieves the next N available sequence number.This method is thread-safe.
- Parameters:
count
- the number of sequence numbers which should be returned- Returns:
- the next N available sequence numbers
-
storeNew
public static org.eclipse.jgit.transport.ReceiveCommand storeNew(org.eclipse.jgit.lib.ObjectInserter ins, String name, int val) throws IOException
- Throws:
IOException
-
-