Package com.google.gerrit.server.notedb
Class RepoSequence
java.lang.Object
com.google.gerrit.server.notedb.RepoSequence
- All Implemented Interfaces:
Sequence
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 ClassesModifier and TypeClassDescriptionstatic class
A groups sequence provider that does not fire git reference updates.static class
static interface
Nested classes/interfaces inherited from interface com.google.gerrit.server.Sequence
Sequence.LightweightAccounts, Sequence.LightweightGroups, Sequence.SequenceType
-
Field Summary
Fields inherited from interface com.google.gerrit.server.Sequence
NAME_ACCOUNTS, NAME_CHANGES, NAME_GROUPS
-
Constructor Summary
ConstructorsConstructorDescriptionRepoSequence
(GitRepositoryManager repoManager, GitReferenceUpdated gitRefUpdated, Project.NameKey projectName, String name, RepoSequence.Seed seed, int batchSize) -
Method Summary
Modifier and TypeMethodDescriptionint
current()
Returns the next available sequence value.int
last()
Retrieves the last returned sequence number.int
next()
Retrieves the next available sequence number.com.google.common.collect.ImmutableList<Integer>
next
(int count) Retrieves the next N available sequence number.void
storeNew
(int value)
-
Constructor Details
-
RepoSequence
public RepoSequence(GitRepositoryManager repoManager, GitReferenceUpdated gitRefUpdated, Project.NameKey projectName, String name, RepoSequence.Seed seed, int batchSize)
-
-
Method Details
-
next
public int next()Retrieves the next available sequence number.This method is thread-safe.
-
next
Retrieves the next N available sequence number.This method is thread-safe.
-
storeNew
public void storeNew(int value) Description copied from interface:Sequence
-
current
public int current()Description copied from interface:Sequence
Returns the next available sequence value. -
last
public int last()Retrieves the last returned sequence number.Explicitly calls
next()
if this instance didn't return sequence number until now.
-