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 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 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 EvaluateTrue( MatchedEventMap matchEvent, EvalStateNode fromNode, bool isQuitted, EventBean optionalTriggeringEvent) { var agentInstanceContext = evalOrNode.Context.AgentInstanceContext; agentInstanceContext.InstrumentationProvider.QPatternOrEvaluateTrue(evalOrNode.factoryNode, matchEvent); // If one of the children quits, the whole or expression turns true and all subexpressions must quit if (isQuitted) { for (var i = 0; i < childNodes.Length; i++) { if (childNodes[i] == fromNode) { childNodes[i] = null; } } agentInstanceContext.AuditProvider.PatternInstance(false, evalOrNode.factoryNode, agentInstanceContext); QuitInternal(); // Quit the remaining listeners } agentInstanceContext.AuditProvider.PatternTrue( evalOrNode.FactoryNode, this, matchEvent, isQuitted, agentInstanceContext); ParentEvaluator.EvaluateTrue(matchEvent, this, isQuitted, optionalTriggeringEvent); agentInstanceContext.InstrumentationProvider.APatternOrEvaluateTrue(isQuitted); }
public void EvaluateFalse( EvalStateNode fromNode, bool restartable) { var agentInstanceContext = evalOrNode.Context.AgentInstanceContext; agentInstanceContext.InstrumentationProvider.QPatternOrEvalFalse(evalOrNode.factoryNode); for (var i = 0; i < childNodes.Length; i++) { if (childNodes[i] == fromNode) { childNodes[i] = null; } } var allEmpty = true; for (var i = 0; i < childNodes.Length; i++) { if (childNodes[i] != null) { allEmpty = false; break; } } if (allEmpty) { agentInstanceContext.AuditProvider.PatternFalse(evalOrNode.FactoryNode, this, agentInstanceContext); agentInstanceContext.AuditProvider.PatternInstance(false, evalOrNode.factoryNode, agentInstanceContext); ParentEvaluator.EvaluateFalse(this, true); } agentInstanceContext.InstrumentationProvider.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 void EvaluateFalse( EvalStateNode fromNode, bool restartable) { var agentInstanceContext = evalAndNode.Context.AgentInstanceContext; agentInstanceContext.InstrumentationProvider.QPatternAndEvaluateFalse(evalAndNode.factoryNode); int? indexFrom = null; for (var 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(); agentInstanceContext.AuditProvider.PatternFalse(evalAndNode.FactoryNode, this, agentInstanceContext); agentInstanceContext.AuditProvider.PatternInstance(false, evalAndNode.factoryNode, agentInstanceContext); ParentEvaluator.EvaluateFalse(this, restartable ? true : false); agentInstanceContext.InstrumentationProvider.APatternAndEvaluateFalse(); }
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 override void RemoveMatch(ISet <EventBean> matchEvent) { if (PatternConsumptionUtil.ContainsEvent(matchEvent, _eventObserver.BeginState)) { Quit(); ParentEvaluator.EvaluateFalse(this, true); } }
public void ObserverEvaluateFalse(bool restartable) { var agentInstanceContext = evalObserverNode.Context.AgentInstanceContext; agentInstanceContext.AuditProvider.PatternFalse(evalObserverNode.FactoryNode, this, agentInstanceContext); agentInstanceContext.AuditProvider.PatternInstance( false, evalObserverNode.factoryNode, agentInstanceContext); ParentEvaluator.EvaluateFalse(this, restartable); }
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); }
public override void RemoveMatch(ISet <EventBean> matchEvent) { if (PatternConsumptionUtil.ContainsEvent(matchEvent, BeginState)) { Quit(); ParentEvaluator.EvaluateFalse(this, true); } else { PatternConsumptionUtil.ChildNodeRemoveMatches(matchEvent, SpawnedNodes.Keys); } }
public override void RemoveMatch(ISet<EventBean> matchEvent) { if (PatternConsumptionUtil.ContainsEvent(matchEvent, beginState)) { Quit(); var agentInstanceContext = everyNode.Context.AgentInstanceContext; agentInstanceContext.AuditProvider.PatternFalse(everyNode.FactoryNode, this, agentInstanceContext); ParentEvaluator.EvaluateFalse(this, true); } else { PatternConsumptionUtil.ChildNodeRemoveMatches(matchEvent, spawnedNodes.Keys); } }
public override void RemoveMatch(ISet <EventBean> matchEvent) { if (!IsStarted) { return; } if (PatternConsumptionUtil.ContainsEvent(matchEvent, BeginState)) { Quit(); ParentEvaluator.EvaluateFalse(this, true); } }
public void EvaluateFalse( EvalStateNode fromNode, bool restartable) { activeChildNode = null; var agentInstanceContext = evalGuardNode.Context.AgentInstanceContext; agentInstanceContext.InstrumentationProvider.QPatternGuardEvalFalse(evalGuardNode.factoryNode); agentInstanceContext.AuditProvider.PatternFalse(evalGuardNode.FactoryNode, this, agentInstanceContext); agentInstanceContext.AuditProvider.PatternInstance(false, evalGuardNode.factoryNode, agentInstanceContext); ParentEvaluator.EvaluateFalse(this, true); agentInstanceContext.InstrumentationProvider.APatternGuardEvalFalse(); }
public override void RemoveMatch(ISet<EventBean> matchEvent) { if (PatternConsumptionUtil.ContainsEvent(matchEvent, eventObserver.BeginState)) { Quit(); var agentInstanceContext = evalObserverNode.Context.AgentInstanceContext; agentInstanceContext.AuditProvider.PatternFalse( evalObserverNode.FactoryNode, this, agentInstanceContext); ParentEvaluator.EvaluateFalse(this, true); } }
public void ObserverEvaluateTrue(MatchedEventMap matchEvent, bool quitted) { if (InstrumentationHelper.ENABLED) { InstrumentationHelper.Get().QPatternObserverEvaluateTrue(_evalObserverNode, matchEvent); } ParentEvaluator.EvaluateTrue(matchEvent, this, quitted); if (InstrumentationHelper.ENABLED) { InstrumentationHelper.Get().APatternObserverEvaluateTrue(); } }
public override void RemoveMatch(ISet<EventBean> matchEvent) { if (!_isStarted) { return; } if (PatternConsumptionUtil.ContainsEvent(matchEvent, _beginState)) { Quit(); var agentInstanceContext = _evalFilterNode.Context.AgentInstanceContext; agentInstanceContext.AuditProvider.PatternFalse(_evalFilterNode.FactoryNode, this, agentInstanceContext); ParentEvaluator.EvaluateFalse(this, true); } }
private void EvaluateTrue( MatchedEventMap theEvent, bool isQuitted, EventBean optionalTriggeringEvent) { var agentInstanceContext = _evalFilterNode.Context.AgentInstanceContext; agentInstanceContext.AuditProvider.PatternTrue( _evalFilterNode.FactoryNode, this, theEvent, isQuitted, agentInstanceContext); ParentEvaluator.EvaluateTrue(theEvent, this, isQuitted, optionalTriggeringEvent); }
public override void RemoveMatch(ISet <EventBean> matchEvent) { if (PatternConsumptionUtil.ContainsEvent(matchEvent, _beginState)) { Quit(); ParentEvaluator.EvaluateFalse(this, true); } else { if (_activeChildNode != null) { _activeChildNode.RemoveMatch(matchEvent); } } }
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 EvaluateTrue( MatchedEventMap matchEvent, EvalStateNode fromNode, bool isQuitted, EventBean optionalTriggeringEvent) { AgentInstanceContext agentInstanceContext = evalEveryNode.Context.AgentInstanceContext; agentInstanceContext.InstrumentationProvider.QPatternEveryEvaluateTrue( evalEveryNode.factoryNode, 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.StatementName); EvalStateNode spawned = evalEveryNode.ChildNode.NewState(spawnEvaluator); 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 agentInstanceContext.AuditProvider.PatternTrue( evalEveryNode.FactoryNode, this, matchEvent, false, agentInstanceContext); ParentEvaluator.EvaluateTrue(matchEvent, this, false, optionalTriggeringEvent); agentInstanceContext.InstrumentationProvider.APatternEveryEvaluateTrue(); }
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 RemoveMatch(ISet <EventBean> matchEvent) { bool quit = false; if (EventsPerChild != null) { foreach (Object entry in EventsPerChild) { if (entry is MatchedEventMap) { quit = PatternConsumptionUtil.ContainsEvent(matchEvent, (MatchedEventMap)entry); } else if (entry != null) { var list = (IList <MatchedEventMap>)entry; foreach (MatchedEventMap map in list) { quit = PatternConsumptionUtil.ContainsEvent(matchEvent, map); if (quit) { break; } } } if (quit) { break; } } } if (!quit && ActiveChildNodes != null) { foreach (EvalStateNode child in ActiveChildNodes) { if (child != null) { child.RemoveMatch(matchEvent); } } } if (quit) { Quit(); ParentEvaluator.EvaluateFalse(this, true); } }
public override void Start(MatchedEventMap beginState) { var factoryNode = evalNotNode.FactoryNode; var agentInstanceContext = evalNotNode.Context.AgentInstanceContext; agentInstanceContext.InstrumentationProvider.QPatternNotStart(evalNotNode.factoryNode, beginState); agentInstanceContext.AuditProvider.PatternInstance(true, factoryNode, agentInstanceContext); childNode = evalNotNode.ChildNode.NewState(this); 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. agentInstanceContext.AuditProvider.PatternTrue(factoryNode, this, beginState, false, agentInstanceContext); ParentEvaluator.EvaluateTrue(beginState, this, false, null); agentInstanceContext.InstrumentationProvider.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 override void RemoveMatch(ISet <EventBean> matchEvent) { bool quit = PatternConsumptionUtil.ContainsEvent(matchEvent, _beginState); if (!quit) { foreach (List <EventBean> list in _matchedEventArrays) { if (list == null) { continue; } foreach (EventBean @event in list) { if (matchEvent.Contains(@event)) { quit = true; break; } } if (quit) { break; } } } if (quit) { Quit(); ParentEvaluator.EvaluateFalse(this, true); } else { if (_stateMatcher != null) { _stateMatcher.RemoveMatch(matchEvent); } if (_stateUntil != null) { _stateUntil.RemoveMatch(matchEvent); } } }
public void GuardQuit() { var agentInstanceContext = evalGuardNode.Context.AgentInstanceContext; agentInstanceContext.InstrumentationProvider.QPatternGuardGuardQuit(evalGuardNode.factoryNode); // 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 activeChildNode?.Quit(); activeChildNode = null; // Indicate to parent state that this is permanently false. agentInstanceContext.AuditProvider.PatternFalse(evalGuardNode.FactoryNode, this, agentInstanceContext); agentInstanceContext.AuditProvider.PatternInstance(false, evalGuardNode.factoryNode, agentInstanceContext); ParentEvaluator.EvaluateFalse(this, true); agentInstanceContext.InstrumentationProvider.APatternGuardGuardQuit(); }
public void EvaluateFalse(EvalStateNode fromNode, bool restartable) { if (InstrumentationHelper.ENABLED) { InstrumentationHelper.Get().QPatternEveryEvalFalse(_evalEveryNode); } fromNode.Quit(); _spawnedNodes.Remove(fromNode); if (!restartable) { ParentEvaluator.EvaluateFalse(this, false); if (InstrumentationHelper.ENABLED) { InstrumentationHelper.Get().APatternEveryEvalFalse(); } return; } // 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; } if (InstrumentationHelper.ENABLED) { InstrumentationHelper.Get().APatternEveryEvalFalse(); } }