簡體   English   中英

Fiware Orion + Cosmos:訂閱失敗 - 嘗試通知屬於同一網絡的 PC 時已超時

[英]Fiware Orion + Cosmos: Subscription failed - Timeout was reached trying to notify a PC that belongs to the same network

我在 Citrix Xenserver 服務器上有一個場景,在同一網絡 (10.0.1.0/24) 上有 3 個虛擬機 (VM) Centos7。 每個 VM 負責在 Scala(邏輯回歸)上使用 Apache Spark 進行預測。 我在 Docker 上使用 Orion 上下文代理 (CB) 來創建將被觸發以詢問預測的訂閱。 CB 它僅位於 10.0.1.4 VM 中,我使一些端口可用於從其他機器訪問。

我的 docker-compose.yml:

 mongo:
   image: mongo:4.4
   command: --nojournal
 orion:
   image: fiware/orion
   links:
     - mongo
   ports:
     - "1026:1026"
     - "1027:1027"
     - "1028:1028"
     - "9090:9090"
     
   command: -dbhost mongo -corsOrigin __ALL

例如,要從 10.0.1.2 VM 訪問 CB,我使用 10.0.1.4:1028/..... 等等。

這是我面臨問題的訂閱(也許與 10.0.1.3 VM 相關的其他訂閱也必須有同樣的問題)

 curl -v localhost:1026/v2/subscriptions -s -S -H 'Content-Type: application/json' -d @- <<EOF
{
  "description": "Suscripcion de anemia para monitorear al Paciente",
  "subject": {
    "entities": [
      {
        "id": "Paciente1",
        "type": "Paciente"
      }
    ],
    "condition": {
      "attrs": ["calculateAnaemia"]
    },
    "expression":{
        "q":"calculateAnaemia:1"
    }
  },
  "notification": {
    "http": {
      "url": "http://10.0.1.2:9002/notify"
    },
    
    "attrs": ["gender","age","hemoglobin","mch","mchc","mcv"]
    
  },
  "expires": "2040-01-01T14:00:00.00Z",
  "throttling": 10
  
}
EOF

我在 10.0.1.2 VM 上有一個代碼,它正在使用 Fiware Cosmos 在端口 9002 上偵聽與此訂閱相關的更改:

對於10.0.1.4 VM 上的 eventStream變量,端口為 9004,對於 10.0.1.3 VM,端口為 9003

對於conf變量,我在 10.0.1.4 VM 上使用 10.0.1.4 IP 設置“spark.driver.host”,並將 10.0.1.3 VM 設置為 10.0.1.3 IP

import esqMensajeria.ActorSysMensajeria.ActoresEsquema
import org.apache.spark._
import org.apache.spark.streaming.{Seconds, StreamingContext}
import org.fiware.cosmos.orion.spark.connector._

object Main extends App{
    val conf = new SparkConf().setMaster("local[*]").setAppName("AnaemiaPrediction").set("spark.driver.host", "10.0.1.2")
    val ssc = new StreamingContext(conf, Seconds(10))
    // Create Orion Source. Receive notifications on port 9002
    val eventStream = ssc.receiverStream(new OrionReceiver(9002))
    // Esquema de mensajeria
    val actorSysMsj = new ActoresEsquema ()
    println("Esperando cambios para obtener información...")
    // Process event stream
    val processedDataStream = eventStream
      .flatMap(event => event.entities)
      .map(entity => {
        val gender: Int = entity.attrs("gender").value.asInstanceOf[Number].intValue()
        val age: Int = entity.attrs("age").value.asInstanceOf[Number].intValue()
        val hemoglobin: Double = entity.attrs("hemoglobin").value.asInstanceOf[Double].doubleValue()
        val mch: Double = entity.attrs("mch").value.asInstanceOf[Double].doubleValue()
        val mchc: Double = entity.attrs("mchc").value.asInstanceOf[Double].doubleValue()
        val mcv: Double = entity.attrs("mcv").value.asInstanceOf[Double].doubleValue()
        actorSysMsj.start((entity.id, gender,age,hemoglobin,mch,mchc,mcv),conf)
        (entity.id, gender,age,hemoglobin,mch,mchc,mcv)
      })
    processedDataStream.print
    ssc.start()
    ssc.awaitTermination()
}

