Class ObservingVersionStore
- java.lang.Object
-
- org.projectnessie.versioned.ObservingVersionStore
-
- All Implemented Interfaces:
VersionStore
public class ObservingVersionStore extends java.lang.Object implements VersionStore
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.projectnessie.versioned.VersionStore
VersionStore.CommitValidator, VersionStore.KeyRestrictions, VersionStore.MergeOp, VersionStore.MergeTransplantOpBase, VersionStore.TransplantOp
-
-
Constructor Summary
Constructors Constructor Description ObservingVersionStore(VersionStore delegate)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ReferenceAssignedResultassign(NamedRef ref, Hash expectedHash, Hash targetHash)Assign the NamedRef to point to a particular hash.CommitResult<Commit>commit(BranchName branch, java.util.Optional<Hash> referenceHash, org.projectnessie.model.CommitMeta metadata, java.util.List<Operation> operations, VersionStore.CommitValidator validator, java.util.function.BiConsumer<org.projectnessie.model.ContentKey,java.lang.String> addedContents)Create a new commit and add to a branch.ReferenceCreatedResultcreate(NamedRef ref, java.util.Optional<Hash> targetHash)Assign the NamedRef to point to a particular hash.ReferenceDeletedResultdelete(NamedRef ref, Hash hash)Delete the provided NamedRefPaginationIterator<Commit>getCommits(Ref ref, boolean fetchAdditionalInfo)Get a stream of all ancestor commits to a provided ref.PaginationIterator<Diff>getDiffs(Ref from, Ref to, java.lang.String pagingToken, VersionStore.KeyRestrictions keyRestrictions)Get list of diffs between two refs.java.util.List<org.projectnessie.model.IdentifiedContentKey>getIdentifiedKeys(Ref ref, java.util.Collection<org.projectnessie.model.ContentKey> keys)PaginationIterator<KeyEntry>getKeys(Ref ref, java.lang.String pagingToken, boolean withContent, VersionStore.KeyRestrictions keyRestrictions)Get a stream of all available keys for the given ref.ReferenceInfo<org.projectnessie.model.CommitMeta>getNamedRef(java.lang.String ref, GetNamedRefsParams params)Resolve the givenNamedRefand return information about it, which at least contains the current HEAD commit hash plus, optionally, additional information.PaginationIterator<ReferenceInfo<org.projectnessie.model.CommitMeta>>getNamedRefs(GetNamedRefsParams params, java.lang.String pagingToken)List named refs.ReferenceHistorygetReferenceHistory(java.lang.String refName, java.lang.Integer headCommitsToScan)Retrieve the recorded recent history of a reference.java.util.List<org.projectnessie.model.RepositoryConfig>getRepositoryConfig(java.util.Set<org.projectnessie.model.RepositoryConfig.Type> repositoryConfigTypes)RepositoryInformationgetRepositoryInformation()ContentResultgetValue(Ref ref, org.projectnessie.model.ContentKey key)Get the value for a provided ref.java.util.Map<org.projectnessie.model.ContentKey,ContentResult>getValues(Ref ref, java.util.Collection<org.projectnessie.model.ContentKey> keys)Get the values for a list of keys.HashhashOnReference(NamedRef namedReference, java.util.Optional<Hash> hashOnReference, java.util.List<RelativeCommitSpec> relativeLookups)Verifies that the givennamedReferenceexists and thathashOnReference, if present, is reachable via that reference.MergeResult<Commit>merge(VersionStore.MergeOp mergeOp)Merge items from an existing hash into the requested branch.HashnoAncestorHash()Retrieve the hash for "no ancestor" (or "beginning of time"), which is a hash for which no commit exists.MergeResult<Commit>transplant(VersionStore.TransplantOp transplantOp)Transplant a series of commits to a target branch.org.projectnessie.model.RepositoryConfigupdateRepositoryConfig(org.projectnessie.model.RepositoryConfig repositoryConfig)-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.projectnessie.versioned.VersionStore
commit
-
-
-
-
Constructor Detail
-
ObservingVersionStore
public ObservingVersionStore(VersionStore delegate)
-
-
Method Detail
-
getRepositoryInformation
@Nonnull public RepositoryInformation getRepositoryInformation()
- Specified by:
getRepositoryInformationin interfaceVersionStore
-
hashOnReference
public Hash hashOnReference(NamedRef namedReference, java.util.Optional<Hash> hashOnReference, java.util.List<RelativeCommitSpec> relativeLookups) throws ReferenceNotFoundException
Description copied from interface:VersionStoreVerifies that the givennamedReferenceexists and thathashOnReference, if present, is reachable via that reference.- Specified by:
hashOnReferencein interfaceVersionStore- Returns:
- verified
hashOnReferenceor, ifhashOnReferenceis not present, the current HEAD ofnamedReference - Throws:
ReferenceNotFoundException- ifnamedReferencedoes not exist orhashOnReference, if present, is not reachable from that reference
-
noAncestorHash
@Nonnull public Hash noAncestorHash()
Description copied from interface:VersionStoreRetrieve the hash for "no ancestor" (or "beginning of time"), which is a hash for which no commit exists. "no ancestor" or "beginning of time" are the initial hash of the default branch and branches that are created viaVersionStore.create(NamedRef, Optional)without specifying thetargetHash.This "no ancestor" value is readable for all users, and it is a valid hash for every named reference.
The result of this function must not change for any store instance, but it can be different for different backends and even for different instances of the same backend.
- Specified by:
noAncestorHashin interfaceVersionStore
-
commit
public CommitResult<Commit> commit(@Nonnull BranchName branch, @Nonnull java.util.Optional<Hash> referenceHash, @Nonnull org.projectnessie.model.CommitMeta metadata, @Nonnull java.util.List<Operation> operations, @Nonnull VersionStore.CommitValidator validator, @Nonnull java.util.function.BiConsumer<org.projectnessie.model.ContentKey,java.lang.String> addedContents) throws ReferenceNotFoundException, ReferenceConflictException
Description copied from interface:VersionStoreCreate a new commit and add to a branch.If
referenceHashis not empty, for each key referenced by one of the operations, the current key's value is compared with the stored value for referenceHash's tree, andReferenceConflictExceptionis thrown if values are not matching.- Specified by:
commitin interfaceVersionStore- Parameters:
branch- The branch to commit to.referenceHash- The hash to use as a reference for conflict detection. If not present, do not perform conflict detectionmetadata- The metadata associated with the commit.operations- The set of operations to apply.validator- Gets called during the atomic commit operations, callers can implement validation logic.addedContents- callback that receives the content-ID of _new_ content per content-key- Throws:
ReferenceNotFoundException- ifbranchis not present in the storeReferenceConflictException- ifreferenceHashvalues do not match the stored values forbranch
-
transplant
public MergeResult<Commit> transplant(VersionStore.TransplantOp transplantOp) throws ReferenceNotFoundException, ReferenceConflictException
Description copied from interface:VersionStoreTransplant a series of commits to a target branch.This is done as an atomic operation such that only the last of the sequence is ever visible to concurrent readers/writers. The sequence to transplant must be contiguous, in order and share a common ancestor with the target branch.
- Specified by:
transplantin interfaceVersionStore- Returns:
- merge result
- Throws:
ReferenceNotFoundException- ifbranchor if any of the hashes fromsequenceToTransplantis not present in the store.ReferenceConflictException- ifreferenceHashvalues do not match the stored values forbranch
-
merge
public MergeResult<Commit> merge(VersionStore.MergeOp mergeOp) throws ReferenceNotFoundException, ReferenceConflictException
Description copied from interface:VersionStoreMerge items from an existing hash into the requested branch. The merge is always a rebase + fast-forward merge and is only completed if the rebase is conflict free. The set of commits added to the branch will be all of those until we arrive at a common ancestor. Depending on the underlying implementation, the number of commits allowed as part of this operation may be limitedThrows if any of the following are true:
- the hash or the branch do not exists
- the rebase has conflicts
- the expected branch hash does not match the actual branch hash
- Specified by:
mergein interfaceVersionStore- Returns:
- merge result
- Throws:
ReferenceNotFoundException- iftoBranchorfromHashis not present in the store.ReferenceConflictException- ifexpectedBranchHashdoesn't match the stored hash fortoBranch
-
assign
public ReferenceAssignedResult assign(NamedRef ref, Hash expectedHash, Hash targetHash) throws ReferenceNotFoundException, ReferenceConflictException
Description copied from interface:VersionStoreAssign the NamedRef to point to a particular hash.refshould already exists. IfexpectedHashis not empty, its value is compared with the current stored value forrefand an exception is thrown if values do not match.- Specified by:
assignin interfaceVersionStore- Parameters:
ref- The named ref to be assignedexpectedHash- The current head of the NamedRef to validate before updating (required).targetHash- The hash that this ref should refer to.- Returns:
- A
ReferenceAssignedResultcontaining the previous and current head of the reference - Throws:
ReferenceNotFoundException- ifrefis not present in the store or iftargetHashis not present in the storeReferenceConflictException- ifexpectedHashis not empty and its value doesn't match the stored hash forref
-
create
public ReferenceCreatedResult create(NamedRef ref, java.util.Optional<Hash> targetHash) throws ReferenceNotFoundException, ReferenceAlreadyExistsException
Description copied from interface:VersionStoreAssign the NamedRef to point to a particular hash. If the NamedRef does not exist, it will be created.- Specified by:
createin interfaceVersionStore- Parameters:
ref- The named ref we're assigningtargetHash- The hash that this ref should refer to (optional). Otherwise will reference the beginning of time.- Returns:
- A
ReferenceCreatedResultcontaining the head of the created reference - Throws:
ReferenceNotFoundException- iftargetHashis not empty and not present in the storeReferenceAlreadyExistsException- ifrefalready exists
-
delete
public ReferenceDeletedResult delete(NamedRef ref, Hash hash) throws ReferenceNotFoundException, ReferenceConflictException
Description copied from interface:VersionStoreDelete the provided NamedRefThrows exception if the optional hash does not match the provided ref.
- Specified by:
deletein interfaceVersionStore- Parameters:
ref- The NamedRef to be deleted.hash- The expected hash (required). The operation will only succeed if the branch is pointing at the provided hash.- Returns:
- A
ReferenceDeletedResultcontaining the head of the deleted reference - Throws:
ReferenceNotFoundException- ifrefis not present in the storeReferenceConflictException- ifhashdoesn't match the stored hash forref
-
getNamedRef
public ReferenceInfo<org.projectnessie.model.CommitMeta> getNamedRef(java.lang.String ref, GetNamedRefsParams params) throws ReferenceNotFoundException
Description copied from interface:VersionStoreResolve the givenNamedRefand return information about it, which at least contains the current HEAD commit hash plus, optionally, additional information.This is a functionally equivalent to
hashOnReference(ref, Optional.empty(), Collections.emptyList()).- Specified by:
getNamedRefin interfaceVersionStore- Parameters:
ref- The branch or tag to lookup.params- options that control which information shall be returned inReferenceInfo, seeGetNamedRefsParamsfor details.- Returns:
- Requested information about the requested reference.
- Throws:
ReferenceNotFoundException- if the reference cannot be found
-
getReferenceHistory
public ReferenceHistory getReferenceHistory(java.lang.String refName, java.lang.Integer headCommitsToScan) throws ReferenceNotFoundException
Description copied from interface:VersionStoreRetrieve the recorded recent history of a reference. A reference's history is a size and time limited record of changes of the reference's current pointer, aka HEAD. The size and time limits are configured in the Nessie server configuration.- Specified by:
getReferenceHistoryin interfaceVersionStore- Returns:
- recorded reference history
- Throws:
ReferenceNotFoundException
-
getNamedRefs
public PaginationIterator<ReferenceInfo<org.projectnessie.model.CommitMeta>> getNamedRefs(GetNamedRefsParams params, java.lang.String pagingToken) throws ReferenceNotFoundException
Description copied from interface:VersionStoreList named refs.IMPORTANT NOTE: The returned
Streammust be closed!- Specified by:
getNamedRefsin interfaceVersionStore- Parameters:
params- options that control which information shall be returned in eachReferenceInfo, seeReferenceInfofor details.pagingToken- paging token to start at- Returns:
- All refs and their associated hashes.
- Throws:
ReferenceNotFoundException
-
getCommits
public PaginationIterator<Commit> getCommits(Ref ref, boolean fetchAdditionalInfo) throws ReferenceNotFoundException
Description copied from interface:VersionStoreGet a stream of all ancestor commits to a provided ref.- Specified by:
getCommitsin interfaceVersionStore- Parameters:
ref- the stream to get commits for.fetchAdditionalInfo- include additional information like operations and parent hash- Returns:
- A stream of commits.
- Throws:
ReferenceNotFoundException- ifrefis not present in the store
-
getKeys
public PaginationIterator<KeyEntry> getKeys(Ref ref, java.lang.String pagingToken, boolean withContent, VersionStore.KeyRestrictions keyRestrictions) throws ReferenceNotFoundException
Description copied from interface:VersionStoreGet a stream of all available keys for the given ref.- Specified by:
getKeysin interfaceVersionStore- Parameters:
ref- The ref to get keys for.pagingToken- paging token to start atwithContent- whether to populateKeyEntry.getContent()- Returns:
- The stream of keys available for this ref.
- Throws:
ReferenceNotFoundException- ifrefis not present in the store
-
getIdentifiedKeys
public java.util.List<org.projectnessie.model.IdentifiedContentKey> getIdentifiedKeys(Ref ref, java.util.Collection<org.projectnessie.model.ContentKey> keys) throws ReferenceNotFoundException
- Specified by:
getIdentifiedKeysin interfaceVersionStore- Throws:
ReferenceNotFoundException
-
getValue
public ContentResult getValue(Ref ref, org.projectnessie.model.ContentKey key) throws ReferenceNotFoundException
Description copied from interface:VersionStoreGet the value for a provided ref.- Specified by:
getValuein interfaceVersionStore- Parameters:
ref- Any ref type allowedkey- The key for the specific value- Returns:
- The value.
- Throws:
ReferenceNotFoundException- ifrefis not present in the store
-
getValues
public java.util.Map<org.projectnessie.model.ContentKey,ContentResult> getValues(Ref ref, java.util.Collection<org.projectnessie.model.ContentKey> keys) throws ReferenceNotFoundException
Description copied from interface:VersionStoreGet the values for a list of keys.- Specified by:
getValuesin interfaceVersionStore- Parameters:
ref- The ref to use.keys- An ordered list of keys to retrieve within the provided ref.- Returns:
- A parallel list of values.
- Throws:
ReferenceNotFoundException- ifrefis not present in the store
-
getDiffs
public PaginationIterator<Diff> getDiffs(Ref from, Ref to, java.lang.String pagingToken, VersionStore.KeyRestrictions keyRestrictions) throws ReferenceNotFoundException
Description copied from interface:VersionStoreGet list of diffs between two refs.- Specified by:
getDiffsin interfaceVersionStore- Parameters:
from- The from part of the diff.to- The to part of the diff.pagingToken- paging token to start at- Returns:
- A stream of values that are different.
- Throws:
ReferenceNotFoundException
-
getRepositoryConfig
public java.util.List<org.projectnessie.model.RepositoryConfig> getRepositoryConfig(java.util.Set<org.projectnessie.model.RepositoryConfig.Type> repositoryConfigTypes)
- Specified by:
getRepositoryConfigin interfaceVersionStore
-
updateRepositoryConfig
public org.projectnessie.model.RepositoryConfig updateRepositoryConfig(org.projectnessie.model.RepositoryConfig repositoryConfig) throws ReferenceConflictException- Specified by:
updateRepositoryConfigin interfaceVersionStore- Throws:
ReferenceConflictException
-
-