Skip to content

Commit

Permalink
Merge pull request #32 from lucasponce/PERFORMANCE
Browse files Browse the repository at this point in the history
HWKALERTS-29 Performance tests
  • Loading branch information
lucasponce committed Apr 1, 2015
2 parents ba0b652 + 34eddfc commit 3f8303c
Show file tree
Hide file tree
Showing 5 changed files with 655 additions and 10 deletions.
62 changes: 62 additions & 0 deletions hawkular-alerts-engine/pom.xml
Expand Up @@ -139,6 +139,31 @@
</build>

<profiles>
<profile>
<id>default</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<systemProperties>
<property>
<name>testOutput</name>
<value>${project.build.testOutputDirectory}</value>
</property>
</systemProperties>
<excludes>
<exclude>**/*/PerfRulesEngineTest.java</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>dev</id>
<build>
Expand All @@ -163,6 +188,43 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<systemProperties>
<property>
<name>testOutput</name>
<value>${project.build.testOutputDirectory}</value>
</property>
</systemProperties>
<excludes>
<exclude>**/*/PerfRulesEngineTest.java</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>perf</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<systemProperties>
<property>
<name>testOutput</name>
<value>${project.build.testOutputDirectory}</value>
</property>
</systemProperties>
<includes>
<include>**/*/PerfRulesEngineTest.java</include>
</includes>
</configuration>
</plugin>
</plugins>
</build>
</profile>
Expand Down
Expand Up @@ -22,6 +22,8 @@

import javax.ejb.Singleton;

import org.drools.core.event.DebugAgendaEventListener;
import org.drools.core.event.DebugRuleRuntimeEventListener;
import org.hawkular.alerts.api.model.data.Data;
import org.hawkular.alerts.engine.rules.RulesEngine;
import org.jboss.logging.Logger;
Expand Down Expand Up @@ -56,6 +58,11 @@ public DroolsRulesEngineImpl() {
ks = KieServices.Factory.get();
kc = ks.getKieClasspathContainer();
kSession = kc.newKieSession(SESSION_NAME);

if (log.isEnabled(Logger.Level.TRACE)) {
kSession.addEventListener(new DebugAgendaEventListener());
kSession.addEventListener(new DebugRuleRuntimeEventListener());
}
}

@Override
Expand Down
Expand Up @@ -176,7 +176,6 @@ rule RetractProcessedAvailabilityData
retract ( $d );
end


////// DAMPENING
//
// Dampening defines for each trigger how the number of positive, negative, and total evaluations determine
Expand Down Expand Up @@ -265,30 +264,34 @@ rule DampenTriggerAny
log.debug( "Updating dampening (ANY) for: " + $ce );
}
retract( $d );
retract ( $ce );

$d.perform( $ce );
insert( $d );
if (log != null && log.isDebugEnabled()) {
log.debug("Retracting multi-condition ANY trigger eval: " + $ce);
}
retract ( $ce );

end

rule DampenOneConditionTrigger
when
$t : Trigger( match == Match.ALL, $tid : id, $tmode : mode )
$d : Dampening( triggerId == $tid, triggerMode == $tmode, satisfied == false )
$d : Dampening( triggerId == $tid, triggerMode == $tmode, satisfied == false )
$ce : ConditionEval ( triggerId == $tid, conditionSetSize == 1, conditionSetIndex == 1 )
then
if (log != null && log.isDebugEnabled()) {
log.debug("Updating dampening for: " + $ce);
}
retract( $d );
retract ( $ce );

$d.perform( $ce );
insert( $d );
if (log != null && log.isDebugEnabled()) {
log.debug("Retracting single-condition trigger eval: " + $ce);
}
retract ( $ce );

end

rule DampenTwoConditionTrigger
Expand All @@ -302,8 +305,9 @@ rule DampenTwoConditionTrigger
if (log != null && log.isDebugEnabled()) {
log.debug("Updating dampening for: " + $ce1 + $ce2);
}
retract( $d );
$d.perform( $ce1, $ce2 );
update( $d );
insert( $d );
for( ConditionEval ce : new ConditionEval[] { $ce1, $ce2 } ) {
if ( ! ce.isUsed() ) {
retract( ce );
Expand All @@ -325,8 +329,9 @@ rule DampenThreeConditionTrigger
if (log != null && log.isDebugEnabled()) {
log.debug("Updating dampening for: " + $ce1 + $ce2 + $ce3);
}
retract( $d )
$d.perform( $ce1, $ce2, $ce3 );
update( $d );
insert( $d );
for( ConditionEval ce : new ConditionEval[] { $ce1, $ce2, $ce3 } ) {
if ( ! ce.isUsed() ) {
retract( ce );
Expand All @@ -349,8 +354,9 @@ rule DampenFourConditionTrigger
if (log != null && log.isDebugEnabled()) {
log.debug("Updating dampening for: " + $ce1 + $ce2 + $ce3 + $ce4);
}
retract( $d )
$d.perform( $ce1, $ce2, $ce3, $ce4 );
update( $d );
insert( $d );
for( ConditionEval ce : new ConditionEval[] { $ce1, $ce2, $ce3, $ce4 } ) {
if ( ! ce.isUsed() ) {
retract( ce );
Expand Down Expand Up @@ -392,7 +398,7 @@ end
rule AlertOnSatisfiedDampening
when
$t : Trigger( mode == Mode.FIRE, $tid : id )
$d : Dampening( triggerMode == Mode.FIRE, triggerId == $tid, satisfied == true )
$d : Dampening( triggerMode == Mode.FIRE, triggerId == $tid, satisfied == true )
then
if (log != null && log.isDebugEnabled()) {
log.debug("AlertOnSatisfiedDampening! " + $d.log());
Expand Down Expand Up @@ -429,7 +435,7 @@ end
rule SetFiringModeOnSatisfiedDampening
when
$t : Trigger( mode == Mode.SAFETY, $tid : id )
$d : Dampening( triggerMode == Mode.SAFETY, triggerId == $tid, satisfied == true )
$d : Dampening( triggerMode == Mode.SAFETY, triggerId == $tid, satisfied == true )
then
if (log != null && log.isDebugEnabled()) {
log.debug("SetFiringModeOnSatisfiedDampening! " + $d.log());
Expand Down

0 comments on commit 3f8303c

Please sign in to comment.