Uploaded image for project: 'Samza'
  1. Samza
  2. SAMZA-437

Remove TaskLifecycleListener

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • None
    • 0.9.0
    • container
    • None

    Description

      We recently had a use case where we needed to wrap the Samza process() method in some code. The TaskLifecycleListener was insufficient to do this. We get a beforeProcess and afterProcess, but what we really wanted was:

      def wrapProcess(...) {
        foo.doSomething(new Wrapper() {
          task.process(...)
        })
      }
      

      We ended up just writing a wrapper task, and having the normal code defined via a subtask config:

      task.class=foo.bar.WrapperTask
      task.subtask.class=foo.bar.NormalTask
      

      Both of these tasks implement StreamTask. Samza just sees WrapperTask, and treats it like a normal task. Wrapper task instantiates the subtask, and manages its lifecycle internally.

      This approach seems superior to the TaskLifecycleListener.

      • Allows tasks to be composed multiple times.
      • Removes this complexity from the Samza framework, and makes it a concern of the job owner.
      • Allows the wrapper task to do things like filtering messages, tweaking configs and serialization, catching exceptions, etc.

      Given this, it seems that TaskLifecycleListener is a degenerate case, and adds complexity to the framework. I propose removing it.

      Attachments

        1. SAMZA-437-1.patch
          16 kB
          Chris Riccomini
        2. SAMZA-437-0.patch
          15 kB
          Chris Riccomini

        Issue Links

          Activity

            People

              criccomini Chris Riccomini
              criccomini Chris Riccomini
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: