merlimat commented on a change in pull request #5527: fix: Functions
unnecessarily restart during FunctionRuntimeManager init phase
URL: https://github.com/apache/pulsar/pull/5527#discussion_r341401565
##########
File path:
pulsar-functions/worker/src/main/java/org/apache/pulsar/functions/worker/FunctionRuntimeManager.java
##########
@@ -78,7 +78,37 @@
// All the runtime info related to functions executed by this worker
// Fully Qualified InstanceId - > FunctionRuntimeInfo
@VisibleForTesting
- Map<String, FunctionRuntimeInfo> functionRuntimeInfoMap = new
ConcurrentHashMap<>();
+ class FunctionRuntimeInfos {
+
+ private Map<String, FunctionRuntimeInfo> functionRuntimeInfoMap = new
ConcurrentHashMap<>();
+
+ public FunctionRuntimeInfo get(String fullyQualifiedInstanceId) {
+ return functionRuntimeInfoMap.get(fullyQualifiedInstanceId);
+ }
+
+ public void put(String fullyQualifiedInstanceId, FunctionRuntimeInfo
functionRuntimeInfo) {
+ if (!isInitializePhase) {
+ functionRuntimeInfoMap.put(fullyQualifiedInstanceId,
functionRuntimeInfo);
+ }
+ }
+
+ public void remove (String fullyQualifiedInstanceId) {
+ if (!isInitializePhase) {
+ functionRuntimeInfoMap.remove(fullyQualifiedInstanceId);
+ }
+ }
+
+ public Map<String, FunctionRuntimeInfo> getAll() {
+ return functionRuntimeInfoMap;
+ }
+
+ public int size() {
+ return functionRuntimeInfoMap.size();
+ }
+ }
+
+ @VisibleForTesting
+ FunctionRuntimeInfos functionRuntimeInfos = new FunctionRuntimeInfos();
Review comment:
```suggestion
final FunctionRuntimeInfos functionRuntimeInfos = new
FunctionRuntimeInfos();
```
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services