2017-02-24 14 views
0

我在apache spark中使用了scala中的drools。爲了讓KIE知道查看我的私有連接庫以獲得編譯的規則,我試圖將系統屬性「kie.maven.settings.custom」設置爲包含在工作目錄中的自定義settings.xml文件的jar文件。設置KieContainer kie.maven.settings.custom

我試圖在運行時設置這個系統屬性,但我有混合的結果。這裏是我的代碼來設置「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) 

我的本地機器上運行,但是,它不工作在集羣中時,這似乎正常工作。

我的問題是:我應該期望這樣工作,因爲我期待?或者這是否爲KIE獲取系統屬性創造了競爭條件?

我自定義的settings.xml文件看起來像:

<?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> 

回答

0

我能想出解決辦法,它原來是一個Spark問題,無關Drools的。

爲了解決這個問題,我不得不將我的自定義settings.xml添加到Spark作業類路徑,並設置一些額外的Spark屬性。在李維配置文件這個樣子:

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

我設置既爲駕駛者和執行額外的選項,雖然只是設置執行額外的選項應該已經足夠了,但我沒有測試過這一點。