Interface NodeStore

  • All Known Implementing Classes:
    CompositeNodeStore, MemoryNodeStore, ProxyNodeStore

    public interface NodeStore
    Storage abstraction for trees. At any given point in time the stored tree is rooted at a single immutable node state.

    This is a low-level interface that doesn't cover functionality like merging concurrent changes or rejecting new tree states based on some higher-level consistency constraints.

    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      @NotNull java.lang.String checkpoint​(long lifetime)
      Creates a new checkpoint of the latest root of the tree.
      @NotNull java.lang.String checkpoint​(long lifetime, @NotNull java.util.Map<java.lang.String,​java.lang.String> properties)
      Creates a new checkpoint of the latest root of the tree.
      @NotNull java.util.Map<java.lang.String,​java.lang.String> checkpointInfo​(@NotNull java.lang.String checkpoint)
      Retrieve the properties associated with a checkpoint.
      @NotNull java.lang.Iterable<java.lang.String> checkpoints()
      Returns all valid checkpoints.
      @NotNull Blob createBlob​(java.io.InputStream inputStream)
      Create a Blob from the given input stream.
      @Nullable Blob getBlob​(@NotNull java.lang.String reference)
      Get a blob by its reference.
      @NotNull NodeState getRoot()
      Returns the latest state of the tree.
      @NotNull NodeState merge​(@NotNull NodeBuilder builder, @NotNull CommitHook commitHook, @NotNull CommitInfo info)
      Merges the changes between the base and head states of the given builder to this store.
      @NotNull NodeState rebase​(@NotNull NodeBuilder builder)
      Rebases the changes between the base and head states of the given builder on top of the current root state.
      boolean release​(@NotNull java.lang.String checkpoint)
      Releases the provided checkpoint.
      NodeState reset​(@NotNull NodeBuilder builder)
      Reset the passed builder by throwing away all its changes and setting its base state to the current root state.
      @Nullable NodeState retrieve​(@NotNull java.lang.String checkpoint)
      Retrieves the root node from a previously created repository checkpoint.
    • Method Detail

      • getRoot

        @NotNull
        @NotNull NodeState getRoot()
        Returns the latest state of the tree.
        Returns:
        root node state
      • merge

        @NotNull
        @NotNull NodeState merge​(@NotNull
                                 @NotNull NodeBuilder builder,
                                 @NotNull
                                 @NotNull CommitHook commitHook,
                                 @NotNull
                                 @NotNull CommitInfo info)
                          throws CommitFailedException
        Merges the changes between the base and head states of the given builder to this store.
        Parameters:
        builder - the builder whose changes to apply
        commitHook - the commit hook to apply while merging changes
        info - commit info associated with this merge operation
        Returns:
        the node state resulting from the merge.
        Throws:
        CommitFailedException - if the merge failed
        java.lang.IllegalArgumentException - if the builder is not acquired from a root state of this store
      • rebase

        @NotNull
        @NotNull NodeState rebase​(@NotNull
                                  @NotNull NodeBuilder builder)
        Rebases the changes between the base and head states of the given builder on top of the current root state. The base state of the given builder becomes the latest root state of the repository, and the head state will contain the rebased changes.
        Parameters:
        builder - the builder to rebase
        Returns:
        the node state resulting from the rebase.
        Throws:
        java.lang.IllegalArgumentException - if the builder is not acquired from a root state of this store
      • reset

        NodeState reset​(@NotNull
                        @NotNull NodeBuilder builder)
        Reset the passed builder by throwing away all its changes and setting its base state to the current root state.
        Parameters:
        builder - the builder to reset
        Returns:
        the node state resulting from the reset.
        Throws:
        java.lang.IllegalArgumentException - if the builder is not acquired from a root state of this store
      • createBlob

        @NotNull
        @NotNull Blob createBlob​(java.io.InputStream inputStream)
                          throws java.io.IOException
        Create a Blob from the given input stream. The input stream is closed after this method returns.
        Parameters:
        inputStream - The input stream for the Blob
        Returns:
        The Blob representing inputStream
        Throws:
        java.io.IOException - If an error occurs while reading from the stream
      • getBlob

        @Nullable
        @Nullable Blob getBlob​(@NotNull
                               @NotNull java.lang.String reference)
        Get a blob by its reference.
        Parameters:
        reference - reference to the blob
        Returns:
        blob or null if the reference does not resolve to a blob.
        See Also:
        Blob.getReference()
      • checkpoint

        @NotNull
        @NotNull java.lang.String checkpoint​(long lifetime,
                                             @NotNull
                                             @NotNull java.util.Map<java.lang.String,​java.lang.String> properties)
        Creates a new checkpoint of the latest root of the tree. The checkpoint remains valid for at least as long as requested and allows that state of the repository to be retrieved using the returned opaque string reference.

        The properties passed to this methods are associated with the checkpoint and can be retrieved through the checkpointInfo(String) method. Its semantics is entirely application specific.

        Parameters:
        lifetime - time (in milliseconds, > 0) that the checkpoint should remain available
        properties - properties to associate with the checkpoint
        Returns:
        string reference of this checkpoint
      • checkpoint

        @NotNull
        @NotNull java.lang.String checkpoint​(long lifetime)
        Creates a new checkpoint of the latest root of the tree. The checkpoint remains valid for at least as long as requested and allows that state of the repository to be retrieved using the returned opaque string reference.

        This method is a shortcut for checkpoint(long, Map) passing an empty map for its 2nd argument.

        Parameters:
        lifetime - time (in milliseconds, > 0) that the checkpoint should remain available
        Returns:
        string reference of this checkpoint
      • checkpointInfo

        @NotNull
        @NotNull java.util.Map<java.lang.String,​java.lang.String> checkpointInfo​(@NotNull
                                                                                       @NotNull java.lang.String checkpoint)
        Retrieve the properties associated with a checkpoint.
        Parameters:
        checkpoint - string reference of a checkpoint
        Returns:
        the properties associated with the checkpoint referenced by checkpoint or an empty map when there is no such checkpoint.
      • checkpoints

        @NotNull
        @NotNull java.lang.Iterable<java.lang.String> checkpoints()
        Returns all valid checkpoints. The returned Iterable provides a snapshot of valid checkpoints at the time this method is called. That is, the Iterable will not reflect checkpoints created after this method was called.

        See checkpoint(long, Map) for a definition of a valid checkpoint.

        Returns:
        valid checkpoints.
      • retrieve

        @Nullable
        @Nullable NodeState retrieve​(@NotNull
                                     @NotNull java.lang.String checkpoint)
        Retrieves the root node from a previously created repository checkpoint.
        Parameters:
        checkpoint - string reference of a checkpoint
        Returns:
        the root node of the checkpoint, or null if the checkpoint is no longer available
      • release

        boolean release​(@NotNull
                        @NotNull java.lang.String checkpoint)
        Releases the provided checkpoint. If the provided checkpoint doesn't exist this method should return true.
        Parameters:
        checkpoint - string reference of a checkpoint
        Returns:
        true if the checkpoint was successfully removed, or if it doesn't exist