但是當我觸發時,訂閱失敗顯示下一個(不僅在 10.0.1.2 上,也在 10.0.1.3 VM 上):

{"id":"61cb8569a1e87a254e16066d",
"description":"Suscripcion de anemia para monitorear al Paciente",
"expires":"2040-01-01T14:00:00.000Z",
"status":"failed",
"subject":{"entities":[{"id":"Paciente1","type":"Paciente"}],
"condition":{"attrs":["calculateAnaemia"]}},
"notification":
{"timesSent":3,
"lastNotification":"2021-12-29T00:03:49.000Z",
"attrs":"gender","age","hemoglobin","mch","mchc","mcv"],"
onlyChangedAttrs":false,
"attrsFormat":"normalized",
http":{"url":"http://10.0.1.2:9002/notify"},
"lastFailure":"2021-12-29T00:03:54.000Z",
"lastFailureReason":"Timeout was reached"},
"throttling":10}]

奇怪的是,當我使用與具有 CB 容器的 10.0.1.4 VM 相關的訂閱時,訂閱仍然處於活動狀態,我得到了預期的結果。

這是訂閱:

 curl -v localhost:1026/v2/subscriptions -s -S -H 'Content-Type: application/json' -d @- <<EOF
{
  "description": "Suscripcion de deceso para monitorear al Paciente",
  "subject": {
    "entities": [
      {
        "id": "Paciente1",
        "type": "Paciente"
      }
    ],
    "condition": {
      "attrs": [
        "calculateDeceased"
      ]
    },
    "expression":{
        "q":"calculateDeceased:1"
    }
  },
  "notification": {
    "http": {
      "url": "http://10.0.1.4:9004/notify"
    },
    "attrs": [
      "gender","age","hasAnaemia","creatinePP","hasDiabetes","ejecFrac","highBloodP","platelets","serumCreatinine","serumSodium","smoking","time"
    ]
  },
  "expires": "2040-01-01T14:00:00.00Z"
}
EOF

這是觸發並完美處理時的答案:

{"id":"61caab07a1e87a254e160665",
"description":"Suscripcion de deceso para monitorear al Paciente",
"expires":"2040-01-01T14:00:00.000Z",
"status":"active",
"subject":{"entities":[{"id":"Paciente1","type":"Paciente"}],
"condition":{"attrs":["calculateDeceased"]}},
"notification":{"timesSent":1,"lastNotification":"2021-12-28T06:15:41.000Z",
"attrs":["gender","age","hasAnaemia","creatinePP","hasDiabetes","ejecFrac","highBloodP","platelets","serumCreatinine","serumSodium","smoking","time"],
"onlyChangedAttrs":false,
"attrsFormat":"normalized",
"http":{"url":"http://10.0.1.4:9004/notify"},
"lastSuccess":"2021-12-28T06:15:43.000Z",
"lastSuccessCode":200}}

我不得不說我是 Spark、Scala 甚至 Fiware 的新手。 但是項目就是項目,也許我錯過了我在設置這個項目時閱讀的所有內容中沒有看到的東西。 此外,我停止了所有防火牆 (firewalld),因為我在與 10.0.1.2 和 10.0.1.3 虛擬機相關的訂閱上遇到“無法連接到服務器”錯誤。 我也做了一個 sudo yum 更新,我在彼此之間 ping 了所有的虛擬機,我得到了很好的響應。 我不知道它是否重要的一件事:我的所有虛擬機上都有互聯網,但我無法 ping 例如... www.google.com或 8.8.8.8。 所以,歡迎提出任何建議。 我為我的英語道歉。 先謝謝了~

好吧,經過 3 天的不斷尋找和嘗試,我發現我需要關閉 1.2 和 1.3 防火牆並保持在 1.4 上。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM