Class DefaultLifecycleService
- java.lang.Object
-
- com.snowflake.connectors.application.lifecycle.DefaultLifecycleService
-
- All Implemented Interfaces:
LifecycleService
public class DefaultLifecycleService extends Object implements LifecycleService
Default implementation ofLifecycleService.
-
-
Field Summary
-
Fields inherited from interface com.snowflake.connectors.application.lifecycle.LifecycleService
ROLLBACK_CODE, UNKNOWN_ERROR_CODE
-
-
Constructor Summary
Constructors Constructor Description DefaultLifecycleService(PrivilegeTools privilegeTools, ConnectorStatusService statusService, ConnectorStatus statusAfterRollback)Creates a newDefaultLifecycleService.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description 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.
-
-
-
Constructor Detail
-
DefaultLifecycleService
public DefaultLifecycleService(PrivilegeTools privilegeTools, ConnectorStatusService statusService, ConnectorStatus statusAfterRollback)
Creates a newDefaultLifecycleService.- Parameters:
privilegeTools- privilege tools instancestatusService- connector status service instancestatusAfterRollback- connector status set after connector rollback
-
-
Method Detail
-
validateStatus
public void validateStatus(ConnectorStatus... statuses)
Description copied from interface:LifecycleServiceValidates if the current connector status contains provided ones.- Specified by:
validateStatusin interfaceLifecycleService- Parameters:
statuses- expected connector statuses
-
updateStatus
public void updateStatus(ConnectorStatus status)
Description copied from interface:LifecycleServiceUpdates the connector status to a provided one.- Specified by:
updateStatusin interfaceLifecycleService- Parameters:
status- new connector status
-
validateRequiredPrivileges
public void validateRequiredPrivileges()
Description copied from interface:LifecycleServiceValidates whether the application instance has been granted all privileges necessary to run the lifecycle processes.- Specified by:
validateRequiredPrivilegesin interfaceLifecycleService
-
withRollbackHandling
public ConnectorResponse withRollbackHandling(Supplier<ConnectorResponse> action)
Description copied from interface:LifecycleServiceExecutes 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.- Specified by:
withRollbackHandlingin interfaceLifecycleService- 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
-
-