mqliang commented on a change in pull request #7099:
URL: https://github.com/apache/incubator-pinot/pull/7099#discussion_r660963823



##########
File path: 
pinot-minion/src/main/java/org/apache/pinot/minion/taskfactory/TaskFactoryRegistry.java
##########
@@ -88,24 +104,24 @@ public TaskResult run() {
                 Object executionResult = 
_taskExecutor.executeTask(pinotTaskConfig);
                 long timeSpentInNanos = System.nanoTime() - startTimeInNanos;
                 _eventObserver.notifyTaskSuccess(pinotTaskConfig, 
executionResult);
-                minionMetrics.addMeteredTableValue(taskType, 
MinionMeter.NUMBER_TASKS_COMPLETED, 1L);
-                minionMetrics.addPhaseTiming(taskType, 
MinionQueryPhase.TASK_EXECUTION, timeSpentInNanos);
+                _minionMetrics.addMeteredTableValue(taskType, 
MinionMeter.NUMBER_TASKS_COMPLETED, 1L);
+                _minionMetrics.addPhaseTiming(taskType, 
MinionQueryPhase.TASK_EXECUTION, timeSpentInNanos);

Review comment:
       @mcvsubbu I am a little bit confused. Currently `runInternal()` just 
simply call `Object executionResult = 
_taskExecutor.executeTask(pinotTaskConfig);` then try/catch all kinds of 
exceptions, and log/emit metric accordingly. If we add try/catch in `run()` and 
move the log/metric logic to the `run()` method, then it's equivalent to moving 
all logic to`run()`:
   
   ```java
      public TaskResult run() {
        try {
          Object executionResult = _taskExecutor.executeTask(pinotTaskConfig);
          // log and emit success message/metric
          return new TaskResult(TaskResult.Status.COMPLETED, "Succeeded");
        } catch (TaskCancelledException e) {
          // log and emit cancel message/metric
          return new TaskResult(TaskResult.Status.CANCELED, e.toString());
        } catch (FatalException e) {
          // log and emit fatal error message/metric
          return new TaskResult(TaskResult.Status.FATAL_FAILED, e.toString());
        } catch (Exception e) {
           // log and emit error message/metric
          return new TaskResult(TaskResult.Status.FAILED, e.toString());
        } finally {
          _minionMetrics.addValueToGlobalGauge(MinionGauge.NUMBER_OF_TASKS, 
-1L);
        }
      }
      private Object runInternal(PinotTaskConfig pinotTaskConfig)
          throws Exception {
          return  _taskExecutor.executeTask(pinotTaskConfig)
      }
   
   ```




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

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to