You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@storm.apache.org by Max Evers <mc...@gmail.com> on 2014/07/21 16:31:12 UTC

Prepare vs constructor

Can anyone explain the distinction between the prepare statement and the
constructor?   when is either called?   The impression I get is that the
constructor is called when the topology is first started and prepare is
called when workers are 'given' to a bolts task?  Confirm / deny?

Re: Prepare vs constructor

Posted by Aaron Zimmerman <az...@sproutsocial.com>.
Max,
  That's right.  The constructor is only called when you initialize the
topology.  Then the bolts are serialized and sent around, when they are
reinflated the prepare method is called for connecting to databases or
whatever objects need to be created that can't be serialized.   So you use
the prepare as you would use the constructor in more traditional java.

AZ


On Mon, Jul 21, 2014 at 9:31 AM, Max Evers <mc...@gmail.com> wrote:

> Can anyone explain the distinction between the prepare statement and the
> constructor?   when is either called?   The impression I get is that the
> constructor is called when the topology is first started and prepare is
> called when workers are 'given' to a bolts task?  Confirm / deny?
>