sv2000 commented on a change in pull request #2667: [GOBBLIN-800] Remove the 
metric context cache from GobblinMetricsRegistry
URL: https://github.com/apache/incubator-gobblin/pull/2667#discussion_r291756656
 
 

 ##########
 File path: 
gobblin-runtime/src/main/java/org/apache/gobblin/runtime/util/TaskMetrics.java
 ##########
 @@ -61,15 +62,35 @@ public GobblinMetrics call() throws Exception {
 
   /**
    * Remove the {@link TaskMetrics} instance for the task with the given 
{@link TaskMetrics} instance.
+   * Please note this method is invoked by job driver so it won't delete any 
underlying {@link ForkMetrics}
+   * because the {@link org.apache.gobblin.runtime.fork.Fork} can be created 
on different nodes.
    *
    * @param taskState the given {@link TaskState} instance
    */
   public static void remove(TaskState taskState) {
     remove(name(taskState));
   }
 
+  /**
+   * Remove the {@link TaskMetrics} instance for the task with the given 
{@link TaskMetrics} instance.
+   * Please note that this will also delete the underlying {@link ForkMetrics} 
related to this specific task.
+   *
+   * @param task the given task instance
+   */
+  public static void remove(Task task) {
+    task.getForks().forEach(forkOpt -> {
+      remove(ForkMetrics.name(task.getTaskState(), forkOpt.get().getIndex()));
+    });
+
+    remove(name(task));
+  }
+
   private static String name(TaskState taskState) {
-    return "gobblin.metrics." + taskState.getJobId() + "." + 
taskState.getTaskId();
+    return METRICS_ID_PREFIX + taskState.getJobId() + "." + 
taskState.getTaskId();
+  }
+
+  private static String name(Task task) {
+    return METRICS_ID_PREFIX + task.getJobId() + "." + task.getTaskId();
 
 Review comment:
   return name(task.getTaskState())?

----------------------------------------------------------------
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:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to