public void EvaluateTrue(MatchedEventMap matchEvent, EvalStateNode fromNode, bool isQuitted) { if (InstrumentationHelper.ENABLED) { InstrumentationHelper.Get().QPatternGuardEvaluateTrue(_evalGuardNode, matchEvent); } bool haveQuitted = _activeChildNode == null; // If one of the children quits, remove the child if (isQuitted) { _activeChildNode = null; // Stop guard, since associated subexpression is gone _guard.StopGuard(); } if (!(haveQuitted)) { bool guardPass = _guard.Inspect(matchEvent); if (guardPass) { ParentEvaluator.EvaluateTrue(matchEvent, this, isQuitted); } } if (InstrumentationHelper.ENABLED) { InstrumentationHelper.Get().APatternGuardEvaluateTrue(isQuitted); } }
public void EvaluateFalse(EvalStateNode fromNode, bool restartable) { if (InstrumentationHelper.ENABLED) { InstrumentationHelper.Get().QPatternAndEvaluateFalse(EvalAndNode); } int?indexFrom = null; for (int i = 0; i < ActiveChildNodes.Length; i++) { if (ActiveChildNodes[i] == fromNode) { ActiveChildNodes[i] = null; indexFrom = i; } } if (indexFrom != null) { EventsPerChild[indexFrom.Value] = null; } // The and node cannot turn true anymore, might as well quit all child nodes QuitInternal(); ParentEvaluator.EvaluateFalse(this, restartable ? true : false); if (InstrumentationHelper.ENABLED) { InstrumentationHelper.Get().APatternAndEvaluateFalse(); } }
public void EvaluateFalse(EvalStateNode fromNode, bool restartable) { if (InstrumentationHelper.ENABLED) { InstrumentationHelper.Get().QPatternEveryDistinctEvalFalse(EveryDistinctNode); } fromNode.Quit(); SpawnedNodes.Remove(fromNode); // Spawn all nodes below this EVERY node // During the start of a child we need to use the temporary evaluator to catch any event created during a start // Such events can be raised when the "not" operator is used. var spawnEvaluator = new EvalEveryStateSpawnEvaluator(EveryDistinctNode.Context.PatternContext.StatementName); var spawned = EveryDistinctNode.ChildNode.NewState(spawnEvaluator, null, 0L); spawned.Start(BeginState); // If the whole spawned expression already turned true, quit it again if (spawnEvaluator.IsEvaluatedTrue) { spawned.Quit(); } else { SpawnedNodes.Put(spawned, new HashSet <Object>()); spawned.ParentEvaluator = this; } if (InstrumentationHelper.ENABLED) { InstrumentationHelper.Get().APatternEveryDistinctEvalFalse(); } }
public void EvaluateTrue(MatchedEventMap matchEvent, EvalStateNode fromNode, bool isQuitted) { if (InstrumentationHelper.ENABLED) { InstrumentationHelper.Get().QPatternOrEvaluateTrue(EvalOrNode, matchEvent); } // If one of the children quits, the whole or expression turns true and all subexpressions must quit if (isQuitted) { for (int i = 0; i < ChildNodes.Length; i++) { if (ChildNodes[i] == fromNode) { ChildNodes[i] = null; } } QuitInternal(); // Quit the remaining listeners } ParentEvaluator.EvaluateTrue(matchEvent, this, isQuitted); if (InstrumentationHelper.ENABLED) { InstrumentationHelper.Get().APatternOrEvaluateTrue(isQuitted); } }
public override void Start(MatchedEventMap beginState) { if (InstrumentationHelper.ENABLED) { InstrumentationHelper.Get().QPatternOrStart(EvalOrNode, beginState); } // In an "or" expression we need to create states for all child expressions/listeners, // since all are going to be started int count = 0; foreach (EvalNode node in EvalOrNode.ChildNodes) { EvalStateNode childState = node.NewState(this, null, 0L); ChildNodes[count++] = childState; } // In an "or" expression we start all child listeners EvalStateNode[] childNodeCopy = new EvalStateNode[ChildNodes.Length]; Array.Copy(ChildNodes, 0, childNodeCopy, 0, ChildNodes.Length); foreach (EvalStateNode child in childNodeCopy) { child.Start(beginState); } if (InstrumentationHelper.ENABLED) { InstrumentationHelper.Get().APatternOrStart(); } }
public void EvaluateFalse(EvalStateNode fromNode, bool restartable) { if (InstrumentationHelper.ENABLED) { InstrumentationHelper.Get().QPatternOrEvalFalse(EvalOrNode); } for (int i = 0; i < ChildNodes.Length; i++) { if (ChildNodes[i] == fromNode) { ChildNodes[i] = null; } } bool allEmpty = true; for (int i = 0; i < ChildNodes.Length; i++) { if (ChildNodes[i] != null) { allEmpty = false; break; } } if (allEmpty) { ParentEvaluator.EvaluateFalse(this, true); } if (InstrumentationHelper.ENABLED) { InstrumentationHelper.Get().APatternOrEvalFalse(); } }
public void EvaluateFalse(EvalStateNode fromNode, bool restartable) { int index; fromNode.Quit(); var hasIndex = Nodes.TryGetValue(fromNode, out index); Nodes.Remove(fromNode); if (hasIndex && index > 0) { if (EvalFollowedByNode.IsTrackWithMax) { CountActivePerChild[index - 1]--; } if (EvalFollowedByNode.IsTrackWithPool) { PatternSubexpressionPoolStmtSvc poolSvc = EvalFollowedByNode.Context.StatementContext.PatternSubexpressionPoolSvc; poolSvc.EngineSvc.DecreaseCount(EvalFollowedByNode, EvalFollowedByNode.Context.AgentInstanceContext); poolSvc.StmtHandler.DecreaseCount(); } } if (Nodes.IsEmpty()) { ParentEvaluator.EvaluateFalse(this, true); Quit(); } }
public override void Start(MatchedEventMap beginState) { if (InstrumentationHelper.ENABLED) { InstrumentationHelper.Get().QPatternAndStart(EvalAndNode, beginState); } // In an "and" expression we need to create a state for all child listeners int count = 0; foreach (EvalNode node in EvalAndNode.ChildNodes) { EvalStateNode childState = node.NewState(this, null, 0L); ActiveChildNodes[count++] = childState; } // Start all child nodes foreach (EvalStateNode child in ActiveChildNodes) { if (child != null) { child.Start(beginState); } } if (InstrumentationHelper.ENABLED) { InstrumentationHelper.Get().APatternAndStart(); } }
public override void Start(MatchedEventMap beginState) { EvalNode child = EvalFollowedByNode.ChildNodes[0]; EvalStateNode childState = child.NewState(this, null, 0L); Nodes.Put(childState, 0); childState.Start(beginState); }
/// <summary> /// Constructor. /// </summary> /// <param name="parentNode">is the parent evaluator to call to indicate truth value</param> /// <param name="evalAuditNode">is the factory node associated to the state</param> /// <param name="stateNodeNumber">The state node number.</param> /// <param name="stateNodeId">The state node id.</param> public EvalAuditStateNode(Evaluator parentNode, EvalAuditNode evalAuditNode, EvalStateNodeNumber stateNodeNumber, long stateNodeId) : base(parentNode) { _evalAuditNode = evalAuditNode; _childState = evalAuditNode.ChildNode.NewState(this, stateNodeNumber, stateNodeId); }
public void EvaluateFalse(EvalStateNode fromNode, bool restartable) { if (InstrumentationHelper.ENABLED) { InstrumentationHelper.Get().QPatternNotEvalFalse(_evalNotNode); } if (InstrumentationHelper.ENABLED) { InstrumentationHelper.Get().APatternNotEvalFalse(); } }
public void EvaluateFalse(EvalStateNode fromNode, bool restartable) { if (_evalAuditNode.FactoryNode.IsAuditPattern && AuditPath.IsInfoEnabled) { String message = ToStringEvaluateFalse(this, _evalAuditNode.FactoryNode.PatternExpr, fromNode); AuditPath.AuditLog(_evalAuditNode.Context.StatementContext.EngineURI, _evalAuditNode.Context.PatternContext.StatementName, AuditEnum.PATTERN, message); } _evalAuditNode.FactoryNode.DecreaseRefCount(this, _evalAuditNode.Context.PatternContext); ParentEvaluator.EvaluateFalse(this, restartable); }
private void QuitInternal() { if (_stateMatcher != null) { _stateMatcher.Quit(); _stateMatcher = null; } if (_stateUntil != null) { _stateUntil.Quit(); _stateUntil = null; } }
public override void Start(MatchedEventMap beginState) { if (InstrumentationHelper.ENABLED) { InstrumentationHelper.Get().QPatternRootStart(beginState); } _topStateNode = RootSingleChildNode.NewState(this, null, 0L); _topStateNode.Start(beginState); if (InstrumentationHelper.ENABLED) { InstrumentationHelper.Get().APatternRootStart(); } }
public override void Start(MatchedEventMap beginState) { Instrument.With( i => i.QPatternFollowedByStart(EvalFollowedByNode, beginState), i => i.APatternFollowedByStart(), () => { EvalNode child = EvalFollowedByNode.ChildNodes[0]; EvalStateNode childState = child.NewState(this, null, 0L); Nodes.Put(childState, 0); childState.Start(beginState); }); }
public void EvaluateTrue(MatchedEventMap matchEvent, EvalStateNode fromNode, bool isQuitted) { if (_evalAuditNode.FactoryNode.IsAuditPattern && AuditPath.IsInfoEnabled) { String message = ToStringEvaluateTrue(this, _evalAuditNode.FactoryNode.PatternExpr, matchEvent, fromNode, isQuitted); AuditPath.AuditLog(_evalAuditNode.Context.StatementContext.EngineURI, _evalAuditNode.Context.PatternContext.StatementName, AuditEnum.PATTERN, message); } ParentEvaluator.EvaluateTrue(matchEvent, this, isQuitted); if (isQuitted) { _evalAuditNode.FactoryNode.DecreaseRefCount(this, _evalAuditNode.Context.PatternContext); } }
public void EvaluateFalse(EvalStateNode fromNode, bool restartable) { if (InstrumentationHelper.ENABLED) { InstrumentationHelper.Get().QPatternRootEvalFalse(); } if (_topStateNode != null) { _topStateNode.Quit(); _topStateNode = null; HandleEvaluateFalseEvent(); } if (InstrumentationHelper.ENABLED) { InstrumentationHelper.Get().APatternRootEvalFalse(); } }
public void EvaluateFalse(EvalStateNode fromNode, bool restartable) { Instrument.With( i => i.QPatternFollowedByEvalFalse(EvalFollowedByNode), i => i.APatternFollowedByEvalFalse(), () => { fromNode.Quit(); Nodes.Remove(fromNode); if (Nodes.IsEmpty()) { ParentEvaluator.EvaluateFalse(this, true); QuitInternal(); } }); }
public override void Quit() { if (InstrumentationHelper.ENABLED) { InstrumentationHelper.Get().QPatternRootQuit(); } if (_topStateNode != null) { _topStateNode.Quit(); HandleQuitEvent(); } _topStateNode = null; if (InstrumentationHelper.ENABLED) { InstrumentationHelper.Get().APatternRootQuit(); } }
public override void Start(MatchedEventMap beginState) { if (InstrumentationHelper.ENABLED) { InstrumentationHelper.Get().QPatternNotStart(_evalNotNode, beginState); } _childNode = _evalNotNode.ChildNode.NewState(this, null, 0L); _childNode.Start(beginState); // The not node acts by inverting the truth // By default the child nodes are false. This not node acts inverts the truth and pretends the child is true, // raising an event up. this.ParentEvaluator.EvaluateTrue(beginState, this, false); if (InstrumentationHelper.ENABLED) { InstrumentationHelper.Get().APatternNotStart(); } }
public void EvaluateTrue(MatchedEventMap matchEvent, EvalStateNode fromNode, bool isQuitted) { if (InstrumentationHelper.ENABLED) { InstrumentationHelper.Get().QPatternEveryEvaluateTrue(_evalEveryNode, matchEvent); } if (isQuitted) { _spawnedNodes.Remove(fromNode); } // See explanation in EvalFilterStateNode for the type check if (fromNode.IsFilterStateNode || fromNode.IsObserverStateNodeNonRestarting) { // We do not need to newState new listeners here, since the filter state node below this node did not quit } else { // Spawn all nodes below this EVERY node // During the start of a child we need to use the temporary evaluator to catch any event created during a start // Such events can be raised when the "not" operator is used. var spawnEvaluator = new EvalEveryStateSpawnEvaluator(_evalEveryNode.Context.PatternContext.StatementName); var spawned = _evalEveryNode.ChildNode.NewState(spawnEvaluator, null, 0L); spawned.Start(_beginState); // If the whole spawned expression already turned true, quit it again if (spawnEvaluator.IsEvaluatedTrue) { spawned.Quit(); } else { _spawnedNodes.Add(spawned); spawned.ParentEvaluator = this; } } // All nodes indicate to their parents that their child node did not quit, therefore a false for isQuitted ParentEvaluator.EvaluateTrue(matchEvent, this, false); if (InstrumentationHelper.ENABLED) { InstrumentationHelper.Get().APatternEveryEvaluateTrue(); } }
public void EvaluateTrue(MatchedEventMap matchEvent, EvalStateNode fromNode, bool isQuitted) { int index; var hasIndex = Nodes.TryGetValue(fromNode, out index); bool[] isFollowedByQuitted = { false }; using (Instrument.With( i => i.QPatternFollowedByEvaluateTrue(EvalFollowedByNode, matchEvent, index), i => i.APatternFollowedByEvaluateTrue(isFollowedByQuitted[0]))) { if (isQuitted) { Nodes.Remove(fromNode); } // the node may already have quit as a result of an outer state quitting this state, // however the callback may still be received; It is fine to ignore this callback. if (!hasIndex) { return; } // If the match came from the very last filter, need to escalate int numChildNodes = EvalFollowedByNode.ChildNodes.Length; if (index == (numChildNodes - 1)) { if (Nodes.IsEmpty()) { isFollowedByQuitted[0] = true; } ParentEvaluator.EvaluateTrue(matchEvent, this, isFollowedByQuitted[0]); } // Else start a new sub-expression for the next-in-line filter else { EvalNode child = EvalFollowedByNode.ChildNodes[index + 1]; EvalStateNode childState = child.NewState(this, null, 0L); Nodes.Put(childState, index + 1); childState.Start(matchEvent); } } }
public void EvaluateTrue(MatchedEventMap matchEvent, EvalStateNode fromNode, bool isQuitted) { if (InstrumentationHelper.ENABLED) { InstrumentationHelper.Get().QPatternRootEvaluateTrue(matchEvent); } if (isQuitted) { _topStateNode = null; HandleChildQuitEvent(); } _callback.Invoke(matchEvent.MatchingEventsAsMap); if (InstrumentationHelper.ENABLED) { InstrumentationHelper.Get().APatternRootEvaluateTrue(_topStateNode == null); } }
public override void Start(MatchedEventMap beginState) { if (InstrumentationHelper.ENABLED) { InstrumentationHelper.Get().QPatternGuardStart(_evalGuardNode, beginState); } _beginState = beginState; _guard = _evalGuardNode.FactoryNode.GuardFactory.MakeGuard(_evalGuardNode.Context, beginState, this, null, null); _activeChildNode = _evalGuardNode.ChildNode.NewState(this, null, 0L); // Start the single child state _activeChildNode.Start(beginState); // Start the guard _guard.StartGuard(); if (InstrumentationHelper.ENABLED) { InstrumentationHelper.Get().APatternGuardStart(); } }
public void EvaluateFalse(EvalStateNode fromNode, bool restartable) { Instrument.With( i => i.QPatternMatchUntilEvalFalse(_evalMatchUntilNode, fromNode == _stateUntil), i => i.APatternMatchUntilEvalFalse(), () => { var isMatcher = fromNode == _stateMatcher; if (isMatcher) { _stateMatcher.Quit(); _stateMatcher = null; } else { _stateUntil.Quit(); _stateUntil = null; } ParentEvaluator.EvaluateFalse(this, true); }); }
public override void Quit() { if (_activeChildNode == null) { return; } if (InstrumentationHelper.ENABLED) { InstrumentationHelper.Get().QPatternGuardQuit(_evalGuardNode); } if (_activeChildNode != null) { _activeChildNode.Quit(); _guard.StopGuard(); } _activeChildNode = null; if (InstrumentationHelper.ENABLED) { InstrumentationHelper.Get().APatternGuardQuit(); } }
public void EvaluateTrue(MatchedEventMap matchEvent, EvalStateNode fromNode, bool isQuitted) { if (InstrumentationHelper.ENABLED) { InstrumentationHelper.Get().QPatternNotEvaluateTrue(_evalNotNode, matchEvent); } // Only is the subexpression stopped listening can we tell the parent evaluator that this // turned permanently false. if (isQuitted) { _childNode = null; this.ParentEvaluator.EvaluateFalse(this, true); } else { // If the subexpression did not quit, we stay in the "true" state } if (InstrumentationHelper.ENABLED) { InstrumentationHelper.Get().APatternNotEvaluateTrue(isQuitted); } }
public void GuardQuit() { if (InstrumentationHelper.ENABLED) { InstrumentationHelper.Get().QPatternGuardGuardQuit(_evalGuardNode); } // It is possible that the child node has already been quit such as when the parent wait time was shorter. // 1. parent node's guard indicates quit to all children // 2. this node's guards also indicates quit, however that already occured if (_activeChildNode != null) { _activeChildNode.Quit(); } _activeChildNode = null; // Indicate to parent state that this is permanently false. ParentEvaluator.EvaluateFalse(this, true); if (InstrumentationHelper.ENABLED) { InstrumentationHelper.Get().APatternGuardGuardQuit(); } }
public override void Start(MatchedEventMap beginState) { Instrument.With( i => i.QPatternMatchUntilStart(_evalMatchUntilNode, beginState), i => i.APatternMatchUntilStart(), () => { _beginState = beginState; EvalNode childMatcher = _evalMatchUntilNode.ChildNodeSub; _stateMatcher = childMatcher.NewState(this, null, 0L); if (_evalMatchUntilNode.ChildNodeUntil != null) { EvalNode childUntil = _evalMatchUntilNode.ChildNodeUntil; _stateUntil = childUntil.NewState(this, null, 0L); } // start until first, it controls the expression // if the same event fires both match and until, the match should not count if (_stateUntil != null) { _stateUntil.Start(beginState); } EvalMatchUntilStateBounds bounds = EvalMatchUntilStateBounds.InitBounds( _evalMatchUntilNode.FactoryNode, beginState, _evalMatchUntilNode.Context); _lowerbounds = bounds.Lowerbounds; _upperbounds = bounds.Upperbounds; if (_stateMatcher != null) { _stateMatcher.Start(beginState); } }); }
public void EvaluateFalse(EvalStateNode fromNode, bool restartable) { Log.Warn("Event/request processing: Uncontrolled pattern matching of \"every\" operator - infinite loop when using EVERY operator on Expression(s) containing a not operator, for statement '" + _statementName + "'"); _isEvaluatedTrue = true; }