Ruby Client and Odysseus without delay

Steffenadensis
Posts: 31
Joined: Tue Jul 29, 2014 11:42 am

Ruby Client and Odysseus without delay

Post by Steffenadensis » Tue Jul 29, 2014 3:01 pm

Hello :) ,

my Problem is, that if i start an Ruby Client on localhost, which is sendigng without an delay Strings like "12/asd/2.4/blu" the Tcp Pakages get bigger and include more then one tuple, the Odysseus Acess Operators which i tryed are not able to actually map the data into the Schema. It is because some Handlers just read the first tuple of the Tcp Pakage, or read everything but dont map it into the Schema.
Also Tuples are cut, so like the half of a Tuple is at the end of the first and the residual at the beginning of the next Pakage.

Is there any solution implemented to like connect two Pakages, to map them correctly, until know it does not work for me.

Ruby:

Code: Select all

require 'socket'

hostname = 'localhost'
port = 4000

connection = TCPSocket.new(hostname, port)
i = 0
loop {
	#sleep(1);
	begin
		connection.print "Str/2323/dsd/234/Hallo/2.4/12345678986/" + i.to_s
		i+=1
	rescue Exception=>e
		puts "coult not send"
		connection.close
	end
}
Odysseus:

Code: Select all

input = ACCESS({source='Buffer', 
wrapper='GenericPush',
transport='TcpServer1',
protocol='',
dataHandler='Tuple',options=[['port','4000']],
schema=[
['a','STRING'],
['b','INTEGER'],
['c','STRING'],
['d','INTEGER'],
['e','STRING'],
['f','FLOAT'],
['g','LONG'],
['h','LONG']
]})
Kind regards

T. Steffen

Operating system: Debian GNU/Linux 7.6 (wheezy)

User avatar
ckuka
Posts: 35
Joined: Tue Jul 29, 2014 10:55 am
Location: Shanghai, P.R. China/中国上海
Contact:

Re: Ruby Client and Odysseus without delay

Post by ckuka » Tue Jul 29, 2014 3:16 pm

The problem is the missing protocol handler that transforms the TCP packages into chucks for the data handler. Try using the CSV protocol handler and set the delimiter to "/".
kind regards / 祝好
Christian Kuka

admin
Site Admin
Posts: 5
Joined: Mon Jul 28, 2014 4:58 pm

Re: Ruby Client and Odysseus without delay

Post by admin » Tue Jul 29, 2014 3:41 pm

SimpleCSV should work here, since there are no quotation marks and it is faster :-)

http://odysseus.offis.uni-oldenburg.de: ... ol+handler

Steffenadensis
Posts: 31
Joined: Tue Jul 29, 2014 11:42 am

Re: Ruby Client and Odysseus without delay

Post by Steffenadensis » Tue Jul 29, 2014 4:44 pm

Yes i already tried that,it is not working, because there are empty fields parsed.

Code: Select all

input = ACCESS({source='Buffers', 
wrapper='GenericPush',
transport='TcpServer1',
protocol='simplecsv',
dataHandler='Tuple',
options=[['port','4000'], ['delimiter', '/']],
schema=[
['a','STRING'],
['b','STRING'],
['c','STRING'],
['d','STRING'],
['e','STRING'],
['f','STRING'],
['g','STRING'],
['h','STRING']
]})
( i changed the schema to see the values of all items )
Kind regards

T. Steffen

Operating system: Debian GNU/Linux 7.6 (wheezy)

Steffenadensis
Posts: 31
Joined: Tue Jul 29, 2014 11:42 am

Re: Ruby Client and Odysseus without delay

Post by Steffenadensis » Tue Jul 29, 2014 5:04 pm

The Option dumpEachLine.
There is nothing displayed in the Odysseus console.
Is that dump only for developing, so in Eclipse Visible? I didn't test it with Eclipse.

( dumpEachLine: Dumps lines to the console. if set to 1 each line will be dumped )

Code: Select all

#PARSER PQL
#RUNQUERY

