Integration of Drools with Hadoop
by Roger Smith
We are working on a project to integrate Drools with Apache Hadoop,
http://hadoop.apache.org/, and run into some road blocks. We would very much
appreciate any suggestions/help from this list.
We have an app where we call drools rule engine inside the reducer task of a
Hadoop map reduce job. It throws a NullPointerException when we the rule
package resource to the knowledge builder. The same code works fine when
run as part of a stand alone app.
Code:
private static Map<String, StatefulKnowledgeSession> sessions =
new HashMap<String, StatefulKnowledgeSession>();
private static final String RULE_PACK_DIR = "
file:///home/roger/Projects/gridx/ <file:///\\home\pranab\Projects\gridx\>";
private static final String RULE_PACK_EXT = ".drl";
public int process(String rulePackage, String dateTime, String type)
throws TException {
int rate = 0;
StatefulKnowledgeSession session = sessions.get(rulePackage);
if (null == session){
KnowledgeBuilder kbuilder =
KnowledgeBuilderFactory.newKnowledgeBuilder();
String rulePackPath = RULE_PACK_DIR + rulePackage +
RULE_PACK_EXT;
kbuilder.add( ResourceFactory.newFileResource(rulePackPath ),
ResourceType.DRL);
if ( kbuilder.hasErrors() ) {
System.err.println( kbuilder.getErrors().toString() );
}
KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase();
kbase.addKnowledgePackages(kbuilder.getKnowledgePackages());
session = kbase.newStatefulKnowledgeSession();
sessions.put(rulePackage, session);
}
ContractRule contractRule = new ContractRule();
contractRule.prepare(dateTime, type);;
FactHandle ruleHandle = session.insert(contractRule);
session.fireAllRules();
System.out.println("" + contractRule);
rate = contractRule.getRate();
session.retract(ruleHandle);
return rate;
}
This line throws the exception:
kbuilder.add( ResourceFactory.newFileResource(rulePackPath ),
ResourceType.DRL);
It works fine as a stand alone app, outside hadoop
Roger Smith
15 years, 2 months
working with aray list
by wasim.khan318
public static class Item
{
private String CustomerId;
private String Item;
}
public static class Data
{
public ArrayList<Item> items = new ArrayList<Item>();
public ArrayList<Item> GetData()
{Item item1 = new Item();
// some code
from database
item1.CustomerId=rs.getString("CustomerId");
item1.Price=rs.getString("item");
items.add(item);
return item1
}
1.how to write rule how to find customer of a perticular Item
2. what i have written
$D:Data();
$I:Item();
$R:Item(item =="I1" )from $D.GetData() ;
then
System.out.println("hello");
--
View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/working-with-aray-lis...
Sent from the Drools - User mailing list archive at Nabble.com.
15 years, 2 months
Modifying in built rule in new formatt
by wasim.khan318
It is a Test Code , and i am very new to java and drools
i have a inbuilt
rule "bundle A - included units"
dialect "mvel"
when
$order : OrderDTO( )
$line : OrderLineDTO( itemId == 16, $quantity : quantity ) from
$order.lines
SubscriptionResult( userId == $order.userId, itemId == 12, subscribed ==
true )
$pricing : PricingResult(userId == $order.userId, itemId == 13)
then
$order.getLines().remove($line);
OrderLineBL.addItem($order, 13, new Integer($quantity.intValue()),
$pricing.getPrice());update($order);
end
i want to modify this rule like
rule "bundle A - included units"
dialect "mvel"
when
$order : OrderDTO( )
$line : OrderLineDTO( itemId == param1, $quantity : quantity ) from
$order.lines
SubscriptionResult( userId == $order.userId, itemId == param2, subscribed
== true )
$pricing : PricingResult(userId == $order.userId, itemId == param3)
then
$order.getLines().remove($line);
OrderLineBL.addItem($order, param3, new Integer($quantity.intValue()),
$pricing.getPrice());update($order);
end
1.i want to replace hardcoded value to params as ItemId16 to param1
,Itemid12 to param2 so when any one see my rule can not guess about
hardcoded value. and i want that the values of param1,param2 some how come
from database
2.Till now what i did from my reading and exploring is
i have created java functions in jboss which returns value like
GetParam1(some var),GetParam2(some var),GetParam3()
i tested them in jboss drools application they are working fine
3. then i build package and upload in guvnor
4.while writing technical ander Fact field i am getting only GetParam3() not
GetParam1(some var) and
GetParam2(some var)
5. I dont know why . when i remove parameter value say make GetParam1() ,
without parameter it comes under class field.
6. please tell me is it right approach and if right then how i handle
GetParam1(some var) ,because they return param1 value which passed in
modified rule
--
View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Modifying-in-built-ru...
Sent from the Drools - User mailing list archive at Nabble.com.
15 years, 2 months
Re: [rules-users] URGENT : Drools - Guvnor Integration doubt
by Esteban Aliverti
Hi,
My first suggestion is: never use the word URGENT in the subject! 90% of the
people that write to this list (me included) have "urgent" problems ;)
Now, regarding to your question. In order to use a model in guvnor, you must
upload it as a jar file. Once you have your jar uploaded, you can start
authoring your rules in guvnor.
Your applications can then get those rules (its sources or as a compiled
package) to use them. Usually, applications don't modify the model classes:
they don't create new classes nor add new attributes, etc.
When you need to modify a class, then you need to upload the new version of
you jar again. There are ways to do this programatically if you need to.
Best regards,
El dic 28, 2010 6:35 a.m., "sunkara007" <srinivas.sunkara(a)altisource.com>
escribió:
Hi Team,
I am evaluating Drools - Guvnor to use it in BPM suits.
can you explain how the domain...
View this message in context:
http://drools-java-rules-engine.46999.n3.nabble.com/URGENT-Drools-Guvnor-...
Sent from the Drools - User mailing list archive at Nabble.com.
____________________________________...
15 years, 2 months
Testing rules created using fluent API
by Dan Nathanson
Hi,
I've written code that converts our company's internal model of a process
flow to a Drools flow, using the fluent API. I can see in my debugger that
I've created the correct structure (I think), but I'd like to write test
cases that prove it. Is there a way to check the structure of the generated
process without executing it? I'm not trying to test a specific flow, I'm
trying to test the code that converts from our model to Drools.
Regards,
Dan Nathanson
15 years, 2 months
Re: [rules-users] URL for package documentation does not refresh
by John Peterson
We're running on a Linux server using JBoss 4.2.3.GA, so the
documentation isn't on our workstations (we tried clearing the cache on
IE and it didn't resolve the issue).
Is it sitting out on the server someplace?
>Message: 3
>Date: Thu, 30 Dec 2010 07:31:14 -0700
>From: "John Peterson" <john.peterson.gv3k(a)statefarm.com>
>Subject: [rules-users] URL for package documentation does not refresh
> with new Build
>To: <rules-users(a)lists.jboss.org>
>Message-ID:
>
<D3A6E68928C9104BB815C83F43A36BDF0F1164FD(a)WPSCV6NH.OPR.STATEFARM.ORG>
>Content-Type: text/plain; charset="us-ascii"
>
>I was experimenting with Guvnor 5.1.1's new capability to produce
documentation. In my scenario, I did a Build Package and then clicked
on the "URL for package documentation" link. Everything looked
>fine.
>Then I went back and added a description to one rule and "un-disabled"
>another rule (in DSL) to see how it would look on the report. I
returned to the package screen, clicked Build Package, then click on the
"URL for package documentation" link, but nothing appeared to
>change (neither my description nor my "un-disabled rule" are on the
report).
>
>I've tried to "Save and validate package" as well as logging out of
Guvnor and logging back in, but those did not work either. Has anyone
else seen this?
>
15 years, 2 months
URL for package documentation does not refresh with new Build
by John Peterson
I was experimenting with Guvnor 5.1.1's new capability to produce
documentation. In my scenario, I did a Build Package and then clicked
on the "URL for package documentation" link. Everything looked fine.
Then I went back and added a description to one rule and "un-disabled"
another rule (in DSL) to see how it would look on the report. I
returned to the package screen, clicked Build Package, then click on the
"URL for package documentation" link, but nothing appeared to change
(neither my description nor my "un-disabled rule" are on the report).
I've tried to "Save and validate package" as well as logging out of
Guvnor and logging back in, but those did not work either. Has anyone
else seen this?
15 years, 2 months
Rule removal in BRMS 5.1/Drools Guvnor
by Benson Fung
Hi,
I created a rule(Technical rule) in the BRMS. But I would like to remove it
now. When I pull down the Action at the top right hand corner, the delete
is greyed. Please teach me how to remove the rule, otherwise, so many
garbage rule will be accumulated in the BRMS.
Thanks
Benson
15 years, 2 months