Class SandboxNotificationPruneRepository
SandboxNotificationPruneService-
Constructor Summary
ConstructorsConstructorDescriptionSandboxNotificationPruneRepository(SandboxNotificationPruneProperties sandboxPruneNotificationProperties, org.springframework.transaction.support.TransactionTemplate transactionTemplate) -
Method Summary
Modifier and TypeMethodDescriptionprotected jakarta.persistence.criteria.PredicatebuildAckedFalseFilter(jakarta.persistence.criteria.Root<com.broadleafcommerce.data.tracking.jpa.filtering.domain.JpaNotificationState> root, jakarta.persistence.criteria.CriteriaBuilder cb) protected jakarta.persistence.criteria.PredicatebuildChangeTimestampNullFilter(jakarta.persistence.criteria.Root<com.broadleafcommerce.data.tracking.jpa.filtering.domain.JpaNotificationState> root, jakarta.persistence.criteria.CriteriaBuilder cb) protected jakarta.persistence.criteria.PredicatebuildIdGreaterThanBatchLowerBoundFilter(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.PredicatebuildIdLessThanOrEqualToBatchUpperBoundFilter(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.PredicatebuildIdLessThanPruneThresholdFilter(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.PredicatebuildPruneableCandidateFetchingFilters(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.PredicatebuildStoppedFalseFilter(jakarta.persistence.criteria.Root<com.broadleafcommerce.data.tracking.jpa.filtering.domain.JpaNotificationState> root, jakarta.persistence.criteria.CriteriaBuilder cb) protected intdeleteWithinBatchBounds(String batchLowerBoundId, String batchUpperBoundId, String pruneThresholdUlid) protected StringfindDeleteBatchUpperBoundId(String batchLowerBoundId, String pruneThresholdUlid) protected Stringprotected jakarta.persistence.EntityManagerprotected SandboxNotificationPrunePropertiesprotected org.springframework.transaction.support.TransactionTemplateprotected voidvoidNotificationAwareDomainMapperMembereagerly creates a lot of 'dormant'NotificationStatesthat 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()NotificationAwareDomainMapperMembereagerly creates a lot of 'dormant'NotificationStatesthat are only initialized for send when a transition operation is requested for their parent entities. This eager creation makes subsequent updates to initialize theNotificationStateefficient, but it also means that if a particular transition is never engaged for a particular entity, theNotificationStatewill remain in the datastore forever and lead to buildup. For example, the state forRejectionProducer.TYPEis eagerly created but if a 'reject' is never engaged for a summary, then thatNotificationStatewill 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.TYPEnotification state, a subsequent reject transition request for the parent summary would still work because the transition flow would newly create theRejectionProducer.TYPEon-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()
-