Create a Sink for fetching data from a GenericPull Source

Post Reply
dcinbir
Posts: 3
Joined: Wed May 20, 2015 12:55 pm

Create a Sink for fetching data from a GenericPull Source

Post by dcinbir » Thu May 28, 2015 1:49 pm

Dear Dr. Grawunder,
I created in Odysseus a generic Pull source for reading the actual value from a source.

If I got it right, then the "GenericPush" source delivers the data on some external Events (by the call of "fireProcess"), the "GenericPull" delivers the data, when it is asked for it. In my case the source worked fine.

Now I wanted to create a sink using the SENDER operation, that fetches the data from this source on some external events. So the events are triggered in the sink, not the source.
I was trying to implement the transport Handler to use for this sink myself, but how can I trigger the process? It there someting like "fireProcess" for sinks?

Best regards,
Dogan Cinbir

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

Re: Create a Sink for fetching data from a GenericPull Source

Post by Marco Grawunder » Thu May 28, 2015 2:17 pm

Odysseus is data driven/push based. This means, that every operator (e.g. a source) sends it result to the following operator.

This is the same for sender. Here the sender operator get from the former operator the input. To write output in a sender just implement the send-Method. The method will be called automatically from Odysseus.

An example can be found in the AbstractFileHandler (out is here an FileOutputStream):

Code: Select all

	@Override
	public void send(byte[] message) throws IOException {
		if (writeDelaySize > 0) {
			int msgL = message.length;
			// Would message plus current buffer content exceed buffers capacity?
			if (msgL + writeBuffer.position() > writeDelaySize){
				
				dumpBuffer();
				// To avoid double writes, write content only if message does not
				// fit into buffer
				if (msgL > writeDelaySize){
					out.write(message);
				}else{
					writeBuffer.put(message);
				}
			}else{
				writeBuffer.put(message);
			}
		} else {
			out.write(message);
		}
	}

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest