incubator-s4-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Leo Neumeyer <leoneume...@gmail.com>
Subject Re: In a PE how do I know which Keys are getting sent to me?
Date Thu, 17 Nov 2011 14:54:04 GMT
[sorry, my email bounced I sent this yesterday.]

Hi Aron,

The only representation of a Key is the KeyFinder really, S4 doesn't really
care what you call a Key as long as it is a function that returns a String
value using some logic, that's why we cannot represent it.

I don't think this is what you asked but to get the actual value of the key
that corresponds to a PE instance use the getId() method on a PE.

However, I'm not sure I understand what you are trying to do. A Stream is
associated with one and only one KeyFinder so you should be able to tell by
identify them by stream id. You can uniquely identify a stream by calling
Stream#getStreamId(). You always has a reference to the incoming streams on
your PE.

In summary, you can easily uniquely identify the Key on which an EVent was
dispatched but we don't have a representation other than reference to the
KeyFinder. The value of the key you can easily get.

Sorry if this is not what you asked.

-leo


On Wed, Nov 16, 2011 at 11:32 AM, Aron Sogor <bigman@gmail.com> wrote:

> Here is a scenario:
>
> DBSinkPE- writes the event to the database.
> DBKeySelector- based on the event id picks which db to write to.
>
> The problem is simple sharding by using modulus. In the PE I need to know
> which key the event belongs to so I can create the right jdbc url.
>
> #1 I can call the KeyFinder again... seems clunky.
> #2 I can mark the event with the Key in the KeyFinder... probably works.
>
> #3 some elegant method you will tell me...
>



-- 

Leo Neumeyer (@leoneu)

Mime
View raw message