Interface StreamManager

  • All Superinterfaces:
    java.lang.AutoCloseable

    public interface StreamManager
    extends java.lang.AutoCloseable
    Used to create, delete, and manage Streams and ReaderGroups.
    • Method Summary

      All Methods Static Methods Instance Methods Abstract Methods Deprecated Methods 
      Modifier and Type Method Description
      boolean checkScopeExists​(java.lang.String scopeName)
      Checks if a scope exists.
      boolean checkStreamExists​(java.lang.String scopeName, java.lang.String streamName)
      Checks if a stream exists in scope.
      void close()
      Closes the stream manager.
      static StreamManager create​(ClientConfig clientConfig)
      Creates a new instance of StreamManager.
      static StreamManager create​(java.net.URI controller)
      Creates a new instance of StreamManager.
      boolean createScope​(java.lang.String scopeName)
      Creates a new scope.
      boolean createStream​(java.lang.String scopeName, java.lang.String streamName, StreamConfiguration config)
      Creates a new stream
      boolean deleteScope​(java.lang.String scopeName)
      Deletes an existing scope.
      boolean deleteScope​(java.lang.String scopeName, boolean forceDelete)
      Deprecated.
      As of Pravega release 0.11.0, replaced by deleteScopeRecursive(String).
      boolean deleteScopeRecursive​(java.lang.String scopeName)
      Deletes scope by listing and deleting all streams/RGs/KVTs in scope.
      boolean deleteStream​(java.lang.String scopeName, java.lang.String toDelete)
      Deletes the provided stream.
      <T> java.util.concurrent.CompletableFuture<T> fetchEvent​(EventPointer pointer, Serializer<T> deserializer)
      Re-read an event that was previously read, by passing the pointer returned from EventRead.getEventPointer().
      java.util.concurrent.CompletableFuture<StreamInfo> fetchStreamInfo​(java.lang.String scopeName, java.lang.String streamName)
      Fetch information about a given Stream StreamInfo from server asynchronously.
      java.util.Collection<java.lang.String> getStreamTags​(java.lang.String scopeName, java.lang.String streamName)
      Gets the Tags associated with a stream.
      java.util.List<TransactionInfo> listCompletedTransactions​(Stream stream)
      List most recent completed (COMMITTED/ABORTED) transactions.
      java.util.Iterator<java.lang.String> listScopes()
      Gets an iterator for all scopes.
      java.util.Iterator<Stream> listStreams​(java.lang.String scopeName)
      Gets an iterator for all streams in scope.
      java.util.Iterator<Stream> listStreams​(java.lang.String scopeName, java.lang.String tagName)
      Gets an iterator to list all streams with the provided tag.
      boolean sealStream​(java.lang.String scopeName, java.lang.String streamName)
      Seal an existing stream.
      boolean truncateStream​(java.lang.String scopeName, java.lang.String streamName, StreamCut streamCut)
      Truncate stream at given stream cut.
      boolean updateStream​(java.lang.String scopeName, java.lang.String streamName, StreamConfiguration config)
      Change the configuration for an existing stream.
    • Method Detail

      • create

        static StreamManager create​(java.net.URI controller)
        Creates a new instance of StreamManager.
        Parameters:
        controller - The Controller URI.
        Returns:
        Instance of Stream Manager implementation.
      • create

        static StreamManager create​(ClientConfig clientConfig)
        Creates a new instance of StreamManager.
        Parameters:
        clientConfig - Configuration for the client connection to Pravega.
        Returns:
        Instance of Stream Manager implementation.
      • createStream

        boolean createStream​(java.lang.String scopeName,
                             java.lang.String streamName,
                             StreamConfiguration config)
        Creates a new stream

        Note: This method is idempotent assuming called with the same name and config. This method may block.

        Parameters:
        scopeName - The name of the scope to create this stream in.
        streamName - The name of the stream to be created.
        config - The configuration the stream should use.
        Returns:
        True if stream is created
      • updateStream

        boolean updateStream​(java.lang.String scopeName,
                             java.lang.String streamName,
                             StreamConfiguration config)
        Change the configuration for an existing stream.

        Note: This method is idempotent assuming called with the same name and config. This method may block.

        Parameters:
        scopeName - The name of the scope to create this stream in.
        streamName - The name of the stream who's config is to be changed.
        config - The new configuration.
        Returns:
        True if stream configuration is updated
      • truncateStream

        boolean truncateStream​(java.lang.String scopeName,
                               java.lang.String streamName,
                               StreamCut streamCut)
        Truncate stream at given stream cut. This method may block.
        Parameters:
        scopeName - The name of the scope to create this stream in.
        streamName - The name of the stream who's config is to be changed.
        streamCut - The stream cut to truncate at.
        Returns:
        True if stream is truncated at given truncation stream cut.
      • sealStream

        boolean sealStream​(java.lang.String scopeName,
                           java.lang.String streamName)
        Seal an existing stream.
        Parameters:
        scopeName - The name of the scope to create this stream in.
        streamName - The name of the stream which has to be sealed.
        Returns:
        True if stream is sealed
      • deleteStream

        boolean deleteStream​(java.lang.String scopeName,
                             java.lang.String toDelete)
        Deletes the provided stream. No more events may be written or read. Resources used by the stream will be freed.
        Parameters:
        scopeName - The name of the scope to create this stream in.
        toDelete - The name of the stream to be deleted.
        Returns:
        True if stream is deleted
      • listScopes

        java.util.Iterator<java.lang.String> listScopes()
        Gets an iterator for all scopes.
        Returns:
        Iterator to iterate over all scopes.
      • createScope

        boolean createScope​(java.lang.String scopeName)
        Creates a new scope.
        Parameters:
        scopeName - The name of the scope to create this stream in.
        Returns:
        True if scope is created
      • checkScopeExists

        boolean checkScopeExists​(java.lang.String scopeName)
        Checks if a scope exists.
        Parameters:
        scopeName - The name of the scope to check.
        Returns:
        True if scope exists.
      • listStreams

        java.util.Iterator<Stream> listStreams​(java.lang.String scopeName)
        Gets an iterator for all streams in scope.
        Parameters:
        scopeName - The name of the scope for which to list streams in.
        Returns:
        Iterator of Stream to iterator over all streams in scope.
      • listStreams

        java.util.Iterator<Stream> listStreams​(java.lang.String scopeName,
                                               java.lang.String tagName)
        Gets an iterator to list all streams with the provided tag.
        Parameters:
        scopeName - The name of the scope for which to list streams in.
        tagName - The name of the tag.
        Returns:
        Iterator of Stream to iterator over all streams in scope with the provided tag.
      • getStreamTags

        java.util.Collection<java.lang.String> getStreamTags​(java.lang.String scopeName,
                                                             java.lang.String streamName)
        Gets the Tags associated with a stream.
        Parameters:
        scopeName - Scope name.
        streamName - Stream name.
        Returns:
        Tags associated with the stream.
      • checkStreamExists

        boolean checkStreamExists​(java.lang.String scopeName,
                                  java.lang.String streamName)
        Checks if a stream exists in scope.
        Parameters:
        scopeName - The name of the scope to check the stream in.
        streamName - The name of the stream to check.
        Returns:
        True if stream exists.
      • deleteScope

        boolean deleteScope​(java.lang.String scopeName)
        Deletes an existing scope. The scope must contain no stream. This is same as calling deleteScope(String, boolean) with deleteStreams flag set to false.
        Parameters:
        scopeName - The name of the scope to delete.
        Returns:
        True if scope is deleted
      • deleteScope

        @Deprecated
        boolean deleteScope​(java.lang.String scopeName,
                            boolean forceDelete)
                     throws DeleteScopeFailedException
        Deprecated.
        As of Pravega release 0.11.0, replaced by deleteScopeRecursive(String).
        Deletes scope by listing and deleting all streams in scope. This method is not atomic and if new streams are added to the scope concurrently, the attempt to delete the scope may fail. Deleting scope is idempotent and failure to delete scope is retry-able.
        Parameters:
        scopeName - The name of the scope to delete.
        forceDelete - To list and delete streams, key-value tables and reader groups in scope before attempting to delete scope.
        Returns:
        True if scope is deleted, false otherwise.
        Throws:
        DeleteScopeFailedException - is thrown if this method is unable to seal and delete a stream.
      • deleteScopeRecursive

        boolean deleteScopeRecursive​(java.lang.String scopeName)
                              throws DeleteScopeFailedException
        Deletes scope by listing and deleting all streams/RGs/KVTs in scope. New streams/RGs/KVTs can not be added to the scope if this method is called.
        Parameters:
        scopeName - The name of the scope to delete.
        Returns:
        True if scope is deleted, false otherwise.
        Throws:
        DeleteScopeFailedException - is thrown if this method is unable to seal and delete a stream.
      • fetchEvent

        <T> java.util.concurrent.CompletableFuture<T> fetchEvent​(EventPointer pointer,
                                                                 Serializer<T> deserializer)
        Re-read an event that was previously read, by passing the pointer returned from EventRead.getEventPointer(). This does not affect the current position of any reader.

        This is a non-blocking call. Passing an EventPointer of a stream that has been deleted or data truncated away it will throw exception.

        Type Parameters:
        T - The type of the Event
        Parameters:
        pointer - It is an EventPointer obtained from the result of a previous readNextEvent call.
        deserializer - The Serializer
        Returns:
        A future for the provided EventPointer of the fetch call. If an exception occurred, it will be completed with the causing exception. Notable exception is NoSuchEventException
      • listCompletedTransactions

        java.util.List<TransactionInfo> listCompletedTransactions​(Stream stream)
        List most recent completed (COMMITTED/ABORTED) transactions. It will return transactionId, transaction status and stream.
        Parameters:
        stream - The name of the stream for which to list transactionInfo.
        Returns:
        List of TransactionInfo.
      • fetchStreamInfo

        @Beta
        java.util.concurrent.CompletableFuture<StreamInfo> fetchStreamInfo​(java.lang.String scopeName,
                                                                           java.lang.String streamName)
        Fetch information about a given Stream StreamInfo from server asynchronously. This includes StreamCuts pointing to the current HEAD and TAIL of the Stream and the current StreamConfiguration. Call join() on future object to get StreamInfo.
        Parameters:
        scopeName - The scope of the stream.
        streamName - The stream name.
        Returns:
        A future representing StreamInfo that will be completed when server responds.
      • close

        void close()
        Closes the stream manager.
        Specified by:
        close in interface java.lang.AutoCloseable
        See Also:
        AutoCloseable.close()