Setting KieContainer kie.maven.settings.custom

感情迁移 提交于 2019-12-12 01:47:29

问题


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>

回答1:


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.



来源:https://stackoverflow.com/questions/42446989/setting-kiecontainer-kie-maven-settings-custom

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!