Class RecoveryService
- java.lang.Object
-
- org.bonitasoft.engine.tenant.restart.RecoveryService
-
@Component public class RecoveryService extends java.lang.ObjectResponsible to recover from incidents like database or network outage. It scans the database (on-demand) and reschedules the elements to recover. It will recover these elements using multiple transaction using a batch size configured by the property `bonita.tenant.work.batch_restart_size`
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringDURATION_OF_RECOVERY_TASKstatic java.lang.StringNUMBER_OF_ELEMENTS_RECOVERED_LAST_RECOVERYstatic java.lang.StringNUMBER_OF_ELEMENTS_RECOVERED_TOTALstatic java.lang.StringNUMBER_OF_RECOVERY
-
Constructor Summary
Constructors Constructor Description RecoveryService(FlowNodeInstanceService flowNodeInstanceService, ProcessInstanceService processInstanceService, UserTransactionService userTransactionService, FlowNodesRecover flowNodesRecover, ProcessesRecover processesRecover, SessionAccessor sessionAccessor, org.springframework.beans.factory.ObjectFactory<org.bonitasoft.engine.tenant.restart.RecoveryMonitor> recoveryMonitorProvider, io.micrometer.core.instrument.MeterRegistry meterRegistry)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidexecuteInBatch(org.bonitasoft.engine.tenant.restart.RecoveryMonitor recoveryMonitor, java.util.List<ElementToRecover> elements, org.bonitasoft.engine.tenant.restart.RecoveryService.BatchExecution execution)java.util.List<ElementToRecover>getAllElementsToRecover(java.time.Duration considerElementsOlderThan)Retrieve elements ( ProcessInstance and Flow Nodes ) that needs to be recovered and that are older than the given duration.protected voidinitMetrics()voidrecover(java.util.List<ElementToRecover> elementsToRecover)Trigger works to execute elements ( ProcessInstance and Flow Nodes ) that needs to be recoveredvoidrecoverAllElements()Recover all elements considered as "stuck".voidsetBatchRestartSize(int batchRestartSize)voidsetConsiderElementsOlderThan(java.lang.String considerElementsOlderThan)voidsetReadBatchSize(int readBatchSize)voidsetTenantId(long tenantId)
-
-
-
Field Detail
-
DURATION_OF_RECOVERY_TASK
public static final java.lang.String DURATION_OF_RECOVERY_TASK
- See Also:
- Constant Field Values
-
NUMBER_OF_RECOVERY
public static final java.lang.String NUMBER_OF_RECOVERY
- See Also:
- Constant Field Values
-
NUMBER_OF_ELEMENTS_RECOVERED_LAST_RECOVERY
public static final java.lang.String NUMBER_OF_ELEMENTS_RECOVERED_LAST_RECOVERY
- See Also:
- Constant Field Values
-
NUMBER_OF_ELEMENTS_RECOVERED_TOTAL
public static final java.lang.String NUMBER_OF_ELEMENTS_RECOVERED_TOTAL
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
RecoveryService
public RecoveryService(FlowNodeInstanceService flowNodeInstanceService, ProcessInstanceService processInstanceService, UserTransactionService userTransactionService, FlowNodesRecover flowNodesRecover, ProcessesRecover processesRecover, SessionAccessor sessionAccessor, org.springframework.beans.factory.ObjectFactory<org.bonitasoft.engine.tenant.restart.RecoveryMonitor> recoveryMonitorProvider, io.micrometer.core.instrument.MeterRegistry meterRegistry)
-
-
Method Detail
-
initMetrics
@PostConstruct protected void initMetrics()
-
setReadBatchSize
@Value("${bonita.tenant.recover.read_batch_size:5000}") public void setReadBatchSize(int readBatchSize)
-
setConsiderElementsOlderThan
@Value("${bonita.tenant.recover.consider_elements_older_than:PT1H}") public void setConsiderElementsOlderThan(java.lang.String considerElementsOlderThan)
-
setBatchRestartSize
@Value("${bonita.tenant.work.batch_restart_size:1000}") public void setBatchRestartSize(int batchRestartSize)
-
setTenantId
@Value("${tenantId}") public void setTenantId(long tenantId)
-
getAllElementsToRecover
public java.util.List<ElementToRecover> getAllElementsToRecover(java.time.Duration considerElementsOlderThan)
Retrieve elements ( ProcessInstance and Flow Nodes ) that needs to be recovered and that are older than the given duration.- Parameters:
considerElementsOlderThan- consider elements older than that duration- Returns:
- elements to be recovered
-
recover
public void recover(java.util.List<ElementToRecover> elementsToRecover)
Trigger works to execute elements ( ProcessInstance and Flow Nodes ) that needs to be recovered- Parameters:
elementsToRecover- elements needs to be recovered
-
executeInBatch
protected void executeInBatch(org.bonitasoft.engine.tenant.restart.RecoveryMonitor recoveryMonitor, java.util.List<ElementToRecover> elements, org.bonitasoft.engine.tenant.restart.RecoveryService.BatchExecution execution)
-
recoverAllElements
public void recoverAllElements()
Recover all elements considered as "stuck". Only recover elements older than a duration configured withsetConsiderElementsOlderThan(String).
-
-