Class RuleStatisticsServiceImpl
java.lang.Object
com.codebarrel.automation.api.service.statistics.RuleStatisticsServiceImpl
- All Implemented Interfaces:
RuleStatisticsService
-
Field Summary
Fields inherited from interface com.codebarrel.automation.api.service.statistics.RuleStatisticsService
MAX_HISTORY_HOURS -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidCalled regularly to keep this table small.longgetActiveTenantCount(Environment env, Instant sinceTimeAgo) Returns count of tenants that executed a rule in the time period provided.getCurrentRuleExecutionStartTime(TenantContext context, long ruleId) Returns the current execution time prior the one with the provided audit log id.longgetExecutionTenantCount(TenantContext context, long millisAgo) Returns the number of times rules executed in timeframe specified on this tenant..intReturns the number of times rules executed in the current calendar month for a particular tenant.getLastRuleExecutionStates(TenantContext context, Set<Long> ruleIds) Retrieves the most recent rule execution states for the given rule ids.getPreviousRuleExecutionStartTime(TenantContext context, long ruleId) Returns the previous execution time prior the one with the provided audit log id.intgetQueuedItemCount(TenantContext context, long ruleId, long auditItemId) longgetQueuedItemCount(TenantContext context, Instant sinceTimeAgo) Get total queued items for tenant.getRuleStatistics(Environment environment, Instant sinceTimeAgo) Returns stats about rule executions since the time provided.longgetTotalExecutionDuration(TenantContext context, long millisAgo, long ruleId) Return the total duration this rule spent processing since the created OffsetTime.booleanhasAlreadyBegun(TenantContext context, AutomationEvent event, com.codebarrel.automation.api.config.RuleConfigBean rule) A check if the rule has already begun for this particular event? This will be accurate within the lastRuleStatisticsService.MAX_HISTORY_HOURShours.booleanisPreviousExecutionSuccessful(TenantContext context, long ruleId) Checks if the execution just prior to the one with the provided audit log id was successful.voidupdateStaleStatisticsEntries(TenantContext context, Set<Long> staleAuditItemIds) Updates the stale statistics entries for the given audit item ids.
-
Constructor Details
-
RuleStatisticsServiceImpl
-
-
Method Details
-
expireOldEntries
Description copied from interface:RuleStatisticsServiceCalled regularly to keep this table small.- Specified by:
expireOldEntriesin interfaceRuleStatisticsService- Parameters:
env- the db environment
-
getExecutionTenantCount
Description copied from interface:RuleStatisticsServiceReturns the number of times rules executed in timeframe specified on this tenant..- Specified by:
getExecutionTenantCountin interfaceRuleStatisticsService- Parameters:
context- the tenant database contextmillisAgo- how long ago to look for executions in milliseconds- Returns:
- total count of rule executions
-
getExecutionTenantCountCurrentMonth
Description copied from interface:RuleStatisticsServiceReturns the number of times rules executed in the current calendar month for a particular tenant.- Specified by:
getExecutionTenantCountCurrentMonthin interfaceRuleStatisticsService- Parameters:
context- the tenant database context- Returns:
- total count of rule executions
-
getTotalExecutionDuration
Description copied from interface:RuleStatisticsServiceReturn the total duration this rule spent processing since the created OffsetTime.- Specified by:
getTotalExecutionDurationin interfaceRuleStatisticsService- Parameters:
context- the tenant database contextmillisAgo- how long ago to look for executions in millisecondsruleId- the id of the rule to check- Returns:
- total execution time in milli seconds since the created offset
-
getLastRuleExecutionStates
public Set<LastRuleExecutionState> getLastRuleExecutionStates(TenantContext context, Set<Long> ruleIds) Description copied from interface:RuleStatisticsServiceRetrieves the most recent rule execution states for the given rule ids. This can be used to figure out if a rule currently has an error.- Specified by:
getLastRuleExecutionStatesin interfaceRuleStatisticsService- Parameters:
context- the tenant database contextruleIds- The rule ids to lookup audit items for.- Returns:
- set of matching rule execution states.
-
getPreviousRuleExecutionStartTime
Description copied from interface:RuleStatisticsServiceReturns the previous execution time prior the one with the provided audit log id.- Specified by:
getPreviousRuleExecutionStartTimein interfaceRuleStatisticsService- Parameters:
context- the tenant database contextruleId- The rule id to lookup the start time for- Returns:
- the start time or empty if the rule didn't execute yet.
-
getCurrentRuleExecutionStartTime
Description copied from interface:RuleStatisticsServiceReturns the current execution time prior the one with the provided audit log id.- Specified by:
getCurrentRuleExecutionStartTimein interfaceRuleStatisticsService- Parameters:
context- the tenant database contextruleId- The rule id to lookup the start time for- Returns:
- the start time or empty if the rule didn't execute yet.
-
isPreviousExecutionSuccessful
Description copied from interface:RuleStatisticsServiceChecks if the execution just prior to the one with the provided audit log id was successful. Only returns false, if a previous execution was found that in an error state defined byState.isErrorState(String). If there was no prior execution this method returns true.- Specified by:
isPreviousExecutionSuccessfulin interfaceRuleStatisticsService- Parameters:
context- the tenant database contextruleId- The rule id to lookup the previous execution for
-
hasAlreadyBegun
public boolean hasAlreadyBegun(TenantContext context, AutomationEvent event, com.codebarrel.automation.api.config.RuleConfigBean rule) Description copied from interface:RuleStatisticsServiceA check if the rule has already begun for this particular event? This will be accurate within the lastRuleStatisticsService.MAX_HISTORY_HOURShours.- Specified by:
hasAlreadyBegunin interfaceRuleStatisticsService
-
getQueuedItemCount
- Specified by:
getQueuedItemCountin interfaceRuleStatisticsService
-
getRuleStatistics
Description copied from interface:RuleStatisticsServiceReturns stats about rule executions since the time provided.- Specified by:
getRuleStatisticsin interfaceRuleStatisticsService- Parameters:
sinceTimeAgo- duration for which to collect status- Returns:
- rule executions.
-
getQueuedItemCount
Description copied from interface:RuleStatisticsServiceGet total queued items for tenant.- Specified by:
getQueuedItemCountin interfaceRuleStatisticsService- Parameters:
context- the tenantsinceTimeAgo- period for which to look up queued items- Returns:
- count of items
-
getActiveTenantCount
Description copied from interface:RuleStatisticsServiceReturns count of tenants that executed a rule in the time period provided.- Specified by:
getActiveTenantCountin interfaceRuleStatisticsService- Parameters:
env- The tenant environment.sinceTimeAgo- period for which to look up active tenants (max 3 days).- Returns:
- count of active tenants.
-
updateStaleStatisticsEntries
Description copied from interface:RuleStatisticsServiceUpdates the stale statistics entries for the given audit item ids.- Specified by:
updateStaleStatisticsEntriesin interfaceRuleStatisticsService- Parameters:
context- the tenant database contextstaleAuditItemIds- the set of stale audit item ids
-