You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@samza.apache.org by Balazs Mester <bm...@basepointmedia.com> on 2014/08/26 10:15:43 UTC

initialization of a task

Hello!

Is there a best practice how to initialise a StreamTask instance if it has
a constructor that takes an argument? I would like to inject its
dependencies but I don't know how the framework will instantiate this task.

-- 
Balazs Mester
Senior Java Developer @ Basepointmedia

E-mail: bm@basepointmedia.com
Web: http://b <http://pulilab.com/>asepointmedia.com
Skype: balazs_mester

Re: initialization of a task

Posted by Jakob Homan <jg...@gmail.com>.
Hey Balazs-
   The StreamTask is initialized via reflection and so can't have anything
but the default constructor (
https://github.com/apache/incubator-samza/blob/master/samza-core/src/main/scala/org/apache/samza/container/SamzaContainer.scala#L417).
 For any resources the StreamTask needs, initialize them by implementing
the InitableTask interface(
https://github.com/apache/incubator-samza/blob/master/samza-api/src/main/java/org/apache/samza/task/InitableTask.java),
which will get called before processing begins.  You may need to refactor a
bit, but this should provide the same functionality.

-Jakob



On Tue, Aug 26, 2014 at 1:15 AM, Balazs Mester <bm...@basepointmedia.com>
wrote:

> Hello!
>
> Is there a best practice how to initialise a StreamTask instance if it has
> a constructor that takes an argument? I would like to inject its
> dependencies but I don't know how the framework will instantiate this task.
>
> --
> Balazs Mester
> Senior Java Developer @ Basepointmedia
>
> E-mail: bm@basepointmedia.com
> Web: http://b <http://pulilab.com/>asepointmedia.com
> Skype: balazs_mester
>