Skip to content

RemoteWrapperPush V2

sarni edited this page Feb 25, 2014 · 2 revisions

The remote wrapper is used for communication between two different GSN instances (both instances should run exactly the same revision of GSN).

The new push based remote wrapper a rewritten version of the old remote wrapper with the difference that it is now using standard http like requests (post/get/...) instead of the xml-rpc used by the previously available wrapper. The advantage is clear, we can have any sort of client easily connecting to the new gsn.

In order to use this wrapper, one needs to have both sides using the same code base (the same svn revision).

Parameters:

  • query This is a sql query sent to perform filtering at the source. This query can only contain one single table (no joins, self-joins, inner-selects) and basic filtering (no aggregation, group by, having, database specific key words. Notice that if you don't specify the TIMED field in your query (eg. select HEAP, NON_HEAP from memorymonitorvs) then the time assigned to the data will be the current time.
  • start-time The system starts downloading the historical data. Once the historical items delivered, the data producer sends the real time data as they get produced. In the case of restful version of remote wrapper, the connection will be kept alive. If the connection is lost, the local GSN retries to connect to the remote host every 3 seconds.
  • username Used if the remote host requires authentication before accepting requests.
  • password Used if the remote host requires authentication before accepting requests.
  • local-contact-point The address of the local GSN's streaming URL. the default value is http://MyIPAddress:MyPort/streaming/
  • remote-contact-point The address of the GSN's streaming URL. the default value is http://MachineNameOrIP:Port/streaming/ (The remote contact point may optionally be specified using host and port parameters)
<address wrapper="remote">
  <predicate key="query">select * from MemoryMonitorVS</predicate>
  <predicate key="host">localhost</predicate>
  <predicate key="port">22001</predicate> 
  <predicate key="local-contact-point">http://localhost:22001/streaming/</predicate> 
  <predicate key="start-time">2009-02-06T11:56:10.004+02:00</predicate> 
</address>

To test the push service in command line you need the netcat and the curl programs.

Open another terminal and run:

nc -l -p 22222 # listening at local port 22222

Open another terminal and run the gsn. (assuming it is running on port 22001)

Open another terminal and run (replace the SOME_RANDOM_NUMBER and MY_VIRTUAL_SENSOR with appropriate values):

wget --post-data "notification-id=SOME_RANDOM_NUMBER&local-contact-point=http://localhost:22222" "http://localhost:22001/streaming/select * from MY_VIRTUAL_SENSOR/" -O -

Now you should see the output structure in the terminal in which you ran the wget command. If you check the netcat's terminal, you should see one stream element (formatted in URL encoded form) delivery to your netcat.

This push-based remote wrapper uses the protocol depicted in the following picture.

push remote wrapper

Clone this wiki locally