Package org.openremote.manager.rules
Class RulesEngine<T extends org.openremote.model.rules.Ruleset>
java.lang.Object
org.openremote.manager.rules.RulesEngine<T>
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classIdentifies a set ofLocationAttributePredicates associated with a particularAssetstatic final classAllows rule deployments to track changes to theAttributeInfos in scope -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final org.openremote.model.rules.Alarmsprotected final AssetLocationPredicateProcessorprotected final org.openremote.model.rules.Assetsprotected final AssetStorageServiceprotected final ClientEventServiceprotected Stringprotected final Map<Long, RulesetDeployment> protected final org.jeasy.rules.core.AbstractRulesEngineprotected final ExecutorServiceprotected final RulesFactsprotected ScheduledFuture<?> protected final org.openremote.model.rules.HistoricDatapointsprotected final RulesEngineId<T> protected final Set<org.openremote.model.attribute.AttributeInfo> protected longprotected final Loggerprotected final org.openremote.model.rules.Notificationsprotected final org.openremote.model.rules.PredictedDatapointsprotected booleanprotected final Set<org.openremote.model.attribute.AttributeInfo> protected io.micrometer.core.instrument.Timerprotected final RulesServiceprotected booleanprotected final ScheduledExecutorServicestatic final Loggerprotected ScheduledFuture<?> protected final org.openremote.container.timer.TimerServiceprotected booleanprotected final Set<org.openremote.model.attribute.AttributeInfo> protected final org.openremote.model.rules.Usersprotected final org.openremote.model.rules.Webhooks -
Constructor Summary
ConstructorsConstructorDescriptionRulesEngine(org.openremote.container.timer.TimerService timerService, RulesService rulesService, ManagerIdentityService identityService, ExecutorService executorService, ScheduledExecutorService scheduledExecutorService, AssetStorageService assetStorageService, AssetProcessingService assetProcessingService, NotificationService notificationService, WebhookService webhookService, AlarmService alarmService, ClientEventService clientEventService, AssetDatapointService assetDatapointService, AssetPredictedDatapointService assetPredictedDatapointService, RulesEngineId<T> id, AssetLocationPredicateProcessor assetLocationPredicatesConsumer, io.micrometer.core.instrument.Timer rulesFiringTimer) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddRuleset(T ruleset) protected voiddoFire()protected voidintprotected StringgetError()intgetId()protected org.openremote.model.rules.RulesEngineStatusbooleanvoidinsertOrUpdateAttributeInfo(org.openremote.model.attribute.AttributeInfo attributeInfo, boolean insert) booleanisError()booleanprotected voidprotected voidprotected voidprocessLocationRules(List<RulesEngine.AssetLocationPredicates> assetStateLocationPredicates) This is called with all the asset's that have a location attribute currently loaded into this engine.protected voidprotected voidpublishRulesetStatus(RulesetDeployment deployment) booleanremoveRuleset(org.openremote.model.rules.Ruleset ruleset) voidretractAttributeInfo(org.openremote.model.attribute.AttributeInfo attributeInfo) protected voidscheduleFire(boolean quickFire) Queues actual firing of rules; if facts have changed then firing occurs in a shorter time frame than if we just need to re-evaluateTemporaryFacts.voidstart()protected voidstartRuleset(RulesetDeployment deployment) voidstop()protected voidstopRuleset(RulesetDeployment deployment) toString()protected voidtrackLocationPredicates(boolean track) protected void
-
Field Details
-
LOG
-
STATS_LOG
-
timerService
protected final org.openremote.container.timer.TimerService timerService -
rulesService
-
executorService
-
scheduledExecutorService
-
assetStorageService
-
clientEventService
-
id
-
assetsFacade
protected final org.openremote.model.rules.Assets assetsFacade -
usersFacade
protected final org.openremote.model.rules.Users usersFacade -
notificationFacade
protected final org.openremote.model.rules.Notifications notificationFacade -
webhooksFacade
protected final org.openremote.model.rules.Webhooks webhooksFacade -
alarmsFacade
protected final org.openremote.model.rules.Alarms alarmsFacade -
predictedFacade
protected final org.openremote.model.rules.PredictedDatapoints predictedFacade -
historicFacade
protected final org.openremote.model.rules.HistoricDatapoints historicFacade -
assetLocationPredicatesConsumer
-
deployments
-
deploymentStatusMap
-
facts
-
engine
protected final org.jeasy.rules.core.AbstractRulesEngine engine -
running
protected boolean running -
previouslyFired
protected boolean previouslyFired -
lastFireTimestamp
protected long lastFireTimestamp -
trackLocationPredicates
protected boolean trackLocationPredicates -
fireTimer
-
statsTimer
-
updateInfos
-
insertInfos
-
retractInfos
-
deploymentInfo
-
rulesFiringTimer
protected io.micrometer.core.instrument.Timer rulesFiringTimer
-
-
Constructor Details
-
RulesEngine
public RulesEngine(org.openremote.container.timer.TimerService timerService, RulesService rulesService, ManagerIdentityService identityService, ExecutorService executorService, ScheduledExecutorService scheduledExecutorService, AssetStorageService assetStorageService, AssetProcessingService assetProcessingService, NotificationService notificationService, WebhookService webhookService, AlarmService alarmService, ClientEventService clientEventService, AssetDatapointService assetDatapointService, AssetPredictedDatapointService assetPredictedDatapointService, RulesEngineId<T> id, AssetLocationPredicateProcessor assetLocationPredicatesConsumer, io.micrometer.core.instrument.Timer rulesFiringTimer)
-
-
Method Details
-
getId
-
isRunning
public boolean isRunning() -
isError
public boolean isError() -
getExecutionErrorDeploymentCount
public int getExecutionErrorDeploymentCount() -
getCompilationErrorDeploymentCount
public int getCompilationErrorDeploymentCount() -
getError
-
addRuleset
-
removeRuleset
public boolean removeRuleset(org.openremote.model.rules.Ruleset ruleset) - Returns:
trueif this rules engine has no deployments.
-
start
public void start() -
trackLocationPredicates
protected void trackLocationPredicates(boolean track) -
stop
public void stop() -
startRuleset
-
stopRuleset
-
scheduleFire
protected void scheduleFire(boolean quickFire) Queues actual firing of rules; if facts have changed then firing occurs in a shorter time frame than if we just need to re-evaluateTemporaryFacts. This effectively limits how often the rules engine will fire, only once within the guaranteed minimum expiration time. -
fireAllDeployments
protected void fireAllDeployments() -
doFire
protected void doFire() -
getEngineId
-
notifyAssetStatesChanged
-
insertOrUpdateAttributeInfo
public void insertOrUpdateAttributeInfo(org.openremote.model.attribute.AttributeInfo attributeInfo, boolean insert) -
retractAttributeInfo
public void retractAttributeInfo(org.openremote.model.attribute.AttributeInfo attributeInfo) -
updateDeploymentInfo
protected void updateDeploymentInfo() -
printSessionStats
protected void printSessionStats() -
processLocationRules
protected void processLocationRules(List<RulesEngine.AssetLocationPredicates> assetStateLocationPredicates) This is called with all the asset's that have a location attribute currently loaded into this engine. -
hasPreviouslyFired
public boolean hasPreviouslyFired() -
getStatus
protected org.openremote.model.rules.RulesEngineStatus getStatus() -
publishRulesEngineStatus
protected void publishRulesEngineStatus() -
publishRulesetStatus
-
toString
-