Class TransactionResourceManager

    • Constructor Detail

      • TransactionResourceManager

        public TransactionResourceManager​(DirectDataOperator direct,
                                          java.util.Map<java.lang.String,​java.lang.Object> cfg)
    • Method Detail

      • setTransactionTimeoutMs

        public void setTransactionTimeoutMs​(long timeoutMs)
      • runObservations

        public void runObservations​(java.lang.String name,
                                    BiConsumer<StreamElement,​Pair<java.lang.Long,​java.lang.Object>> updateConsumer,
                                    CommitLogObserver requestObserver)
        Observe all transactional families with given observer.
        Specified by:
        runObservations in interface ServerTransactionManager
        Parameters:
        name - name of the observer (will be appended with name of the family)
        requestObserver - the observer (need not be synchronized)
        updateConsumer - consumer of updates to the view of transaction states
      • begin

        public java.util.concurrent.CompletableFuture<Response> begin​(java.lang.String transactionId,
                                                                      java.util.List<KeyAttribute> attributes)
        Initialize new transaction. If the transaction already existed prior to this call, the state is updated accordingly.
        Specified by:
        begin in interface ClientTransactionManager
        Parameters:
        transactionId - ID of transaction
        attributes - attributes affected by this transaction (both input and output)
        Returns:
        asynchronous response
      • updateTransaction

        public java.util.concurrent.CompletableFuture<Response> updateTransaction​(java.lang.String transactionId,
                                                                                  java.util.List<KeyAttribute> newAttributes)
        Update the transaction with additional attributes related to the transaction.
        Specified by:
        updateTransaction in interface ClientTransactionManager
        Parameters:
        transactionId - ID of transaction
        newAttributes - attributes to be added to the transaction
        Returns:
        asynchronous response
      • commit

        public java.util.concurrent.CompletableFuture<Response> commit​(java.lang.String transactionId,
                                                                       java.util.Collection<StreamElement> outputs)
        Description copied from interface: ClientTransactionManager
        Commit the transaction with given output KeyAttributes being written.
        Specified by:
        commit in interface ClientTransactionManager
        Parameters:
        transactionId - ID of the transaction
        outputs - elements to be written to the output
        Returns:
        asynchronous response
      • rollback

        public java.util.concurrent.CompletableFuture<Response> rollback​(java.lang.String transactionId)
        Description copied from interface: ClientTransactionManager
        Rollback transaction with given ID.
        Specified by:
        rollback in interface ClientTransactionManager
        Parameters:
        transactionId - ID of the transaction to rollback.
        Returns:
        asynchronous response
      • release

        public void release​(java.lang.String transactionId)
        Description copied from interface: ClientTransactionManager
        Release resources associated with given transaction.
        Specified by:
        release in interface ClientTransactionManager
        Parameters:
        transactionId - ID of the transaction
      • getCurrentState

        public State getCurrentState​(java.lang.String transactionId)
        Retrieve current state of the transaction.
        Specified by:
        getCurrentState in interface ServerTransactionManager
        Parameters:
        transactionId - ID of the transaction
        Returns:
        the State associated with the transaction on server
      • ensureTransactionOpen

        public void ensureTransactionOpen​(java.lang.String transactionId,
                                          State state)
        Description copied from interface: ServerTransactionManager
        Ensure that the given transaction ID is initialized.
        Specified by:
        ensureTransactionOpen in interface ServerTransactionManager
        Parameters:
        transactionId - ID of the transaction
        state - the state that the transaction is supposed to have
      • writeResponseAndUpdateState

        public void writeResponseAndUpdateState​(java.lang.String transactionId,
                                                State updateState,
                                                java.lang.String responseId,
                                                Response response,
                                                CommitCallback callback)
        Description copied from interface: ServerTransactionManager
        Atomically write response and update state of a transaction
        Specified by:
        writeResponseAndUpdateState in interface ServerTransactionManager
        Parameters:
        transactionId - ID of transaction
        updateState - the state to update the transaction to
        responseId - ID of response
        response - the response
        callback - callback for commit after write