Interface LifecycleService
-
- All Known Implementing Classes:
DefaultLifecycleService
public interface LifecycleServiceA service for basic management of the connector lifecycle processes.
-
-
Field Summary
Fields Modifier and Type Field Description static StringROLLBACK_CODEResponse code signifying a rollback operation has occurredstatic StringUNKNOWN_ERROR_CODEResponse code signifying an unknown, unrecoverable error has occurred
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description static LifecycleServicegetInstance(Session session, ConnectorStatus statusAfterRollback)Returns a new instance of the default service implementation.voidupdateStatus(ConnectorStatus status)Updates the connector status to a provided one.voidvalidateRequiredPrivileges()Validates whether the application instance has been granted all privileges necessary to run the lifecycle processes.voidvalidateStatus(ConnectorStatus... statuses)Validates if the current connector status contains provided ones.ConnectorResponsewithRollbackHandling(Supplier<ConnectorResponse> action)Executes the specified action with handling of rollback and unexpected errors.
-
-
-
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
ROLLBACKcode 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_ERRORcode is returned by this method.- Parameters:
action- an action to execute- Returns:
- a response with the code
OKif the execution was successful, a response with the codeROLLBACKif the action performed a rollback operation, or a response with anUNKNOWN_ERRORcode 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 objectstatusAfterRollback- Connector status set if a rollback operation has occurred- Returns:
- a new service instance
-
-