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)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
updateStatus(ConnectorStatus status)
Updates the connector status to a provided one.void
validateRequiredPrivileges()
Validates whether the application instance has been granted all privileges necessary to run the lifecycle processes.void
validateStatus(ConnectorStatus... statuses)
Validates if the current connector status contains provided ones.ConnectorResponse
withRollbackHandling(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)
-
-
Method Detail
-
validateStatus
public void validateStatus(ConnectorStatus... statuses)
Description copied from interface:LifecycleService
Validates if the current connector status contains provided ones.- Specified by:
validateStatus
in interfaceLifecycleService
- Parameters:
statuses
- expected connector statuses
-
updateStatus
public void updateStatus(ConnectorStatus status)
Description copied from interface:LifecycleService
Updates the connector status to a provided one.- Specified by:
updateStatus
in interfaceLifecycleService
- Parameters:
status
- new connector status
-
validateRequiredPrivileges
public void validateRequiredPrivileges()
Description copied from interface:LifecycleService
Validates whether the application instance has been granted all privileges necessary to run the lifecycle processes.- Specified by:
validateRequiredPrivileges
in interfaceLifecycleService
-
withRollbackHandling
public ConnectorResponse withRollbackHandling(Supplier<ConnectorResponse> action)
Description copied from interface:LifecycleService
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.- Specified by:
withRollbackHandling
in interfaceLifecycleService
- Parameters:
action
- an action to execute- Returns:
- a response with the code
OK
if the execution was successful, a response with the codeROLLBACK
if the action performed a rollback operation, or a response with anUNKNOWN_ERROR
code and an error message
-
-