Re: Pattern for One-Entry-Multiple-Workers Problem

Gregg Wonderly <[email protected]>
Newsgroups gmane.comp.java.sun.javaspaces
Message-ID <[email protected]>
Stefan Schulz wrote:
> Hi,
>
> I am looking for a pattern to solve the following problem within
> JavaSpaces:
>
> - A Manager M writes Xi to the space.
> - Each participating Worker Wj reads Xi and produces Xij.
> - Each Wj should read a specific Xi only once.
> - Xi is written to the space, but never taken/removed.
>
> Where:
> - i and j are arbitrary numbers.
> - Xij is the result of an entry Xi processed by Worker Wj.
> - the number of produced Xi and participating Wj is not known.
> - the number of produced Xij is i x j.
>
> As far as I understood, a read on the space returns an arbitrary,
> matching entry, which (in worst case) always is the same entry. Is the
> above problem solvable within JavaSpaces at all? Or would one need
> JavaSpace05 to walk through all available matching entries and provide a
> signature/marking/logging-mechanism to check for unprocessed entries?
>
> Any help, suggestion, and reference is welcome.

If the 'i' is expressed as a public field in the entry and if it changes with a
concreate functional definition (i = i+1 for example), then you can use that
field as a filter to not get previous entries.  The reader would increment its
'filtering' 'i' value after each read to keep from reading old data.  If the
readers are managable through a UI, or JMX, then you could reset 'i' at key
moments to reprocess entries.  You could have any 'Xi' read be companied by an
'Wij' take to remove previous results so that there would be a single result in
the space.

If 'i' is unordered, or otherwise not describable by an function, then you'll
have problems.

My http://fspace.jini.org project is intended to help by providing remote
matching functions as well as executors to run inside a 'space'.  These things
might help you to do the filtering in a way that makes sense.

In general, I can't see how you'd do this in Javaspaces without using an
iterator to read all entries, and then query the space for each matching 'Wij'
and skipping the 'Xi' that already have a matching 'Wij'.

Perhaps someone else on the list has better insight?

Gregg Wonderly

===========================================================================
To unsubscribe, send email to [email protected] and include in the body
of the message "signoff JAVASPACES-USERS".  For general help, send email to
[email protected] and include in the body of the message "help".

To view past JAVASPACES-USERS postings, please see:
http://archives.java.sun.com/archives/javaspaces-users.html

JDC members can download the JavaSpaces(tm) Technology from:
http://developer.java.sun.com/developer/products/jini/
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.