...
In the Flink project, context-like APIs are used to provide diverse metadata and functionalities to different modules and components at runtime. Each context-like API is generally an interface annotated by @Public. Taking RuntimeContext as an example, it is an interface that consists of 27 methods. Some of these methods are used to get metadata, such as getJobId()
, getTaskName()
, getIndexOfThisSubtask()
, and others are used to access functionalities provided by framework, such as getState()
, getAccumulator()
, getCounter()
, and so on.
When new metadata needs to be provided by the RuntimeContext, the corresponding getter methods should be added in the RuntimeContext interface. HoweverWhen new metadata needs to be provided by the RuntimeContext, the corresponding getter methods should be added in the RuntimeContext interface. However, there are 12 implementation classes for the RuntimeContext interface. This means that every time a method is added to the RuntimeContext interface, the 12 implementation classes also need to add the corresponding overrided methods. This design results in extra code modification costs when providing more metadata inRuntimeContext. Similar issues exist in other context-like APIs as well.
...