2016-04-14 10 views
2

Ben ubuntu 15.10 64 bit üzerinde benim localhost içinde donderized sürümü Fiware-Orion ContextBroker 0.28 kullanıyorum.Abonelikler dockerized fiware-orion kullanarak çalışma gibi görünmüyor

$ curl localhost:1026/version 
{ 
    "orion" : { 
    "version" : "0.28.0-next", 
    "uptime" : "0 d, 0 h, 0 m, 6 s", 
    "git_hash" : "067e13618c247daa4af61f82d7831f3015d9eb5d", 
    "compile_time" : "Mon Mar 14 13:04:02 UTC 2016", 
    "compiled_by" : "root", 
    "compiled_in" : "838a42ae8431" 
} 
} 

kullanıyorum liman işçisi yapılandırması:

$ cat docker-compose.yml 
mongo: 
    image: mongo:2.6 
    command: --smallfiles --nojournal 
orion: 
    image: fiware/orion 
    links: 
    - mongo 
    ports: 
    - "1026:1026" 
    command: -dbhost mongo 

Ben orion/docker aldığım uyarı Ben abonelikleri ne zaman olduğunu: Takip ettiğim

orion_1 | [email protected]:19:14 AlarmManager.cpp[303]: Raising alarm NotificationError localhost:1028/accumulate: (curl_easy_perform failed: Couldn't connect to server) 

Değişiklikleri abonelikleri test etmek için API V1 walkthorugh. Ben mongodb ile yeni bir dockerized (sudo docker-up ve tüm bu fuzz) fiware-orion 0.28 ile yeni bir nane ile başlar. Sonra ben sadece kontrol etmek sorgu bağlamı sınamak Sonra

$ (curl localhost:1026/v1/updateContext -s -S --header 'Content-Type: application/json' \ 
>  --header 'Accept: application/json' -d @- | python -mjson.tool) <<EOF 
> { 
>  "contextElements": [ 
>   { 
>    "type": "Room", 
>    "isPattern": "false", 
>    "id": "Room1", 
>    "attributes": [ 
>     { 
>      "name": "temperature", 
>      "type": "float", 
>      "value": "23" 
>     }, 
>     { 
>      "name": "pressure", 
>      "type": "integer", 
>      "value": "720" 
>     } 
>    ] 
>   } 
>  ], 
>  "updateAction": "APPEND" 
> } 
> EOF 
{ 
    "contextResponses": [ 
     { 
      "contextElement": { 
       "attributes": [ 
        { 
         "name": "temperature", 
         "type": "float", 
         "value": "" 
        }, 
        { 
         "name": "pressure", 
         "type": "integer", 
         "value": "" 
        } 
       ], 
       "id": "Room1", 
       "isPattern": "false", 
       "type": "Room" 
      }, 
      "statusCode": { 
       "code": "200", 
       "reasonPhrase": "OK" 
      } 
     } 
    ] 
} 

Room1 kayıt

$ ./accumulator-server.py 1028 /accumulate localhost on 
verbose mode is on 
* Running on http://localhost:1028/ (Press CTRL+C to quit) 

Sonra akümülatörü başlatın:

Sonra
$ (curl localhost:1026/v1/queryContext -s -S --header 'Content-Type: application/json' \ 
>  --header 'Accept: application/json' -d @- | python -mjson.tool) <<EOF 
> { 
>  "entities": [ 
>   { 
>    "type": "Room", 
>    "isPattern": "false", 
>    "id": "Room1" 
>   } 
>  ] 
> } 
> EOF 
{ 
    "contextResponses": [ 
     { 
      "contextElement": { 
       "attributes": [ 
        { 
         "name": "pressure", 
         "type": "integer", 
         "value": "720" 
        }, 
        { 
         "name": "temperature", 
         "type": "float", 
         "value": "23" 
        } 
       ], 
       "id": "Room1", 
       "isPattern": "false", 
       "type": "Room" 
      }, 
      "statusCode": { 
       "code": "200", 
       "reasonPhrase": "OK" 
      } 
     } 
    ] 
} 

yapmam abonelik

$ (curl localhost:1026/v1/subscribeContext -s -S --header 'Content-Type: application/json' \ 
>  --header 'Accept: application/json' -d @- | python -mjson.tool) <<EOF 
> { 
>  "entities": [ 
>   { 
>    "type": "Room", 
>    "isPattern": "false", 
>    "id": "Room1" 
>   } 
>  ], 
>  "attributes": [ 
>   "pressure" 
>  ], 
>  "reference": "http://localhost:1028/accumulate", 
>  "duration": "P1M", 
>  "notifyConditions": [ 
>   { 
>    "type": "ONCHANGE", 
>    "condValues": [ 
>     "pressure" 
>    ] 
>   } 
>  ], 
>  "throttling": "PT5S" 
> } 
> EOF 
{ 
    "subscribeResponse": { 
     "duration": "P1M", 
     "subscriptionId": "570f8ac247fcf8a62722353c", 
     "throttling": "PT5S" 
    } 
} 

Bu noktada adam ual akümülatörün bir ilk güncellemeyi alabileceğini söylüyor ama gerekli değil, bu yüzden hiçbir şey almadım ama belki de sorun değil. Ya da belki değil, çünkü abonelik sorgu gönderdikten sonra, Orion'un liman işçisi diyor ki:

orion_1 | [email protected]:19:14 AlarmManager.cpp[303]: Raising alarm NotificationError localhost:1028/accumulate: (curl_easy_perform failed: Couldn't connect to server) 

Sonunda varlık güncelleştirmek ve ben akümülatör güncellemeyi almalıdır, ama yok:

$ (curl localhost:1026/v1/updateContext -s -S --header 'Content-Type: application/json' \ 
>  --header 'Accept: application/json' -d @- | python -mjson.tool) <<EOF 
> { 
>  "contextElements": [ 
>   { 
>    "type": "Room", 
>    "isPattern": "false", 
>    "id": "Room1", 
>    "attributes": [ 
>     { 
>      "name": "temperature", 
>      "type": "float", 
>      "value": "56.5" 
>     }, 
>     { 
>      "name": "pressure", 
>      "type": "integer", 
>      "value": "553" 
>     } 
>    ] 
>   } 
>  ], 
>  "updateAction": "UPDATE" 
> } 
> EOF 
{ 
    "contextResponses": [ 
     { 
      "contextElement": { 
       "attributes": [ 
        { 
         "name": "temperature", 
         "type": "float", 
         "value": "" 
        }, 
        { 
         "name": "pressure", 
         "type": "integer", 
         "value": "" 
        } 
       ], 
       "id": "Room1", 
       "isPattern": "false", 
       "type": "Room" 
      }, 
      "statusCode": { 
       "code": "200", 
       "reasonPhrase": "OK" 
      } 
     } 
    ] 
} 

Ubuntu'yu derlemek için fiware-orion almanın oldukça zor olduğunu ve bu yüzden docker'ı kullanmamın sebebini de söylemeliyim.

+0

Derleme Orion yalnızca CentOS'ta desteklenir, ancak Ubuntu'da küçük değişiklikler yapılarak yapılması çok zor olmamalıdır. – LeandroGuillen

cevap

2

Hedef aboneliğinizin URL'sini değiştirmeniz gerekebilir ("referans" özniteliği). Orion'u bir Docker'ın içinde çalıştırıyorsanız, Orion'a ait localhost, Docker'ın kendisidir ve makineniz değildir. Bu yüzden, bildirimler Docker localhost port 1028'e yükseltiliyor. Muhtemelen Docker port 1028 üzerinde herhangi bir uygulama bulunmayabilir, curl hatası alırsınız.

başka makinede birikimine sunucusunu ayarlamak veya (ngrok kullanarak örneğin) makinenizin localhost kadar tünel yapmak ve bu adrese abonelik başvurusu ayarlamak için deneyin.

3

Yanıt ifconfig üzerinde görünüyor.

$ ifconfig 
docker0 Link encap:Ethernet HWaddr 02:42:09:7b:6e:b7 
      inet addr:172.17.0.1 Bcast:0.0.0.0 Mask:255.255.0.0 
      inet6 addr: fe80::42:9ff:fe7b:6eb7/64 Scope:Link 
      UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 
      RX packets:1036 errors:0 dropped:0 overruns:0 frame:0 
      TX packets:1506 errors:0 dropped:0 overruns:0 carrier:0 
      collisions:0 txqueuelen:0 

Bu docker Orion makinesi için, ana 172.17.0.1 üzerinde olduğu anlamına gelir.

akümülatör ile başlanmalı:

$ ./accumulator-server.py 1028 /accumulate 172.17.0.1 on 

abone komutu ("referans" seçeneğini kullanarak: "http://172.17.0.1:1028/accumulate"): gibi bir şey olmalıdır

(curl localhost:1026/v1/subscribeContext -s -S --header 'Content-Type: application/json' \ 
    --header 'Accept: application/json' -d @- | python -mjson.tool) <<EOF 
{ 
    "entities": [ 
     { 
      "type": "Room", 
      "isPattern": "false", 
      "id": "Room1" 
     } 
    ], 
    "attributes": [ 
     "temperature", 
     "pressure" 
    ], 
    "reference": "http://172.17.0.1:1028/accumulate", 
    "duration": "P1M", 
    "notifyConditions": [ 
     { 
      "type": "ONCHANGE", 
      "condValues": [ 
       "temperature", 
       "pressure" 
      ] 
     } 
    ], 
    "throttling": "PT1S" 
} 
EOF 

En azından bu çözüm benim için çalışıyor

İlgili konular