code: private void submitTaskStateEvents(JobState jobState) {
      // Build Job Metadata applicable for TaskStates
      ImmutableMap.Builder<String, String> jobMetadataBuilder = new ImmutableMap.Builder<>();
      jobMetadataBuilder.put(METADATA_JOB_ID, jobState.getJobId());
      jobMetadataBuilder.put(METADATA_JOB_NAME, jobState.getJobName());
      jobMetadataBuilder.put(METADATA_JOB_TRACKING_URL, jobState.getTrackingURL().or(UNKNOWN_VALUE));
      Map<String, String> jobMetadata = jobMetadataBuilder.build();
  
      // Submit event for each TaskState
      for (TaskState taskState : jobState.getTaskStates()) {
        submitTaskStateEvent(taskState, jobMetadata);
      }
    }
docs: Submits an event for each {@link TaskState} in the given {@link JobState}.