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 override void Start(MatchedEventMap beginState) { if (InstrumentationHelper.ENABLED) { InstrumentationHelper.Get().QPatternEveryDistinctStart(EveryNode, beginState); } BeginState = beginState.ShallowCopy(); var childState = EveryNode.ChildNode.NewState(this, null, 0L); SpawnedNodes.Put(childState, new LinkedHashMap <Object, long>()); // During the start of the child we need to use the temporary evaluator to catch any event created during a start. // Events created during the start would likely come from the "not" operator. // Quit the new child again if var spawnEvaluator = new EvalEveryStateSpawnEvaluator(EveryNode.Context.PatternContext.StatementName); childState.ParentEvaluator = spawnEvaluator; childState.Start(beginState); // If the spawned expression turned true already, just quit it if (spawnEvaluator.IsEvaluatedTrue) { childState.Quit(); } else { childState.ParentEvaluator = this; } if (InstrumentationHelper.ENABLED) { InstrumentationHelper.Get().APatternEveryDistinctStart(); } }
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) { if (InstrumentationHelper.ENABLED) { InstrumentationHelper.Get().QPatternEveryDistinctEvaluateTrue(EveryDistinctNode, matchEvent); } // determine if this evaluation has been seen before from the same node var matchEventKey = PatternExpressionUtil.GetKeys(matchEvent, EveryDistinctNode.FactoryNode.Convertor, EveryDistinctNode.FactoryNode.DistinctExpressionsArray, EveryDistinctNode.Context.AgentInstanceContext); var haveSeenThis = false; var keysFromNode = SpawnedNodes.Get(fromNode); if (keysFromNode != null) { if (keysFromNode.Contains(matchEventKey)) { haveSeenThis = true; } else { keysFromNode.Add(matchEventKey); } } if (isQuitted) { SpawnedNodes.Remove(fromNode); } // See explanation in EvalFilterStateNode for the type check if (fromNode.IsFilterStateNode) { // 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(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 { var keyset = new HashSet <Object>(); if (keysFromNode != null) { keyset.AddAll(keysFromNode); } SpawnedNodes.Put(spawned, keyset); spawned.ParentEvaluator = this; } } if (!haveSeenThis) { ParentEvaluator.EvaluateTrue(matchEvent, this, false); } if (InstrumentationHelper.ENABLED) { InstrumentationHelper.Get().APatternEveryDistinctEvaluateTrue(keysFromNode, null, matchEventKey, haveSeenThis); } }