Package com.google.gerrit.server.notedb
Class NoteDbChangeState
- java.lang.Object
-
- com.google.gerrit.server.notedb.NoteDbChangeState
-
public class NoteDbChangeState extends Object
The state of all relevant NoteDb refs across all repos corresponding to a given Change entity.Stored serialized in the
Change#noteDbState
field, and used to determine whether the state in NoteDb is out of date.Serialized in one of the forms:
- [meta-sha],[account1]=[drafts-sha],[account2]=[drafts-sha]...
- R,[meta-sha],[account1]=[drafts-sha],[account2]=[drafts-sha]...
- R=[read-only-until],[meta-sha],[account1]=[drafts-sha],[account2]=[drafts-sha]...
- N
- N=[read-only-until]
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
NoteDbChangeState.Delta
static class
NoteDbChangeState.PrimaryStorage
static class
NoteDbChangeState.RefState
-
Field Summary
Fields Modifier and Type Field Description static String
NOTE_DB_PRIMARY_STATE
-
Constructor Summary
Constructors Constructor Description NoteDbChangeState(Change.Id changeId, NoteDbChangeState.PrimaryStorage primaryStorage, Optional<NoteDbChangeState.RefState> refState, Optional<Timestamp> readOnlyUntil)
-
Method Summary
-
-
-
Field Detail
-
NOTE_DB_PRIMARY_STATE
public static final String NOTE_DB_PRIMARY_STATE
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
NoteDbChangeState
public NoteDbChangeState(Change.Id changeId, NoteDbChangeState.PrimaryStorage primaryStorage, Optional<NoteDbChangeState.RefState> refState, Optional<Timestamp> readOnlyUntil)
-
-
Method Detail
-
parse
public static NoteDbChangeState parse(Change c)
-
parse
public static NoteDbChangeState parse(Change.Id id, String str)
-
applyDelta
public static NoteDbChangeState applyDelta(Change change, NoteDbChangeState.Delta delta)
Apply a delta to the state stored in a change entity.This method does not check whether the old state was read-only; it is up to the caller to not violate read-only semantics when storing the change back in ReviewDb.
- Parameters:
change
- change entity. The delta is applied against this entity'snoteDbState
and the new state is stored back in the entity as a side effect.delta
- delta to apply.- Returns:
- new state, equivalent to what is stored in
change
as a side effect.
-
isChangeUpToDate
public static boolean isChangeUpToDate(NoteDbChangeState state, RefCache changeRepoRefs, Change.Id changeId) throws IOException
- Throws:
IOException
-
areDraftsUpToDate
public static boolean areDraftsUpToDate(NoteDbChangeState state, RefCache draftsRepoRefs, Change.Id changeId, Account.Id accountId) throws IOException
- Throws:
IOException
-
getReadOnlySkew
public static long getReadOnlySkew(org.eclipse.jgit.lib.Config cfg)
-
checkNotReadOnly
public static void checkNotReadOnly(Change change, long skewMs)
-
checkNotReadOnly
public static void checkNotReadOnly(NoteDbChangeState state, long skewMs)
-
getPrimaryStorage
public NoteDbChangeState.PrimaryStorage getPrimaryStorage()
-
isChangeUpToDate
public boolean isChangeUpToDate(RefCache changeRepoRefs) throws IOException
- Throws:
IOException
-
areDraftsUpToDate
public boolean areDraftsUpToDate(RefCache draftsRepoRefs, Account.Id accountId) throws IOException
- Throws:
IOException
-
isUpToDate
public boolean isUpToDate(RefCache changeRepoRefs, RefCache draftsRepoRefs) throws IOException
- Throws:
IOException
-
isReadOnly
public boolean isReadOnly(Timestamp now)
-
withReadOnlyUntil
public NoteDbChangeState withReadOnlyUntil(Timestamp ts)
-
getChangeId
public Change.Id getChangeId()
-
getChangeMetaId
public org.eclipse.jgit.lib.ObjectId getChangeMetaId()
-
getDraftIds
public com.google.common.collect.ImmutableMap<Account.Id,org.eclipse.jgit.lib.ObjectId> getDraftIds()
-
getRefState
public Optional<NoteDbChangeState.RefState> getRefState()
-
-