Search code examples
apache-apex

What is the operator lifecycle in Apache Apex?


Repost from [email protected]

When is the constructor of an operator called ? The docs say once in the lifetime of an operator but I was wondering whether the definition of "lifetime" spans across start/stop/crash ( because of a coding error ) of an apex application ?


Solution

  • A given operator has the following life cycle as below. The life cycle spans over the execution period of the instance of the operator. In case of operator failure, the lifecycle starts over as below. A checkpoint of operator state occurs periodically once every few windows and it becomes the last known checkpoint in case of failure.

    → Constructor is called
    → State is applied from last known checkpoint
    → setup()
    → loop over { 
            → beginWindow()  
            → loop over {
                    → process()  
              }
            → endWindow()
      }    
    → teardown()