I am using Drools with Spark in a stand alone cluster. I want to load the knowledge session on all the worker nodes at the startup i.e. before the map reduce task. I've tried passing the Statefull session from driver to slave nodes but its not working. Due to this my first job takes around 900ms just to add rules to Knowledge Builder.
Asked
Active
Viewed 440 times
0
-
1Welcome to SO. Please read how to create a [mcve]. – zero323 Aug 01 '16 at 11:10
1 Answers
0
Create Final variable of KnowledgeSession on driver,
final StatelessKnowledgeSession ksession = kbase.newStatelessKnowledgeSession();
And you can pass that ksession
object to all the worker nodes,
lines.foreachRDD(new Function<JavaRDD<String>, Void>() {
public Void call(JavaRDD<String> rdd) throws Exception {
List<String> facts = rdd.collect();
//Apply rules on facts here
ksession.execute(facts);
return null;
}
});