Class SandboxNotificationPruneRepository
SandboxNotificationPruneService
-
Constructor Summary
ConstructorsConstructorDescriptionSandboxNotificationPruneRepository
(SandboxNotificationPruneProperties sandboxPruneNotificationProperties, org.springframework.transaction.support.TransactionTemplate transactionTemplate) -
Method Summary
Modifier and TypeMethodDescriptionprotected jakarta.persistence.criteria.Predicate
buildAckedFalseFilter
(jakarta.persistence.criteria.Root<com.broadleafcommerce.data.tracking.jpa.filtering.domain.JpaNotificationState> root, jakarta.persistence.criteria.CriteriaBuilder cb) protected jakarta.persistence.criteria.Predicate
buildChangeTimestampNullFilter
(jakarta.persistence.criteria.Root<com.broadleafcommerce.data.tracking.jpa.filtering.domain.JpaNotificationState> root, jakarta.persistence.criteria.CriteriaBuilder cb) protected jakarta.persistence.criteria.Predicate
buildIdGreaterThanBatchLowerBoundFilter
(jakarta.persistence.criteria.Root<com.broadleafcommerce.data.tracking.jpa.filtering.domain.JpaNotificationState> root, jakarta.persistence.criteria.CriteriaBuilder cb, Map<String, Object> params, String batchLowerBoundIdParameterName, String batchLowerBoundId) protected jakarta.persistence.criteria.Predicate
buildIdLessThanOrEqualToBatchUpperBoundFilter
(jakarta.persistence.criteria.Root<com.broadleafcommerce.data.tracking.jpa.filtering.domain.JpaNotificationState> root, jakarta.persistence.criteria.CriteriaBuilder cb, Map<String, Object> params, String batchUpperBoundIdParameterName, String batchUpperBoundId) protected jakarta.persistence.criteria.Predicate
buildIdLessThanPruneThresholdFilter
(jakarta.persistence.criteria.Root<com.broadleafcommerce.data.tracking.jpa.filtering.domain.JpaNotificationState> root, jakarta.persistence.criteria.CriteriaBuilder cb, Map<String, Object> params, String pruneThresholdParameterName, String pruneThresholdUlid) protected jakarta.persistence.criteria.Predicate
buildPruneableCandidateFetchingFilters
(jakarta.persistence.criteria.CriteriaBuilder cb, jakarta.persistence.criteria.Root<com.broadleafcommerce.data.tracking.jpa.filtering.domain.JpaNotificationState> root, Map<String, Object> queryParams, String pruneThresholdUlid) protected jakarta.persistence.criteria.Predicate
buildStoppedFalseFilter
(jakarta.persistence.criteria.Root<com.broadleafcommerce.data.tracking.jpa.filtering.domain.JpaNotificationState> root, jakarta.persistence.criteria.CriteriaBuilder cb) protected int
deleteWithinBatchBounds
(String batchLowerBoundId, String batchUpperBoundId, String pruneThresholdUlid) protected String
findDeleteBatchUpperBoundId
(String batchLowerBoundId, String pruneThresholdUlid) protected String
protected jakarta.persistence.EntityManager
protected SandboxNotificationPruneProperties
protected org.springframework.transaction.support.TransactionTemplate
protected void
void
NotificationAwareDomainMapperMember
eagerly creates a lot of 'dormant'NotificationStates
that are only initialized for send when a transition operation is requested for their parent entities.
-
Constructor Details
-
SandboxNotificationPruneRepository
public SandboxNotificationPruneRepository(SandboxNotificationPruneProperties sandboxPruneNotificationProperties, org.springframework.transaction.support.TransactionTemplate transactionTemplate)
-
-
Method Details
-
pruneDormantNotificationStates
public void pruneDormantNotificationStates()NotificationAwareDomainMapperMember
eagerly creates a lot of 'dormant'NotificationStates
that are only initialized for send when a transition operation is requested for their parent entities. This eager creation makes subsequent updates to initialize theNotificationState
efficient, but it also means that if a particular transition is never engaged for a particular entity, theNotificationState
will remain in the datastore forever and lead to buildup. For example, the state forRejectionProducer.TYPE
is eagerly created but if a 'reject' is never engaged for a summary, then thatNotificationState
will remain 'dormant'.These 'dormant' states will not be pruned by
StandaloneCleanupRepository.pruneRestingNotificationStates(Duration)
, because the dormant states haveNotificationState.isStopped()
set to false andNotificationState.getChangeTimestamp()
set to null, and are therefore never included its standard purge criteria.Thus, we need this specialized prune logic that will find and remove these states, which is what this method does. The
SandboxNotificationPruneProperties.getOutdatedDataAgeCutoff()
should inform the cutoff. Typically, this cutoff is more aggressive thanPruneRestingNotificationStatesConfigurationProperties.getOutdatedDataAgeCutoff()
to minimize the buildup of bloat.Note that we can safely purge notification states here without worry because each of the transition flows are resilient and will create the notification state they need if it does not already exist. For example, even if we purge a
RejectionProducer.TYPE
notification state, a subsequent reject transition request for the parent summary would still work because the transition flow would newly create theRejectionProducer.TYPE
on-demand. -
generateUlidForPruneThresholdTimestamp
- Returns:
- a ULID whose timestamp encoding matches the prune threshold defined in
SandboxNotificationPruneProperties.getOutdatedDataAgeCutoff()
. This ULID can be compared against existing IDs in the datastore to serve as the boundary marker on what is/isn't pruned.
-
findDeleteBatchUpperBoundId
-
buildPruneableCandidateFetchingFilters
protected jakarta.persistence.criteria.Predicate buildPruneableCandidateFetchingFilters(jakarta.persistence.criteria.CriteriaBuilder cb, jakarta.persistence.criteria.Root<com.broadleafcommerce.data.tracking.jpa.filtering.domain.JpaNotificationState> root, Map<String, Object> queryParams, String pruneThresholdUlid) -
buildIdLessThanPruneThresholdFilter
protected jakarta.persistence.criteria.Predicate buildIdLessThanPruneThresholdFilter(jakarta.persistence.criteria.Root<com.broadleafcommerce.data.tracking.jpa.filtering.domain.JpaNotificationState> root, jakarta.persistence.criteria.CriteriaBuilder cb, Map<String, Object> params, String pruneThresholdParameterName, String pruneThresholdUlid) -
buildAckedFalseFilter
protected jakarta.persistence.criteria.Predicate buildAckedFalseFilter(jakarta.persistence.criteria.Root<com.broadleafcommerce.data.tracking.jpa.filtering.domain.JpaNotificationState> root, jakarta.persistence.criteria.CriteriaBuilder cb) -
buildStoppedFalseFilter
protected jakarta.persistence.criteria.Predicate buildStoppedFalseFilter(jakarta.persistence.criteria.Root<com.broadleafcommerce.data.tracking.jpa.filtering.domain.JpaNotificationState> root, jakarta.persistence.criteria.CriteriaBuilder cb) -
buildChangeTimestampNullFilter
protected jakarta.persistence.criteria.Predicate buildChangeTimestampNullFilter(jakarta.persistence.criteria.Root<com.broadleafcommerce.data.tracking.jpa.filtering.domain.JpaNotificationState> root, jakarta.persistence.criteria.CriteriaBuilder cb) -
buildIdGreaterThanBatchLowerBoundFilter
protected jakarta.persistence.criteria.Predicate buildIdGreaterThanBatchLowerBoundFilter(jakarta.persistence.criteria.Root<com.broadleafcommerce.data.tracking.jpa.filtering.domain.JpaNotificationState> root, jakarta.persistence.criteria.CriteriaBuilder cb, Map<String, Object> params, String batchLowerBoundIdParameterName, String batchLowerBoundId) -
deleteWithinBatchBounds
-
buildIdLessThanOrEqualToBatchUpperBoundFilter
protected jakarta.persistence.criteria.Predicate buildIdLessThanOrEqualToBatchUpperBoundFilter(jakarta.persistence.criteria.Root<com.broadleafcommerce.data.tracking.jpa.filtering.domain.JpaNotificationState> root, jakarta.persistence.criteria.CriteriaBuilder cb, Map<String, Object> params, String batchUpperBoundIdParameterName, String batchUpperBoundId) -
pauseBetweenBatches
protected void pauseBetweenBatches() -
getSandboxPruneNotificationProperties
-
getTransactionTemplate
protected org.springframework.transaction.support.TransactionTemplate getTransactionTemplate() -
getEntityManager
protected jakarta.persistence.EntityManager getEntityManager()
-