Setting KieContainer kie.maven.settings.custom

2019-09-11 19:20发布

I am using drools with scala in apache spark. In order for KIE to know to look at my private nexus repository for the compiled rules, I am attempting to set the system property: "kie.maven.settings.custom" to a custom settings.xml file which is included in the working directory of the jar file.

I am attempting to set this system property at run time, but am having mixed results. Here is my code to set "kie.maven.settings.custom"

val userDir = System.getProperty("user.dir")
val customPath = Paths.get(userDir, "settings.xml")
System.setProperty("kie.maven.settings.custom", customPath.toString)

This appears to work properly when running on my local machine, however, in the cluster it is not working.

My question is: Should I expect this to work as I am expecting? Or does this create a race condition for KIE getting the system property?

My custom settings.xml file looks like:

<?xml version="1.0" encoding="UTF-8"?>
<profilesXml xmlns="http://maven.apache.org/PROFILES/1.0.0"
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xsi:schemaLocation="http://maven.apache.org/PROFILES/1.0.0 http://maven.apache.org/xsd/profiles-1.0.0.xsd">
<profiles>
    <profile>
        <id>profile-1</id>
        <activation>
            <activeByDefault>true</activeByDefault>
        </activation>
        <repositories>
            <repository>
                <id>temp-nexus</id>
                <url>http://nexus.path..com:8081/repository/maven-releases</url>
                <releases>
                    <updatePolicy>always</updatePolicy>
                </releases>
            </repository>
        </repositories>
    </profile>
</profiles>
</profilesXml>

标签: drools kie
1条回答
\"骚年 ilove
2楼-- · 2019-09-11 20:11

I was able to figure this out, and it turned out to be a Spark issue, and nothing to do with Drools.

To solve this I had to add my custom settings.xml to the Spark jobs class path, and to set some extra Spark properties. In the livy configuration file this look like:

"conf":{
        "spark.driver.extraJavaOptions": "-Dkie.maven.settings.custom=settings.xml",
        "spark.executor.extraJavaOptions": "-Dkie.maven.settings.custom=settings.xml"
    }

I set this both for the driver and executor extra options, although just setting the executor extra options should have been sufficient, but I have not tested that.

查看更多
登录 后发表回答