2

Repost from users@apex.incubator.apache.org

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 ?

2 Answers2

5

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()
PradeepKumbhar
  • 3,361
  • 1
  • 18
  • 31
2

The operator has a life cycle. Constructor --> checkpointed state applied --> setup() --> loop {beginWindow() --> loop {process() for each input port} --> endWindow()} --> tearDown(). When an operator recovers, the cycle is the same. The checkpointed state is the state from last known checkpoint before the operator crashed.