Time Sliding Window Question
by Bernhard Unger
Hello,
I am fairly new to Drools and tried my first steps with Drools Fusion and
was running into the following problem:
According to the Drools Fusion User Guide Version 5.4.0.Final on page 32 the
following pattern should work and select events in between the last 10
minutes:
...
StockTick() over window:time( 2m )
...
I tried the following example, simulating RHQ EventComposite Events with a
simple Junit test:
...
KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
kbuilder.add(new ClassPathResource("rhqrules.drl", getClass()),
ResourceType.DRL);
KnowledgeBaseConfiguration config =
KnowledgeBaseFactory.newKnowledgeBaseConfiguration();
config.setOption(EventProcessingOption.STREAM);
nowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase(config);
kbase.addKnowledgePackages(kbuilder.getKnowledgePackages());
KnowledgeSessionConfiguration conf =
KnowledgeBaseFactory.newKnowledgeSessionConfiguration();
conf.setOption(ClockTypeOption.get("pseudo"));
ksession = kbase.newStatefulKnowledgeSession(conf, null);
...
inside the test method:
...
For-Loop inserts new Events and increases the pseudo clock in one minute
steps:
...
for (int i = 0; i < 100; i++) {
timestamp = clock.advanceTime(1, TimeUnit.MINUTES);
ksession.insert(new EventComposite("EventDetail" + i, resourceId,
"resourceName" + i, "resourceAncestry" + i, resourceTypeId,
eventId, severity, "sourceLocation" + i, timestamp));
}
...
ksession.fireAllRules();
...
The .drl definition should fire only events of the last 10 minutes, however
all inserted 100 events are fired:
declare EventComposite
@role( event )
end
rule "Rule1 events in between last 10 minutes"
when
$event : EventComposite() over window:time( 10m )
then
System.out.println("Event in between the last 10 minutes:: " + $event);
end
On the other hand this rule works as expected and selects only events older
than 10 minutes:
rule "Rule2 events not in between the last 10 minutes"
when
$eventA : EventComposite( )
not EventComposite( this.resourceId == $eventA.resourceId ) over
window:time( 10m )
then
System.out.println("Event not in between the last 10 minutes: " +
$eventA);
end
My question is:
What did I wrong in the definition of Rule-1, what is the correct statement
for finding the last 10 minutes events?
Background information:
I am doing some research on implementing using the drools framework inside
the RHQ framework for complex event processing. I would like to show that
this is possible and could be uses reasonable for RHQ event processing.
Any help is highly appreceated!
Thanks and kind regards
Bernhard
12 years, 6 months
Prevent saving the resource when using guvnorEditorObjRef, in case if validation fails.
by worldofprasanna
Hi All,
We have embedded the Guvnor decision table asset into our html page and
obtained the guvnorEditorObjRef to validate the new rule which is added. We
wrote our business logic within the function,
guvnorEditorObjRef.registerBeforeSaveAllButtonCallbackFunction()
And it works fine. But the problem is when we find the business validation
got failed, we couldn t stop the resource from saving. Check In dialog box
opens and we couldn t find a way to prevent it from saving.
Is there anyway to prevent the asset from Saving in case, if the validation
failed ?
Thanks,
Prasanna Venkataraman.
--
View this message in context: http://drools.46999.n3.nabble.com/Prevent-saving-the-resource-when-using-...
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 6 months
NullPointerException while loading pkg by KnowledgeAgent
by FlyingEagle
Hello,
I have this exception in my Drools application and I don't know what's
happening.
I try to load a pkg by applying a defined change set by the KnowledgeAgent.
If I load the pkg by the KnowledgeBuilder, everything is fine, but I want to
use the KnowledgeAgent, so that changes are automatically recognized.
Can anybody help me?
Thx
http://drools.46999.n3.nabble.com/file/n3959482/CardTrapping.drl
CardTrapping.drl
http://drools.46999.n3.nabble.com/file/n3959482/EngineStarter.java
EngineStarter.java
java.lang.NullPointerException at
org.drools.base.evaluators.AfterEvaluatorDefinition$AfterEvaluator.getInterval(AfterEvaluatorDefinition.java:272)
at
org.drools.rule.VariableRestriction.getInterval(VariableRestriction.java:132)
at
org.drools.rule.VariableConstraint.getInterval(VariableConstraint.java:133)
at
org.drools.reteoo.builder.BuildUtils.gatherTemporalRelationships(BuildUtils.java:334)
at
org.drools.reteoo.builder.BuildUtils.calculateTemporalDistance(BuildUtils.java:298)
at
org.drools.reteoo.builder.ReteooRuleBuilder.addRule(ReteooRuleBuilder.java:108)
at org.drools.reteoo.ReteooBuilder.addRule(ReteooBuilder.java:110)
at org.drools.reteoo.ReteooRuleBase.addRule(ReteooRuleBase.java:441)
at
org.drools.common.AbstractRuleBase.addRule(AbstractRuleBase.java:821)
at
org.drools.common.AbstractRuleBase.addPackages(AbstractRuleBase.java:555)
at
org.drools.reteoo.ReteooRuleBase.addPackages(ReteooRuleBase.java:458)
at
org.drools.impl.KnowledgeBaseImpl.addKnowledgePackages(KnowledgeBaseImpl.java:150)
at
org.drools.agent.impl.KnowledgeAgentImpl.addResourcesToKnowledgeBase(KnowledgeAgentImpl.java:1016)
at
org.drools.agent.impl.KnowledgeAgentImpl.rebuildResources(KnowledgeAgentImpl.java:785)
at
org.drools.agent.impl.KnowledgeAgentImpl.buildKnowledgeBase(KnowledgeAgentImpl.java:657)
at
org.drools.agent.impl.KnowledgeAgentImpl.applyChangeSet(KnowledgeAgentImpl.java:190)
at
org.drools.agent.impl.KnowledgeAgentImpl.applyChangeSet(KnowledgeAgentImpl.java:169)
at
com.wn.fraud.droolstest.starter.EngineStarter.initializeKnowledgeBase(EngineStarter.java:67)
at
com.wn.fraud.droolstest.starter.EngineStarter.<init>(EngineStarter.java:46)
at
com.wn.fraud.droolstest.starter.EngineStarter.getInstance(EngineStarter.java:33)
at
com.wn.fraud.droolstest.BaseFraudTest_UsingEngineStarter.createKnowledgeBase(BaseFraudTest_UsingEngineStarter.java:8)
at
com.wn.fraud.droolstest.BaseFraudTest.initialize(BaseFraudTest.java:47)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at
org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
at
org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at
org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
at
org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:27)
at
org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
at
org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:76)
at
org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
at
org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:49)
at
org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
--
View this message in context: http://drools.46999.n3.nabble.com/NullPointerException-while-loading-pkg-...
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 6 months