Class ControllerImpl

  • All Implemented Interfaces:
    Controller, java.lang.AutoCloseable

    public class ControllerImpl
    extends java.lang.Object
    implements Controller
    RPC based client implementation of Stream Controller V1 API.
    • Constructor Summary

      Constructors 
      Constructor Description
      ControllerImpl​(io.grpc.ManagedChannelBuilder<?> channelBuilder, ControllerImplConfig config, java.util.concurrent.ScheduledExecutorService executor)
      Creates a new instance of the Controller client class.
      ControllerImpl​(ControllerImplConfig config, java.util.concurrent.ScheduledExecutorService executor)
      Creates a new instance of the Controller client class.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.util.concurrent.CompletableFuture<java.lang.Void> abortTransaction​(Stream stream, java.util.UUID txId)
      Aborts a transaction.
      java.util.concurrent.CompletableFuture<java.lang.Boolean> checkScaleStatus​(Stream stream, int scaleEpoch)
      API to check the status of scale for a given epoch.
      java.util.concurrent.CompletableFuture<java.lang.Boolean> checkScopeExists​(java.lang.String scopeName)
      Check if scope exists.
      java.util.concurrent.CompletableFuture<java.lang.Boolean> checkStreamExists​(java.lang.String scopeName, java.lang.String streamName)
      Check if stream exists.
      java.util.concurrent.CompletableFuture<Transaction.Status> checkTransactionStatus​(Stream stream, java.util.UUID txId)
      Returns the status of the specified transaction.
      void close()
      Closes controller client.
      java.util.concurrent.CompletableFuture<java.lang.Void> commitTransaction​(Stream stream, java.lang.String writerId, java.lang.Long timestamp, java.util.UUID txId)
      Commits a transaction, atomically committing all events to the stream, subject to the ordering guarantees specified in EventStreamWriter.
      java.util.concurrent.CompletableFuture<java.lang.Boolean> createKeyValueTable​(java.lang.String scope, java.lang.String kvtName, KeyValueTableConfiguration kvtConfig)
      API to create a KeyValueTable.
      java.util.concurrent.CompletableFuture<ReaderGroupConfig> createReaderGroup​(java.lang.String scope, java.lang.String rgName, ReaderGroupConfig rgConfig)
      API create a ReaderGroup.
      java.util.concurrent.CompletableFuture<java.lang.Boolean> createScope​(java.lang.String scopeName)
      API to create a scope.
      java.util.concurrent.CompletableFuture<java.lang.Boolean> createStream​(java.lang.String scope, java.lang.String streamName, StreamConfiguration streamConfig)
      API to create a stream.
      java.util.concurrent.CompletableFuture<TxnSegments> createTransaction​(Stream stream, long lease)
      API to create a new transaction.
      java.util.concurrent.CompletableFuture<java.lang.Boolean> deleteKeyValueTable​(java.lang.String scope, java.lang.String kvtName)
      API to delete a KeyValueTable.
      java.util.concurrent.CompletableFuture<java.lang.Boolean> deleteReaderGroup​(java.lang.String scope, java.lang.String rgName, java.util.UUID readerGroupId)
      API to delete a Reader Group.
      java.util.concurrent.CompletableFuture<java.lang.Boolean> deleteScope​(java.lang.String scopeName)
      API to delete a scope.
      java.util.concurrent.CompletableFuture<java.lang.Boolean> deleteStream​(java.lang.String scope, java.lang.String streamName)
      API to delete a stream.
      java.util.concurrent.CompletableFuture<StreamSegments> getCurrentSegments​(java.lang.String scope, java.lang.String stream)
      API to get list of current segments for the stream to write to.
      java.util.concurrent.CompletableFuture<KeyValueTableSegments> getCurrentSegmentsForKeyValueTable​(java.lang.String scope, java.lang.String kvtName)
      API to get list of current segments for the KeyValueTable to write to.
      java.util.concurrent.CompletableFuture<io.pravega.shared.protocol.netty.PravegaNodeUri> getEndpointForSegment​(java.lang.String qualifiedSegmentName)
      Given a segment return the endpoint that currently is the owner of that segment.
      java.util.concurrent.CompletableFuture<StreamSegments> getEpochSegments​(java.lang.String scope, java.lang.String stream, int epoch)
      API to get list of segments for given epoch.
      java.util.concurrent.CompletableFuture<KeyValueTableConfiguration> getKeyValueTableConfiguration​(java.lang.String scope, java.lang.String kvtName)
      java.util.concurrent.CompletableFuture<java.lang.String> getOrRefreshDelegationTokenFor​(java.lang.String scope, java.lang.String streamName, io.pravega.shared.security.auth.AccessOperation accessOperation)
      Obtains a delegation token from the server.
      java.util.concurrent.CompletableFuture<ReaderGroupConfig> getReaderGroupConfig​(java.lang.String scope, java.lang.String rgName)
      API to get Reader Group Configuration.
      java.util.concurrent.CompletableFuture<StreamSegmentSuccessors> getSegments​(StreamCut fromStreamCut, StreamCut toStreamCut)
      Returns all the segments from the fromStreamCut till toStreamCut.
      java.util.concurrent.CompletableFuture<java.util.Map<Segment,​java.lang.Long>> getSegmentsAtTime​(Stream stream, long timestamp)
      Given a timestamp and a stream returns segments and offsets that were present at that time in the stream.
      java.util.concurrent.CompletableFuture<StreamConfiguration> getStreamConfiguration​(java.lang.String scopeName, java.lang.String streamName)
      Fetch the current Stream Configuration.
      java.util.concurrent.CompletableFuture<StreamSegmentsWithPredecessors> getSuccessors​(Segment segment)
      Returns StreamSegmentsWithPredecessors containing each of the segments that are successors to the segment requested mapped to a list of their predecessors.
      java.util.concurrent.CompletableFuture<StreamSegmentSuccessors> getSuccessors​(StreamCut from)
      Returns all the segments that come after the provided cutpoint.
      java.util.concurrent.CompletableFuture<java.lang.Boolean> isSegmentOpen​(Segment segment)
      Checks to see if a segment exists and is not sealed.
      io.pravega.common.util.AsyncIterator<KeyValueTableInfo> listKeyValueTables​(java.lang.String scopeName)
      Gets an AsyncIterator on KeyValueTables in scope.
      io.pravega.common.util.AsyncIterator<java.lang.String> listScopes()
      Gets an async iterator on scopes.
      io.pravega.common.util.AsyncIterator<Stream> listStreams​(java.lang.String scopeName)
      Gets an async iterator on streams in scope.
      io.pravega.common.util.AsyncIterator<Stream> listStreamsForTag​(java.lang.String scopeName, java.lang.String tag)
      Gets an async iterator on streams in scope.
      java.util.concurrent.CompletableFuture<java.util.List<java.lang.String>> listSubscribers​(java.lang.String scope, java.lang.String streamName)
      Get list of Subscribers for the Stream.
      java.util.concurrent.CompletableFuture<java.lang.Void> noteTimestampFromWriter​(java.lang.String writer, Stream stream, long timestamp, WriterPosition lastWrittenPosition)
      Notifies that the specified writer has noted the provided timestamp when it was at lastWrittenPosition.
      java.util.concurrent.CompletableFuture<Transaction.PingStatus> pingTransaction​(Stream stream, java.util.UUID txId, long lease)
      API to send transaction heartbeat and increase the transaction timeout by lease amount of milliseconds.
      java.util.concurrent.CompletableFuture<java.lang.Void> removeWriter​(java.lang.String writerId, Stream stream)
      Notifies the controller that the specified writer is shutting down gracefully and no longer needs to be considered for calculating entries for the marks segment.
      CancellableRequest<java.lang.Boolean> scaleStream​(Stream stream, java.util.List<java.lang.Long> sealedSegments, java.util.Map<java.lang.Double,​java.lang.Double> newKeyRanges, java.util.concurrent.ScheduledExecutorService executor)
      API to merge or split stream segments.
      java.util.concurrent.CompletableFuture<java.lang.Boolean> sealStream​(java.lang.String scope, java.lang.String streamName)
      API to seal a stream.
      java.util.concurrent.CompletableFuture<java.lang.Boolean> startScale​(Stream stream, java.util.List<java.lang.Long> sealedSegments, java.util.Map<java.lang.Double,​java.lang.Double> newKeyRanges)
      API to request start of scale operation on controller.
      java.util.concurrent.CompletableFuture<java.lang.Boolean> truncateStream​(java.lang.String scope, java.lang.String stream, StreamCut streamCut)
      API to Truncate stream.
      java.util.concurrent.CompletableFuture<java.lang.Long> updateReaderGroup​(java.lang.String scope, java.lang.String rgName, ReaderGroupConfig rgConfig)
      API to update a ReaderGroup config.
      java.util.concurrent.CompletableFuture<java.lang.Boolean> updateStream​(java.lang.String scope, java.lang.String streamName, StreamConfiguration streamConfig)
      API to update the configuration of a stream.
      java.util.concurrent.CompletableFuture<java.lang.Boolean> updateSubscriberStreamCut​(java.lang.String scope, java.lang.String streamName, java.lang.String subscriber, java.util.UUID readerGroupId, long generation, StreamCut streamCut)
      API to update the truncation StreamCut for a particular Subscriber on Controller.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ControllerImpl

        public ControllerImpl​(ControllerImplConfig config,
                              java.util.concurrent.ScheduledExecutorService executor)
        Creates a new instance of the Controller client class.
        Parameters:
        config - The configuration for this client implementation.
        executor - The executor service to be used for handling retries.
      • ControllerImpl

        public ControllerImpl​(io.grpc.ManagedChannelBuilder<?> channelBuilder,
                              ControllerImplConfig config,
                              java.util.concurrent.ScheduledExecutorService executor)
        Creates a new instance of the Controller client class.
        Parameters:
        channelBuilder - The channel builder to connect to the service instance.
        config - The configuration for this client implementation.
        executor - The executor service to be used internally.
    • Method Detail

      • createScope

        public java.util.concurrent.CompletableFuture<java.lang.Boolean> createScope​(java.lang.String scopeName)
        Description copied from interface: Controller
        API to create a scope. The future completes with true in the case the scope did not exist when the controller executed the operation. In the case of a re-attempt to create the same scope, the future completes with false to indicate that the scope existed when the controller executed the operation.
        Specified by:
        createScope in interface Controller
        Parameters:
        scopeName - Scope name.
        Returns:
        A future which will throw if the operation fails, otherwise returning a boolean to indicate that the scope was added because it did not already exist.
      • checkScopeExists

        public java.util.concurrent.CompletableFuture<java.lang.Boolean> checkScopeExists​(java.lang.String scopeName)
        Description copied from interface: Controller
        Check if scope exists.
        Specified by:
        checkScopeExists in interface Controller
        Parameters:
        scopeName - name of scope.
        Returns:
        CompletableFuture which when completed will indicate if scope exists or not.
      • listScopes

        public io.pravega.common.util.AsyncIterator<java.lang.String> listScopes()
        Description copied from interface: Controller
        Gets an async iterator on scopes.
        Specified by:
        listScopes in interface Controller
        Returns:
        An AsyncIterator which can be used to iterate over all scopes.
      • listStreams

        public io.pravega.common.util.AsyncIterator<Stream> listStreams​(java.lang.String scopeName)
        Description copied from interface: Controller
        Gets an async iterator on streams in scope.
        Specified by:
        listStreams in interface Controller
        Parameters:
        scopeName - The name of the scope for which to list streams in.
        Returns:
        An AsyncIterator which can be used to iterate over all Streams in the scope.
      • listStreamsForTag

        public io.pravega.common.util.AsyncIterator<Stream> listStreamsForTag​(java.lang.String scopeName,
                                                                              java.lang.String tag)
        Description copied from interface: Controller
        Gets an async iterator on streams in scope.
        Specified by:
        listStreamsForTag in interface Controller
        Parameters:
        scopeName - The name of the scope for which to list streams in.
        tag - The Stream tag.
        Returns:
        An AsyncIterator which can be used to iterate over all Streams in the scope.
      • deleteScope

        public java.util.concurrent.CompletableFuture<java.lang.Boolean> deleteScope​(java.lang.String scopeName)
        Description copied from interface: Controller
        API to delete a scope. Note that a scope can only be deleted in the case is it empty. If the scope contains at least one stream, then the delete request will fail.
        Specified by:
        deleteScope in interface Controller
        Parameters:
        scopeName - Scope name.
        Returns:
        A future which will throw if the operation fails, otherwise returning a boolean to indicate that the scope was removed because it existed.
      • createStream

        public java.util.concurrent.CompletableFuture<java.lang.Boolean> createStream​(java.lang.String scope,
                                                                                      java.lang.String streamName,
                                                                                      StreamConfiguration streamConfig)
        Description copied from interface: Controller
        API to create a stream. The future completes with true in the case the stream did not exist when the controller executed the operation. In the case of a re-attempt to create the same stream, the future completes with false to indicate that the stream existed when the controller executed the operation.
        Specified by:
        createStream in interface Controller
        Parameters:
        scope - Scope
        streamName - Stream name
        streamConfig - Stream configuration
        Returns:
        A future which will throw if the operation fails, otherwise returning a boolean to indicate that the stream was added because it did not already exist.
      • checkStreamExists

        public java.util.concurrent.CompletableFuture<java.lang.Boolean> checkStreamExists​(java.lang.String scopeName,
                                                                                           java.lang.String streamName)
        Description copied from interface: Controller
        Check if stream exists.
        Specified by:
        checkStreamExists in interface Controller
        Parameters:
        scopeName - name of scope.
        streamName - name of stream.
        Returns:
        CompletableFuture which when completed will indicate if stream exists or not.
      • getStreamConfiguration

        public java.util.concurrent.CompletableFuture<StreamConfiguration> getStreamConfiguration​(java.lang.String scopeName,
                                                                                                  java.lang.String streamName)
        Description copied from interface: Controller
        Fetch the current Stream Configuration. This includes the ScalingPolicy, RetentionPolicy and tags for the given stream.
        Specified by:
        getStreamConfiguration in interface Controller
        Parameters:
        scopeName - name of scope.
        streamName - name of stream.
        Returns:
        CompletableFuture which returns the current stream configuration.
      • updateStream

        public java.util.concurrent.CompletableFuture<java.lang.Boolean> updateStream​(java.lang.String scope,
                                                                                      java.lang.String streamName,
                                                                                      StreamConfiguration streamConfig)
        Description copied from interface: Controller
        API to update the configuration of a stream.
        Specified by:
        updateStream in interface Controller
        Parameters:
        scope - Scope
        streamName - Stream name
        streamConfig - Stream configuration to updated
        Returns:
        A future which will throw if the operation fails, otherwise returning a boolean to indicate that the stream was updated because the config is now different from before.
      • listSubscribers

        public java.util.concurrent.CompletableFuture<java.util.List<java.lang.String>> listSubscribers​(java.lang.String scope,
                                                                                                        java.lang.String streamName)
        Description copied from interface: Controller
        Get list of Subscribers for the Stream.
        Specified by:
        listSubscribers in interface Controller
        Parameters:
        scope - Scope name
        streamName - Stream name
        Returns:
        List of StreamSubscribers.
      • updateSubscriberStreamCut

        public java.util.concurrent.CompletableFuture<java.lang.Boolean> updateSubscriberStreamCut​(java.lang.String scope,
                                                                                                   java.lang.String streamName,
                                                                                                   java.lang.String subscriber,
                                                                                                   java.util.UUID readerGroupId,
                                                                                                   long generation,
                                                                                                   StreamCut streamCut)
        Description copied from interface: Controller
        API to update the truncation StreamCut for a particular Subscriber on Controller. Used when Stream has Consumption Based Retention Policy configured.
        Specified by:
        updateSubscriberStreamCut in interface Controller
        Parameters:
        scope - Scope name
        streamName - Stream name
        subscriber - Name/Id that uniquely identifies a Stream Subscriber.
        readerGroupId - Reader Group Id.
        generation - subscriber generation number.
        streamCut - StreamCut at which Stream can be Truncated for a Consumption based retention policy
        Returns:
        A future which will throw if the operation fails, otherwise returning a boolean to indicate that the subscribers position was updated in Stream Metadata.
      • truncateStream

        public java.util.concurrent.CompletableFuture<java.lang.Boolean> truncateStream​(java.lang.String scope,
                                                                                        java.lang.String stream,
                                                                                        StreamCut streamCut)
        Description copied from interface: Controller
        API to Truncate stream. This api takes a stream cut point which corresponds to a cut in the stream segments which is consistent and covers the entire key range space.
        Specified by:
        truncateStream in interface Controller
        Parameters:
        scope - Scope
        stream - Stream
        streamCut - Stream cut to updated
        Returns:
        A future which will throw if the operation fails, otherwise returning a boolean to indicate that the stream was truncated at the supplied cut.
      • scaleStream

        public CancellableRequest<java.lang.Boolean> scaleStream​(Stream stream,
                                                                 java.util.List<java.lang.Long> sealedSegments,
                                                                 java.util.Map<java.lang.Double,​java.lang.Double> newKeyRanges,
                                                                 java.util.concurrent.ScheduledExecutorService executor)
        Description copied from interface: Controller
        API to merge or split stream segments. This call returns a future that completes when either the scale operation is completed on controller service (succeeded or failed) or the specified timeout elapses.
        Specified by:
        scaleStream in interface Controller
        Parameters:
        stream - Stream object.
        sealedSegments - List of segments to be sealed.
        newKeyRanges - Key ranges after scaling the stream.
        executor - executor to be used for busy waiting.
        Returns:
        A Cancellable request object which can be used to get the future for scale operation or cancel the scale operation.
      • startScale

        public java.util.concurrent.CompletableFuture<java.lang.Boolean> startScale​(Stream stream,
                                                                                    java.util.List<java.lang.Long> sealedSegments,
                                                                                    java.util.Map<java.lang.Double,​java.lang.Double> newKeyRanges)
        Description copied from interface: Controller
        API to request start of scale operation on controller. This method returns a future that will complete when controller service accepts the scale request.
        Specified by:
        startScale in interface Controller
        Parameters:
        stream - Stream object.
        sealedSegments - List of segments to be sealed.
        newKeyRanges - Key ranges after scaling the stream.
        Returns:
        A future which will throw if the operation fails, otherwise returning a boolean to indicate that the scaling was started or not.
      • checkScaleStatus

        public java.util.concurrent.CompletableFuture<java.lang.Boolean> checkScaleStatus​(Stream stream,
                                                                                          int scaleEpoch)
        Description copied from interface: Controller
        API to check the status of scale for a given epoch.
        Specified by:
        checkScaleStatus in interface Controller
        Parameters:
        stream - Stream object.
        scaleEpoch - stream's epoch for which the scale was started.
        Returns:
        True if scale completed, false otherwise.
      • sealStream

        public java.util.concurrent.CompletableFuture<java.lang.Boolean> sealStream​(java.lang.String scope,
                                                                                    java.lang.String streamName)
        Description copied from interface: Controller
        API to seal a stream.
        Specified by:
        sealStream in interface Controller
        Parameters:
        scope - Scope
        streamName - Stream name
        Returns:
        A future which will throw if the operation fails, otherwise returning a boolean to indicate that the stream was sealed because it was not previously.
      • deleteStream

        public java.util.concurrent.CompletableFuture<java.lang.Boolean> deleteStream​(java.lang.String scope,
                                                                                      java.lang.String streamName)
        Description copied from interface: Controller
        API to delete a stream. Only a sealed stream can be deleted.
        Specified by:
        deleteStream in interface Controller
        Parameters:
        scope - Scope name.
        streamName - Stream name.
        Returns:
        A future which will throw if the operation fails, otherwise returning a boolean to indicate that the stream was removed because it existed.
      • getSegmentsAtTime

        public java.util.concurrent.CompletableFuture<java.util.Map<Segment,​java.lang.Long>> getSegmentsAtTime​(Stream stream,
                                                                                                                     long timestamp)
        Description copied from interface: Controller
        Given a timestamp and a stream returns segments and offsets that were present at that time in the stream.
        Specified by:
        getSegmentsAtTime in interface Controller
        Parameters:
        stream - Name of the stream
        timestamp - Timestamp for getting segments
        Returns:
        A map of segments to the offset within them.
      • getSuccessors

        public java.util.concurrent.CompletableFuture<StreamSegmentsWithPredecessors> getSuccessors​(Segment segment)
        Description copied from interface: Controller
        Returns StreamSegmentsWithPredecessors containing each of the segments that are successors to the segment requested mapped to a list of their predecessors. In the event of a scale up the newly created segments contain a subset of the keyspace of the original segment and their only predecessor is the segment that was split. Example: If there are two segments A and B. A scaling event split A into two new segments C and D. The successors of A are C and D. So calling this method with A would return {C → A, D → A} In the event of a scale down there would be one segment the succeeds multiple. So it would contain the union of the keyspace of its predecessors. So calling with that segment would map to multiple segments. Example: If there are two segments A and B. A and B are merged into a segment C. The successor of A is C. so calling this method with A would return {C → {A, B}} If a segment has not been sealed, it may not have successors now even though it might in the future. The successors to a sealed segment are always known and returned. Example: If there is only one segment A and it is not sealed, and no scaling events have occurred calling this with a would return an empty map.
        Specified by:
        getSuccessors in interface Controller
        Parameters:
        segment - The segment whose successors should be looked up.
        Returns:
        A mapping from Successor to the list of all of the Successor's predecessors
      • getSuccessors

        public java.util.concurrent.CompletableFuture<StreamSegmentSuccessors> getSuccessors​(StreamCut from)
        Description copied from interface: Controller
        Returns all the segments that come after the provided cutpoint.
        Specified by:
        getSuccessors in interface Controller
        Parameters:
        from - The position from which to find the remaining bytes.
        Returns:
        The segments beyond a given cut position.
      • getSegments

        public java.util.concurrent.CompletableFuture<StreamSegmentSuccessors> getSegments​(StreamCut fromStreamCut,
                                                                                           StreamCut toStreamCut)
        Description copied from interface: Controller
        Returns all the segments from the fromStreamCut till toStreamCut.
        Specified by:
        getSegments in interface Controller
        Parameters:
        fromStreamCut - From stream cut.
        toStreamCut - To stream cut.
        Returns:
        list of segments.
      • getCurrentSegments

        public java.util.concurrent.CompletableFuture<StreamSegments> getCurrentSegments​(java.lang.String scope,
                                                                                         java.lang.String stream)
        Description copied from interface: Controller
        API to get list of current segments for the stream to write to.
        Specified by:
        getCurrentSegments in interface Controller
        Parameters:
        scope - Scope
        stream - Stream name
        Returns:
        Current stream segments.
      • getEpochSegments

        public java.util.concurrent.CompletableFuture<StreamSegments> getEpochSegments​(java.lang.String scope,
                                                                                       java.lang.String stream,
                                                                                       int epoch)
        Description copied from interface: Controller
        API to get list of segments for given epoch.
        Specified by:
        getEpochSegments in interface Controller
        Parameters:
        scope - Scope
        stream - Stream name
        epoch - Epoch number.
        Returns:
        Stream segments for a given Epoch.
      • getEndpointForSegment

        public java.util.concurrent.CompletableFuture<io.pravega.shared.protocol.netty.PravegaNodeUri> getEndpointForSegment​(java.lang.String qualifiedSegmentName)
        Description copied from interface: Controller
        Given a segment return the endpoint that currently is the owner of that segment.

        This is called when a reader or a writer needs to determine which host/server it needs to contact to read and write, respectively. The result of this function can be cached until the endpoint is unreachable or indicates it is no longer the owner.

        Specified by:
        getEndpointForSegment in interface Controller
        Parameters:
        qualifiedSegmentName - The name of the segment. Usually obtained from Segment.getScopedName().
        Returns:
        Pravega node URI.
      • isSegmentOpen

        public java.util.concurrent.CompletableFuture<java.lang.Boolean> isSegmentOpen​(Segment segment)
        Description copied from interface: Controller
        Checks to see if a segment exists and is not sealed.
        Specified by:
        isSegmentOpen in interface Controller
        Parameters:
        segment - The segment to verify.
        Returns:
        true if the segment exists and is open or false if it is not.
      • createTransaction

        public java.util.concurrent.CompletableFuture<TxnSegments> createTransaction​(Stream stream,
                                                                                     long lease)
        Description copied from interface: Controller
        API to create a new transaction. The transaction timeout is relative to the creation time.
        Specified by:
        createTransaction in interface Controller
        Parameters:
        stream - Stream name
        lease - Time for which transaction shall remain open with sending any heartbeat.
        Returns:
        Transaction id.
      • pingTransaction

        public java.util.concurrent.CompletableFuture<Transaction.PingStatus> pingTransaction​(Stream stream,
                                                                                              java.util.UUID txId,
                                                                                              long lease)
        Description copied from interface: Controller
        API to send transaction heartbeat and increase the transaction timeout by lease amount of milliseconds.
        Specified by:
        pingTransaction in interface Controller
        Parameters:
        stream - Stream name
        txId - Transaction id
        lease - Time for which transaction shall remain open with sending any heartbeat.
        Returns:
        Transaction.PingStatus or PingFailedException
      • commitTransaction

        public java.util.concurrent.CompletableFuture<java.lang.Void> commitTransaction​(Stream stream,
                                                                                        java.lang.String writerId,
                                                                                        java.lang.Long timestamp,
                                                                                        java.util.UUID txId)
        Description copied from interface: Controller
        Commits a transaction, atomically committing all events to the stream, subject to the ordering guarantees specified in EventStreamWriter. Will fail with TxnFailedException if the transaction has already been committed or aborted.
        Specified by:
        commitTransaction in interface Controller
        Parameters:
        stream - Stream name
        writerId - The writer that is committing the transaction.
        timestamp - The timestamp the writer provided for the commit (or null if they did not specify one).
        txId - Transaction id
        Returns:
        Void or TxnFailedException
      • abortTransaction

        public java.util.concurrent.CompletableFuture<java.lang.Void> abortTransaction​(Stream stream,
                                                                                       java.util.UUID txId)
        Description copied from interface: Controller
        Aborts a transaction. No events written to it may be read, and no further events may be written. Will fail with TxnFailedException if the transaction has already been committed or aborted.
        Specified by:
        abortTransaction in interface Controller
        Parameters:
        stream - Stream name
        txId - Transaction id
        Returns:
        Void or TxnFailedException
      • checkTransactionStatus

        public java.util.concurrent.CompletableFuture<Transaction.Status> checkTransactionStatus​(Stream stream,
                                                                                                 java.util.UUID txId)
        Description copied from interface: Controller
        Returns the status of the specified transaction.
        Specified by:
        checkTransactionStatus in interface Controller
        Parameters:
        stream - Stream name
        txId - Transaction id
        Returns:
        Transaction status.
      • noteTimestampFromWriter

        public java.util.concurrent.CompletableFuture<java.lang.Void> noteTimestampFromWriter​(java.lang.String writer,
                                                                                              Stream stream,
                                                                                              long timestamp,
                                                                                              WriterPosition lastWrittenPosition)
        Description copied from interface: Controller
        Notifies that the specified writer has noted the provided timestamp when it was at lastWrittenPosition. This is called by writers via EventStreamWriter.noteTime(long) or Transaction.commit(long). The controller should aggrigate this information and write it to the stream's marks segment so that it read by readers who will in turn ultimately surface this information through the EventStreamReader.getCurrentTimeWindow(Stream) API.
        Specified by:
        noteTimestampFromWriter in interface Controller
        Parameters:
        writer - The name of the writer. (User defined)
        stream - The stream the timestamp is associated with.
        timestamp - The new timestamp for the writer on the stream.
        lastWrittenPosition - The position the writer was at when it noted the time.
      • removeWriter

        public java.util.concurrent.CompletableFuture<java.lang.Void> removeWriter​(java.lang.String writerId,
                                                                                   Stream stream)
        Description copied from interface: Controller
        Notifies the controller that the specified writer is shutting down gracefully and no longer needs to be considered for calculating entries for the marks segment. This may not be called in the event that writer crashes.
        Specified by:
        removeWriter in interface Controller
        Parameters:
        writerId - The name of the writer. (User defined)
        stream - The stream the writer was on.
      • close

        public void close()
        Description copied from interface: Controller
        Closes controller client.
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface Controller
        See Also:
        AutoCloseable.close()
      • getOrRefreshDelegationTokenFor

        public java.util.concurrent.CompletableFuture<java.lang.String> getOrRefreshDelegationTokenFor​(java.lang.String scope,
                                                                                                       java.lang.String streamName,
                                                                                                       io.pravega.shared.security.auth.AccessOperation accessOperation)
        Description copied from interface: Controller
        Obtains a delegation token from the server.
        Specified by:
        getOrRefreshDelegationTokenFor in interface Controller
        Parameters:
        scope - Scope of the stream.
        streamName - Name of the stream.
        accessOperation - The requested permission.
        Returns:
        The delegation token for the given stream.
      • createKeyValueTable

        public java.util.concurrent.CompletableFuture<java.lang.Boolean> createKeyValueTable​(java.lang.String scope,
                                                                                             java.lang.String kvtName,
                                                                                             KeyValueTableConfiguration kvtConfig)
        Description copied from interface: Controller
        API to create a KeyValueTable. The future completes with true in the case the KeyValueTable did not exist when the controller executed the operation. In the case of a re-attempt to create the same KeyValueTable, the future completes with false to indicate that the KeyValueTable existed when the controller executed the operation.
        Specified by:
        createKeyValueTable in interface Controller
        Parameters:
        scope - Scope
        kvtName - KeyValueTable name
        kvtConfig - The KeyValueTableConfiguration to create with.
        Returns:
        A future which will throw if the operation fails, otherwise returning a boolean to indicate that the stream was added because it did not already exist.
      • listKeyValueTables

        public io.pravega.common.util.AsyncIterator<KeyValueTableInfo> listKeyValueTables​(java.lang.String scopeName)
        Description copied from interface: Controller
        Gets an AsyncIterator on KeyValueTables in scope.
        Specified by:
        listKeyValueTables in interface Controller
        Parameters:
        scopeName - The name of the scope for which to list KeyValueTables in.
        Returns:
        An AsyncIterator which can be used to iterate over all KeyValueTables in the scope.
      • getKeyValueTableConfiguration

        public java.util.concurrent.CompletableFuture<KeyValueTableConfiguration> getKeyValueTableConfiguration​(java.lang.String scope,
                                                                                                                java.lang.String kvtName)
        Description copied from interface: Controller
        Specified by:
        getKeyValueTableConfiguration in interface Controller
        Parameters:
        scope - Scope
        kvtName - KeyValueTable name
        Returns:
        A future which will throw if the operation fails, otherwise returning the KeyValueTableConfiguration of the corresponding KeyValueTable name.
      • deleteKeyValueTable

        public java.util.concurrent.CompletableFuture<java.lang.Boolean> deleteKeyValueTable​(java.lang.String scope,
                                                                                             java.lang.String kvtName)
        Description copied from interface: Controller
        API to delete a KeyValueTable. Only a sealed KeyValueTable can be deleted.
        Specified by:
        deleteKeyValueTable in interface Controller
        Parameters:
        scope - Scope name.
        kvtName - KeyValueTable name.
        Returns:
        A future which will throw if the operation fails, otherwise returning a boolean to indicate that the KeyValueTable was removed because it existed.
      • getCurrentSegmentsForKeyValueTable

        public java.util.concurrent.CompletableFuture<KeyValueTableSegments> getCurrentSegmentsForKeyValueTable​(java.lang.String scope,
                                                                                                                java.lang.String kvtName)
        Description copied from interface: Controller
        API to get list of current segments for the KeyValueTable to write to.
        Specified by:
        getCurrentSegmentsForKeyValueTable in interface Controller
        Parameters:
        scope - Scope
        kvtName - KeyValueTable name
        Returns:
        Current KeyValueTable segments.
      • createReaderGroup

        public java.util.concurrent.CompletableFuture<ReaderGroupConfig> createReaderGroup​(java.lang.String scope,
                                                                                           java.lang.String rgName,
                                                                                           ReaderGroupConfig rgConfig)
        Description copied from interface: Controller
        API create a ReaderGroup.
        Specified by:
        createReaderGroup in interface Controller
        Parameters:
        scope - Scope name for Reader Group.
        rgName - Stream name.
        rgConfig - ReaderGroup configuration.
        Returns:
        A future which will throw if the operation fails, otherwise returning a boolean to indicate that the subscriber was updated in Stream Metadata.
      • updateReaderGroup

        public java.util.concurrent.CompletableFuture<java.lang.Long> updateReaderGroup​(java.lang.String scope,
                                                                                        java.lang.String rgName,
                                                                                        ReaderGroupConfig rgConfig)
        Description copied from interface: Controller
        API to update a ReaderGroup config.
        Specified by:
        updateReaderGroup in interface Controller
        Parameters:
        scope - Scope name for Reader Group.
        rgName - Stream name.
        rgConfig - ReaderGroup configuration.
        Returns:
        A future which will throw if the operation fails, otherwise the subscriber was updated in Stream Metadata and a long indicating the updated config generation is returned.
      • getReaderGroupConfig

        public java.util.concurrent.CompletableFuture<ReaderGroupConfig> getReaderGroupConfig​(java.lang.String scope,
                                                                                              java.lang.String rgName)
        Description copied from interface: Controller
        API to get Reader Group Configuration.
        Specified by:
        getReaderGroupConfig in interface Controller
        Parameters:
        scope - Scope name for Reader Group.
        rgName - Stream name.
        Returns:
        A future which will throw if the operation fails, otherwise returns configuration of the Reader Group.
      • deleteReaderGroup

        public java.util.concurrent.CompletableFuture<java.lang.Boolean> deleteReaderGroup​(java.lang.String scope,
                                                                                           java.lang.String rgName,
                                                                                           java.util.UUID readerGroupId)
        Description copied from interface: Controller
        API to delete a Reader Group.
        Specified by:
        deleteReaderGroup in interface Controller
        Parameters:
        scope - Scope name for Reader Group.
        rgName - Reader Group name.
        readerGroupId - Unique Id for this readerGroup.
        Returns:
        A future which will throw if the operation fails, otherwise returns configuration of the Reader Group.