input = ACCESS({source='Buffers', 
wrapper='GenericPush',
transport='TcpServer1',
protocol='simplecsv',
dataHandler='Tuple',
options=[['port','4000'], ['dumpEachLine','1'], ['delimiter', '/']],
schema=[
['a','STRING'],
['b','STRING'],
['c','STRING'],
['d','STRING'],
['e','STRING'],
['f','STRING'],
['g','STRING'],
['h','STRING']
]})
Kind regards

T. Steffen

Operating system: Debian GNU/Linux 7.6 (wheezy)

User avatar
Marco Grawunder
Posts: 272
Joined: Tue Jul 29, 2014 10:29 am
Location: Oldenburg, Germany
Contact:

Re: Ruby Client and Odysseus without delay

Post by Marco Grawunder » Tue Jul 29, 2014 5:41 pm

I think the problem is much easier. The cvs handler needs to know what is one object, in this case one line. So I think, you should send an end of line with println (I don't know the syntax for ruby) instead of print?

Steffenadensis
Posts: 31
Joined: Tue Jul 29, 2014 11:42 am

Re: Ruby Client and Odysseus without delay

Post by Steffenadensis » Tue Jul 29, 2014 6:10 pm

it would be -> connection.puts "Str/2323/dsd/234/Hallo/2.4/12345678986/" + i.to_s

but it do not work anyway.
Kind regards

T. Steffen

Operating system: Debian GNU/Linux 7.6 (wheezy)

User avatar
ckuka
Posts: 35
Joined: Tue Jul 29, 2014 10:55 am
Location: Shanghai, P.R. China/中国上海
Contact:

Re: Ruby Client and Odysseus without delay

Post by ckuka » Tue Jul 29, 2014 6:41 pm

Found the problem. The TCP server needs to know the length of the package in advance to build up one tuple and forward that tuple to the protocol handler. In your case, you need to put all your data into one byte array (strings have to be prefixed with their length) and then send the array prefixed with the array length to the server. An example on how to do that can be found in the bundle "de.uniol.inf.is.odysseus.generator".
kind regards / 祝好
Christian Kuka

User avatar
Marco Grawunder
Posts: 272
Joined: Tue Jul 29, 2014 10:29 am
Location: Oldenburg, Germany
Contact:

Re: Ruby Client and Odysseus without delay

Post by Marco Grawunder » Tue Jul 29, 2014 8:52 pm

Ok. I had to fix the CSV handler. Now it works in push mode correclty with the following example
Important: There must be a line break for csv based handler!
Ruby-Code

Code: Select all

require 'socket'

    hostname = 'localhost'
    port = 4000

    connection = TCPSocket.new(hostname, port)
    i = 0
    loop {
       #sleep(1);
       begin
          connection.print "Str/2323/dsd/234/Hallo/2.4/12345678986/" + i.to_s + "\n"
          i+=1
       rescue Exception=>e
          puts "coult not send"
          connection.close
       end
    }
PQL Code to retrieve values

Code: Select all

#PARSER PQL
#RUNQUERY

    input = ACCESS({
                source='Buffer',
                wrapper='GenericPush',
                transport='TcpServer',
                protocol='SimpleCSV',
                datahandler='Tuple',
                options=[['port','4000'], ['delimiter','/']],
                schema=[
                  ['a','STRING'],
                  ['b','INTEGER'],
                  ['c','STRING'],
                  ['d','INTEGER'],
                  ['e','STRING'],
                  ['f','FLOAT'],
                  ['g','LONG'],
                  ['h','LONG']
                ]              
              }            
            )

Steffenadensis
Posts: 31
Joined: Tue Jul 29, 2014 11:42 am

Re: Ruby Client and Odysseus without delay

Post by Steffenadensis » Tue Jul 29, 2014 9:26 pm

Ahhh o.k very great i will test it tomorrow ;)

To change every Client isn't an option :)
Kind regards

T. Steffen

Operating system: Debian GNU/Linux 7.6 (wheezy)

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest