jerrypeng commented on a change in pull request #9671:
URL: https://github.com/apache/pulsar/pull/9671#discussion_r587738396



##########
File path: 
pulsar-functions/worker/src/main/java/org/apache/pulsar/functions/worker/FunctionRuntimeManager.java
##########
@@ -452,25 +444,43 @@ public synchronized void restartFunctionInstances(String 
tenant, String namespac
                         }
                         continue;
                     }
-
-                    ComponentType componentType = 
assignment.getInstance().getFunctionMetaData().getFunctionDetails().getComponentType();
-
-                    if (ComponentType.SOURCE == componentType) {
-                        this.functionAdmin.sources().restartSource(tenant, 
namespace, functionName,
-                            assignment.getInstance().getInstanceId());
-                    } else if (ComponentType.SINK == componentType) {
-                        this.functionAdmin.sinks().restartSink(tenant, 
namespace, functionName,
-                            assignment.getInstance().getInstanceId());
-                    } else {
-                        this.functionAdmin.functions().restartFunction(tenant, 
namespace, functionName,
-                            assignment.getInstance().getInstanceId());
-                    }
+                    restartFunctionUsingPulsarAdmin(assignment, tenant, 
namespace, functionName, false);
                 }
             }
         }
         return;
     }
 
+    /**
+     * Restart the entire function or restart a single instance of the function
+     */
+    private void restartFunctionUsingPulsarAdmin(Assignment assignment, String 
tenant, String namespace,

Review comment:
       I would recommend refactoring this method to the following: 
   
   `// restarts a particular instance of the function
   private void internalRestartFunction(Assignment assignment, String tenant, 
String namespace, Integer instanceId)
   
   // restarts the whole function
   private void internalRestartFunction(Assignment assignment, String tenant, 
String namespace) {
     internalRestartFunction(assignment, tenant, namespace, null)
   }`




----------------------------------------------------------------
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]


Reply via email to