Interface LifecycleService

  • All Known Implementing Classes:
    DefaultLifecycleService

    public interface LifecycleService
    A service for basic management of the connector lifecycle processes.
    • Field Detail

      • ROLLBACK_CODE

        static final String ROLLBACK_CODE
        Response code signifying a rollback operation has occurred
        See Also:
        Constant Field Values
      • UNKNOWN_ERROR_CODE

        static final String UNKNOWN_ERROR_CODE
        Response code signifying an unknown, unrecoverable error has occurred
        See Also:
        Constant Field Values
    • Method Detail

      • validateStatus

        void validateStatus​(ConnectorStatus... statuses)
        Validates if the current connector status contains provided ones.
        Parameters:
        statuses - expected connector statuses
        Throws:
        InvalidConnectorStatusException - when the current connector status is different from the expected ones
      • updateStatus

        void updateStatus​(ConnectorStatus status)
        Updates the connector status to a provided one.
        Parameters:
        status - new connector status
      • validateRequiredPrivileges

        void validateRequiredPrivileges()
        Validates whether the application instance has been granted all privileges necessary to run the lifecycle processes.
        Throws:
        RequiredPrivilegesMissingException - if any required privilege has not been granted
      • withRollbackHandling

        ConnectorResponse withRollbackHandling​(Supplier<ConnectorResponse> action)
        Executes the specified action with handling of rollback and unexpected errors.

        If a ROLLBACK code was returned by the action - the connector status is updated accordingly and the action response is returned by this method.

        If an unexpected exception has been thrown during the action execution - a response with an UNKNOWN_ERROR code is returned by this method.

        Parameters:
        action - an action to execute
        Returns:
        a response with the code OK if the execution was successful, a response with the code ROLLBACK if the action performed a rollback operation, or a response with an UNKNOWN_ERROR code and an error message
      • getInstance

        static LifecycleService getInstance​(Session session,
                                            ConnectorStatus statusAfterRollback)
        Returns a new instance of the default service implementation.

        Default implementation of the service uses a default implementation of ConnectorStatusService.

        Parameters:
        session - Snowpark session object
        statusAfterRollback - Connector status set if a rollback operation has occurred
        Returns:
        a new service instance