You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@gobblin.apache.org by "umustafi (via GitHub)" <gi...@apache.org> on 2023/08/16 19:03:34 UTC

[GitHub] [gobblin] umustafi opened a new pull request, #3743: replace job props upon setting reminder scheduler event

umustafi opened a new pull request, #3743:
URL: https://github.com/apache/gobblin/pull/3743

   Dear Gobblin maintainers,
   
   Please accept this PR. I understand that it will not be reviewed until I have checked off all the steps below!
   
   
   ### JIRA
   - [X] My PR addresses the following [Gobblin JIRA](https://issues.apache.org/jira/browse/GOBBLIN/) issues and references them in the PR title. For example, "[GOBBLIN-XXX] My Gobblin PR"
       - https://issues.apache.org/jira/browse/GOBBLIN-1881 
   
   
   ### Description
   - [X] Here are some details about my PR, including screenshots (if applicable):
   The following error is thrown when attempting to schedule reminder events. 
   ```
   {{The job ... referenced by the trigger does not exist.","stackTrace":[
   {"index":0,"call":"storeTrigger","columnNumber":null,"fileName":"RAMJobStore.java","lineNumber":422,"nativeMethod":"0","source":"org.quartz.simpl.RAMJobStore"}
   ,
   {"index":1,"call":"scheduleJob","columnNumber":null,"fileName":"QuartzScheduler.java","lineNumber":932,"nativeMethod":"0","source":"org.quartz.core.QuartzScheduler"}
   ,
   {"index":2,"call":"scheduleJob","columnNumber":null,"fileName":"StdScheduler.java","lineNumber":258,"nativeMethod":"0","source":"org.quartz.impl.StdScheduler"}
   ,
   {"index":3,"call":"scheduleReminderForEvent","columnNumber":null,"fileName":"FlowTriggerHandler.java","lineNumber":187,"nativeMethod":"0","source":"org.apache.gobblin.service.modules.orchestration.FlowTriggerHandler"}
   ,
   {"index":4,"call":"handleTriggerEvent","columnNumber":null,"fileName":"FlowTriggerHandler.java","lineNumber":124,"nativeMethod":"0","source":"org.apache.gobblin.service.modules.orchestration.FlowTriggerHandler"}
   ,
   {"index":5,"call":"orchestrate","columnNumber":null,"fileName":"Orchestrator.java","lineNumber":267,"nativeMethod":"0","source":"org.apache.gobblin.service.modules.orchestration.Orchestrator"}
   ,{"index":6,"call":"runJob","columnNumber":null,"fileName":"GobblinServiceJobScheduler.java","lineNumber":47}}
   ```
    
   The issue above from FlowTriggerHandler reveals two problems
   
   - The job referenced is not found by scheduler -> We add a check for if this happens by searching for the jobKey within the scheduler and emit a metric. The job key is constructed with flow name/group instead of job name/group, this could be an issue for multi-hop jobs but in general should not be. Adding logs to reveal more information. 
   - Upon looking closely at the code, we also need to update the job props of the job in the scheduler to keep track of the event to set reminder for. The job props we set [here](https://jarvis.corp.linkedin.com/codesearch/result/?name=FlowTriggerHandler.java&path=gobblin-elr%2Fgobblin-service%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fgobblin%2Fservice%2Fmodules%2Forchestration&reponame=linkedin%2Fgobblin-elr#176) are never used in [createTriggerForJob](https://jarvis.corp.linkedin.com/codesearch/result/?name=JobScheduler.java&path=gobblin-elr%2Fgobblin-runtime%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fgobblin%2Fscheduler&reponame=linkedin%2Fgobblin-elr#588) We want to use `StdScheduler.scheduleJob(JobDetail jobDetail, Set<? extends Trigger> triggersForJob, boolean replace)` to replace the `jobDetail` we construct when making a reminder event.
   
   ### Tests
   - [X] My PR adds the following unit tests __OR__ does not need testing for this extremely good reason:
   
   
   ### Commits
   - [X] My commits all reference JIRA issues in their subject lines, and I have squashed multiple commits if they address the same issue. In addition, my commits follow the guidelines from "[How to write a good git commit message](http://chris.beams.io/posts/git-commit/)":
       1. Subject is separated from body by a blank line
       2. Subject is limited to 50 characters
       3. Subject does not end with a period
       4. Subject uses the imperative mood ("add", not "adding")
       5. Body wraps at 72 characters
       6. Body explains "what" and "why", not "how"
   
   


-- 
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: dev-unsubscribe@gobblin.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [gobblin] umustafi commented on a diff in pull request #3743: replace job props upon setting reminder scheduler event

Posted by "umustafi (via GitHub)" <gi...@apache.org>.
umustafi commented on code in PR #3743:
URL: https://github.com/apache/gobblin/pull/3743#discussion_r1298966366


##########
gobblin-service/src/main/java/org/apache/gobblin/service/modules/orchestration/FlowTriggerHandler.java:
##########
@@ -170,28 +174,80 @@ private void scheduleReminderForEvent(Properties jobProps, MultiActiveLeaseArbit
     // Add a small randomization to the minimum reminder wait time to avoid 'thundering herd' issue
     String cronExpression = createCronFromDelayPeriod(status.getMinimumLingerDurationMillis()
         + random.nextInt(schedulerMaxBackoffMillis));
-    jobProps.setProperty(ConfigurationKeys.JOB_SCHEDULE_KEY, cronExpression);
-    // Ensure we save the event timestamp that we're setting reminder for to have for debugging purposes
-    // in addition to the event we want to initiate
-    jobProps.setProperty(ConfigurationKeys.SCHEDULER_EVENT_TO_REVISIT_TIMESTAMP_MILLIS_KEY,
-        String.valueOf(status.getEventTimeMillis()));
-    jobProps.setProperty(ConfigurationKeys.SCHEDULER_EVENT_TO_TRIGGER_TIMESTAMP_MILLIS_KEY,
-        String.valueOf(originalEventTimeMillis));
-    JobKey key = new JobKey(flowAction.getFlowName(), flowAction.getFlowGroup());
-    // Create a new trigger for the flow in job scheduler that is set to fire at the minimum reminder wait time calculated
-    Trigger trigger = JobScheduler.createTriggerForJob(key, jobProps,
-        Optional.of(createSuffixForJobTrigger(status.getEventTimeMillis())));
+    JobKey origJobKey = new JobKey(jobProps.getProperty(ConfigurationKeys.JOB_NAME_KEY, "<<no job name>>"),
+        jobProps.getProperty(ConfigurationKeys.JOB_GROUP_KEY, "<<no job group>>"));
+    // Triggers:job have an N:1 relationship but the job properties must remain constant between both, which does not
+    // allow us to keep track of additional properties for reminder events. By reusing the same job key, we either
+    // encounter an exception that the job already exists and cannot add it to the scheduler or have to overwrite the
+    // original job properties with the reminder event schedule. Thus, we differentiate the job and trigger key from the
+    // original event.
+    JobKey newJobKey = new JobKey(origJobKey.getName() + createSuffixForJobTrigger(status.getEventTimeMillis()),
+        origJobKey.getGroup());

Review Comment:
   Included most of your suggestions in 3746. For the last one, the `Scheduler.scheduleJob` is a part of the Quartz library so I can't update that. 



-- 
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: dev-unsubscribe@gobblin.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [gobblin] phet commented on a diff in pull request #3743: replace job props upon setting reminder scheduler event

Posted by "phet (via GitHub)" <gi...@apache.org>.
phet commented on code in PR #3743:
URL: https://github.com/apache/gobblin/pull/3743#discussion_r1298904021


##########
gobblin-service/src/main/java/org/apache/gobblin/service/modules/orchestration/FlowTriggerHandler.java:
##########
@@ -170,28 +174,80 @@ private void scheduleReminderForEvent(Properties jobProps, MultiActiveLeaseArbit
     // Add a small randomization to the minimum reminder wait time to avoid 'thundering herd' issue
     String cronExpression = createCronFromDelayPeriod(status.getMinimumLingerDurationMillis()
         + random.nextInt(schedulerMaxBackoffMillis));
-    jobProps.setProperty(ConfigurationKeys.JOB_SCHEDULE_KEY, cronExpression);
-    // Ensure we save the event timestamp that we're setting reminder for to have for debugging purposes
-    // in addition to the event we want to initiate
-    jobProps.setProperty(ConfigurationKeys.SCHEDULER_EVENT_TO_REVISIT_TIMESTAMP_MILLIS_KEY,
-        String.valueOf(status.getEventTimeMillis()));
-    jobProps.setProperty(ConfigurationKeys.SCHEDULER_EVENT_TO_TRIGGER_TIMESTAMP_MILLIS_KEY,
-        String.valueOf(originalEventTimeMillis));
-    JobKey key = new JobKey(flowAction.getFlowName(), flowAction.getFlowGroup());
-    // Create a new trigger for the flow in job scheduler that is set to fire at the minimum reminder wait time calculated
-    Trigger trigger = JobScheduler.createTriggerForJob(key, jobProps,
-        Optional.of(createSuffixForJobTrigger(status.getEventTimeMillis())));
+    JobKey origJobKey = new JobKey(jobProps.getProperty(ConfigurationKeys.JOB_NAME_KEY, "<<no job name>>"),
+        jobProps.getProperty(ConfigurationKeys.JOB_GROUP_KEY, "<<no job group>>"));
+    // Triggers:job have an N:1 relationship but the job properties must remain constant between both, which does not
+    // allow us to keep track of additional properties for reminder events. By reusing the same job key, we either
+    // encounter an exception that the job already exists and cannot add it to the scheduler or have to overwrite the
+    // original job properties with the reminder event schedule. Thus, we differentiate the job and trigger key from the
+    // original event.
+    JobKey newJobKey = new JobKey(origJobKey.getName() + createSuffixForJobTrigger(status.getEventTimeMillis()),
+        origJobKey.getGroup());

Review Comment:
   the best code is skimmable, and this is not, because there's too much to visually parse.  raise the level of abstraction, until each method call sings out its single immediately recognizable purpose.
   
   e.g. if we encapsulate the reaching inside of this object and that, which is so prevalent here, it would read:
   ```
   JobKey triggerJobKey = JobKey.fromJobProps(jobProperties);
   try {
       if (!this.schedulerService.getScheduler().checkExists(triggerJobKey)) {
           ...
       }
       JobDetailImpl jobDetail = updatePropsInJobDetail(triggerJobKey, status, originalEventTimeMillis);
       log.info("Flow Trigger Handler - [{}, eventTimestamp: {}] -  attempting to schedule reminder for event {}",
           flowAction, originalEventTimeMillis, status.getEventTimeMillis();
       JobKey reminderJobKey = calcReminderJobKey(status, triggerJobKey);
       Trigger reminderTrigger = this.schedulerService.scheduleJob(reminderJobKey, jobDetail);
       log.info(...)
   }
   ```
   NOTES:
   ```
   a. updatePropsInJobDetail - change return type to avoid cast; callee accesses this.schedulerMaxBackoffMillis
   b. leave the `getNextFireTime()` off the "about to call" logging, and only include that in the "succeeded" log line (if in fact we really need both)
   c. scheduleJob - new method that also encapsulates creating the `Trigger`; so we can log `.getNextFireTime(), that is returned
   ```
   up to you if you have the time RN... but this is what to aim for :)
   
   



-- 
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: dev-unsubscribe@gobblin.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [gobblin] phet commented on a diff in pull request #3743: replace job props upon setting reminder scheduler event

Posted by "phet (via GitHub)" <gi...@apache.org>.
phet commented on code in PR #3743:
URL: https://github.com/apache/gobblin/pull/3743#discussion_r1298887184


##########
gobblin-service/src/main/java/org/apache/gobblin/service/modules/orchestration/FlowTriggerHandler.java:
##########
@@ -170,28 +174,80 @@ private void scheduleReminderForEvent(Properties jobProps, MultiActiveLeaseArbit
     // Add a small randomization to the minimum reminder wait time to avoid 'thundering herd' issue
     String cronExpression = createCronFromDelayPeriod(status.getMinimumLingerDurationMillis()
         + random.nextInt(schedulerMaxBackoffMillis));
-    jobProps.setProperty(ConfigurationKeys.JOB_SCHEDULE_KEY, cronExpression);
-    // Ensure we save the event timestamp that we're setting reminder for to have for debugging purposes
-    // in addition to the event we want to initiate
-    jobProps.setProperty(ConfigurationKeys.SCHEDULER_EVENT_TO_REVISIT_TIMESTAMP_MILLIS_KEY,
-        String.valueOf(status.getEventTimeMillis()));
-    jobProps.setProperty(ConfigurationKeys.SCHEDULER_EVENT_TO_TRIGGER_TIMESTAMP_MILLIS_KEY,
-        String.valueOf(originalEventTimeMillis));
-    JobKey key = new JobKey(flowAction.getFlowName(), flowAction.getFlowGroup());
-    // Create a new trigger for the flow in job scheduler that is set to fire at the minimum reminder wait time calculated
-    Trigger trigger = JobScheduler.createTriggerForJob(key, jobProps,
-        Optional.of(createSuffixForJobTrigger(status.getEventTimeMillis())));
+    JobKey origJobKey = new JobKey(jobProps.getProperty(ConfigurationKeys.JOB_NAME_KEY, "<<no job name>>"),
+        jobProps.getProperty(ConfigurationKeys.JOB_GROUP_KEY, "<<no job group>>"));
+    // Triggers:job have an N:1 relationship but the job properties must remain constant between both, which does not
+    // allow us to keep track of additional properties for reminder events. By reusing the same job key, we either
+    // encounter an exception that the job already exists and cannot add it to the scheduler or have to overwrite the
+    // original job properties with the reminder event schedule. Thus, we differentiate the job and trigger key from the
+    // original event.
+    JobKey newJobKey = new JobKey(origJobKey.getName() + createSuffixForJobTrigger(status.getEventTimeMillis()),
+        origJobKey.getGroup());
     try {
-      log.info("Flow Trigger Handler - [{}, eventTimestamp: {}] -  attempting to schedule reminder for event {} in {} millis",
+      if (!this.schedulerService.getScheduler().checkExists(origJobKey)) {
+        log.warn("Attempting to set a reminder for a job that does not exist in the scheduler. Key: {}", origJobKey);

Review Comment:
   it doesn't seem like we're actually "Attempting", but rather skipping.  if so, this logging is misleading.
   
   also, let's not create `newJobKey` (prior to this) before confirming a need for it, since we early-return here



-- 
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: dev-unsubscribe@gobblin.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [gobblin] phet commented on a diff in pull request #3743: replace job props upon setting reminder scheduler event

Posted by "phet (via GitHub)" <gi...@apache.org>.
phet commented on code in PR #3743:
URL: https://github.com/apache/gobblin/pull/3743#discussion_r1298908515


##########
gobblin-service/src/main/java/org/apache/gobblin/service/modules/orchestration/FlowTriggerHandler.java:
##########
@@ -170,28 +174,80 @@ private void scheduleReminderForEvent(Properties jobProps, MultiActiveLeaseArbit
     // Add a small randomization to the minimum reminder wait time to avoid 'thundering herd' issue
     String cronExpression = createCronFromDelayPeriod(status.getMinimumLingerDurationMillis()
         + random.nextInt(schedulerMaxBackoffMillis));
-    jobProps.setProperty(ConfigurationKeys.JOB_SCHEDULE_KEY, cronExpression);
-    // Ensure we save the event timestamp that we're setting reminder for to have for debugging purposes
-    // in addition to the event we want to initiate
-    jobProps.setProperty(ConfigurationKeys.SCHEDULER_EVENT_TO_REVISIT_TIMESTAMP_MILLIS_KEY,
-        String.valueOf(status.getEventTimeMillis()));
-    jobProps.setProperty(ConfigurationKeys.SCHEDULER_EVENT_TO_TRIGGER_TIMESTAMP_MILLIS_KEY,
-        String.valueOf(originalEventTimeMillis));
-    JobKey key = new JobKey(flowAction.getFlowName(), flowAction.getFlowGroup());
-    // Create a new trigger for the flow in job scheduler that is set to fire at the minimum reminder wait time calculated
-    Trigger trigger = JobScheduler.createTriggerForJob(key, jobProps,
-        Optional.of(createSuffixForJobTrigger(status.getEventTimeMillis())));
+    JobKey origJobKey = new JobKey(jobProps.getProperty(ConfigurationKeys.JOB_NAME_KEY, "<<no job name>>"),
+        jobProps.getProperty(ConfigurationKeys.JOB_GROUP_KEY, "<<no job group>>"));
+    // Triggers:job have an N:1 relationship but the job properties must remain constant between both, which does not
+    // allow us to keep track of additional properties for reminder events. By reusing the same job key, we either
+    // encounter an exception that the job already exists and cannot add it to the scheduler or have to overwrite the
+    // original job properties with the reminder event schedule. Thus, we differentiate the job and trigger key from the
+    // original event.
+    JobKey newJobKey = new JobKey(origJobKey.getName() + createSuffixForJobTrigger(status.getEventTimeMillis()),
+        origJobKey.getGroup());
     try {
-      log.info("Flow Trigger Handler - [{}, eventTimestamp: {}] -  attempting to schedule reminder for event {} in {} millis",
+      if (!this.schedulerService.getScheduler().checkExists(origJobKey)) {
+        log.warn("Attempting to set a reminder for a job that does not exist in the scheduler. Key: {}", origJobKey);
+        this.jobDoesNotExistInSchedulerCount.inc();
+        return;
+      }
+      JobDetailImpl jobDetail = (JobDetailImpl) updatePropsInJobDetail(origJobKey, cronExpression,
+          status.getEventTimeMillis(), originalEventTimeMillis);
+      // Create a new trigger that is set to fire at the minimum reminder wait time calculated
+      Trigger trigger = JobScheduler.createTriggerForJob(newJobKey,
+          (Properties) jobDetail.getJobDataMap().get(GobblinServiceJobScheduler.PROPERTIES_KEY), Optional.absent());
+      log.info("Flow Trigger Handler - [{}, eventTimestamp: {}] -  attempting to schedule reminder for event {} in {} "
+              + "millis", flowAction, originalEventTimeMillis, status.getEventTimeMillis(), trigger.getNextFireTime());
+      this.schedulerService.getScheduler().scheduleJob(jobDetail, trigger);
+      log.info("Flow Trigger Handler - [{}, eventTimestamp: {}] - SCHEDULED REMINDER for event {} in {} millis",

Review Comment:
   do we really need to log the same info in a before-calling and after-the-call variant?



-- 
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: dev-unsubscribe@gobblin.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [gobblin] umustafi commented on a diff in pull request #3743: replace job props upon setting reminder scheduler event

Posted by "umustafi (via GitHub)" <gi...@apache.org>.
umustafi commented on code in PR #3743:
URL: https://github.com/apache/gobblin/pull/3743#discussion_r1298966443


##########
gobblin-service/src/main/java/org/apache/gobblin/service/modules/orchestration/FlowTriggerHandler.java:
##########
@@ -170,28 +174,80 @@ private void scheduleReminderForEvent(Properties jobProps, MultiActiveLeaseArbit
     // Add a small randomization to the minimum reminder wait time to avoid 'thundering herd' issue
     String cronExpression = createCronFromDelayPeriod(status.getMinimumLingerDurationMillis()
         + random.nextInt(schedulerMaxBackoffMillis));
-    jobProps.setProperty(ConfigurationKeys.JOB_SCHEDULE_KEY, cronExpression);
-    // Ensure we save the event timestamp that we're setting reminder for to have for debugging purposes
-    // in addition to the event we want to initiate
-    jobProps.setProperty(ConfigurationKeys.SCHEDULER_EVENT_TO_REVISIT_TIMESTAMP_MILLIS_KEY,
-        String.valueOf(status.getEventTimeMillis()));
-    jobProps.setProperty(ConfigurationKeys.SCHEDULER_EVENT_TO_TRIGGER_TIMESTAMP_MILLIS_KEY,
-        String.valueOf(originalEventTimeMillis));
-    JobKey key = new JobKey(flowAction.getFlowName(), flowAction.getFlowGroup());
-    // Create a new trigger for the flow in job scheduler that is set to fire at the minimum reminder wait time calculated
-    Trigger trigger = JobScheduler.createTriggerForJob(key, jobProps,
-        Optional.of(createSuffixForJobTrigger(status.getEventTimeMillis())));
+    JobKey origJobKey = new JobKey(jobProps.getProperty(ConfigurationKeys.JOB_NAME_KEY, "<<no job name>>"),
+        jobProps.getProperty(ConfigurationKeys.JOB_GROUP_KEY, "<<no job group>>"));
+    // Triggers:job have an N:1 relationship but the job properties must remain constant between both, which does not
+    // allow us to keep track of additional properties for reminder events. By reusing the same job key, we either
+    // encounter an exception that the job already exists and cannot add it to the scheduler or have to overwrite the
+    // original job properties with the reminder event schedule. Thus, we differentiate the job and trigger key from the
+    // original event.
+    JobKey newJobKey = new JobKey(origJobKey.getName() + createSuffixForJobTrigger(status.getEventTimeMillis()),
+        origJobKey.getGroup());
     try {
-      log.info("Flow Trigger Handler - [{}, eventTimestamp: {}] -  attempting to schedule reminder for event {} in {} millis",
+      if (!this.schedulerService.getScheduler().checkExists(origJobKey)) {
+        log.warn("Attempting to set a reminder for a job that does not exist in the scheduler. Key: {}", origJobKey);
+        this.jobDoesNotExistInSchedulerCount.inc();
+        return;
+      }
+      JobDetailImpl jobDetail = (JobDetailImpl) updatePropsInJobDetail(origJobKey, cronExpression,
+          status.getEventTimeMillis(), originalEventTimeMillis);
+      // Create a new trigger that is set to fire at the minimum reminder wait time calculated
+      Trigger trigger = JobScheduler.createTriggerForJob(newJobKey,
+          (Properties) jobDetail.getJobDataMap().get(GobblinServiceJobScheduler.PROPERTIES_KEY), Optional.absent());
+      log.info("Flow Trigger Handler - [{}, eventTimestamp: {}] -  attempting to schedule reminder for event {} in {} "
+              + "millis", flowAction, originalEventTimeMillis, status.getEventTimeMillis(), trigger.getNextFireTime());
+      this.schedulerService.getScheduler().scheduleJob(jobDetail, trigger);
+      log.info("Flow Trigger Handler - [{}, eventTimestamp: {}] - SCHEDULED REMINDER for event {} in {} millis",

Review Comment:
   Leaving it in for now since I'm having trouble debugging this and verifying that it is working. I added a TODO to remove it later.



-- 
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: dev-unsubscribe@gobblin.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [gobblin] umustafi commented on a diff in pull request #3743: replace job props upon setting reminder scheduler event

Posted by "umustafi (via GitHub)" <gi...@apache.org>.
umustafi commented on code in PR #3743:
URL: https://github.com/apache/gobblin/pull/3743#discussion_r1298938201


##########
gobblin-service/src/main/java/org/apache/gobblin/service/modules/orchestration/DagManager.java:
##########
@@ -497,6 +497,7 @@ public void handleLaunchFlowEvent(DagActionStore.DagAction action) {
     FlowId flowId = action.getFlowId();
     FlowSpec spec;
     try {
+      log.info("Handle launch flow event for action: {}", action);

Review Comment:
   rebased the other PR so should be gone from it



-- 
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: dev-unsubscribe@gobblin.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [gobblin] phet commented on a diff in pull request #3743: replace job props upon setting reminder scheduler event

Posted by "phet (via GitHub)" <gi...@apache.org>.
phet commented on code in PR #3743:
URL: https://github.com/apache/gobblin/pull/3743#discussion_r1298904021


##########
gobblin-service/src/main/java/org/apache/gobblin/service/modules/orchestration/FlowTriggerHandler.java:
##########
@@ -170,28 +174,80 @@ private void scheduleReminderForEvent(Properties jobProps, MultiActiveLeaseArbit
     // Add a small randomization to the minimum reminder wait time to avoid 'thundering herd' issue
     String cronExpression = createCronFromDelayPeriod(status.getMinimumLingerDurationMillis()
         + random.nextInt(schedulerMaxBackoffMillis));
-    jobProps.setProperty(ConfigurationKeys.JOB_SCHEDULE_KEY, cronExpression);
-    // Ensure we save the event timestamp that we're setting reminder for to have for debugging purposes
-    // in addition to the event we want to initiate
-    jobProps.setProperty(ConfigurationKeys.SCHEDULER_EVENT_TO_REVISIT_TIMESTAMP_MILLIS_KEY,
-        String.valueOf(status.getEventTimeMillis()));
-    jobProps.setProperty(ConfigurationKeys.SCHEDULER_EVENT_TO_TRIGGER_TIMESTAMP_MILLIS_KEY,
-        String.valueOf(originalEventTimeMillis));
-    JobKey key = new JobKey(flowAction.getFlowName(), flowAction.getFlowGroup());
-    // Create a new trigger for the flow in job scheduler that is set to fire at the minimum reminder wait time calculated
-    Trigger trigger = JobScheduler.createTriggerForJob(key, jobProps,
-        Optional.of(createSuffixForJobTrigger(status.getEventTimeMillis())));
+    JobKey origJobKey = new JobKey(jobProps.getProperty(ConfigurationKeys.JOB_NAME_KEY, "<<no job name>>"),
+        jobProps.getProperty(ConfigurationKeys.JOB_GROUP_KEY, "<<no job group>>"));
+    // Triggers:job have an N:1 relationship but the job properties must remain constant between both, which does not
+    // allow us to keep track of additional properties for reminder events. By reusing the same job key, we either
+    // encounter an exception that the job already exists and cannot add it to the scheduler or have to overwrite the
+    // original job properties with the reminder event schedule. Thus, we differentiate the job and trigger key from the
+    // original event.
+    JobKey newJobKey = new JobKey(origJobKey.getName() + createSuffixForJobTrigger(status.getEventTimeMillis()),
+        origJobKey.getGroup());

Review Comment:
   the best code is skimmable, and this is not, because there's too much to visually parse.  raise the level of abstraction, until each method call sings out its single immediately recognizable purpose.
   
   e.g. if we encapsulate the reaching inside of this object and that, which is so prevalent here, it would read:
   ```
   JobKey triggerJobKey = JobKey.fromJobProps(jobProperties);
   try {
       if (!this.schedulerService.getScheduler().checkExists(triggerJobKey)) {
           ...
       }
       JobDetailImpl jobDetail = updatePropsInJobDetail(triggerJobKey, status, originalEventTimeMillis);
       log.info("Flow Trigger Handler - [{}, eventTimestamp: {}] -  attempting to schedule reminder for event {}",
           flowAction, originalEventTimeMillis, status.getEventTimeMillis();
       JobKey reminderJobKey = calcReminderJobKey(status, triggerJobKey);
       Trigger reminderTrigger = this.schedulerService.scheduleJob(reminderJobKey, jobDetail);
       log.info(...)
   }
   ```
   NOTES:
   ```
   a. updatePropsInJobDetail - change return type to avoid cast; callee accesses this.schedulerMaxBackoffMillis
   b. leave the `getNextFireTime()` off the "about to call" logging, and only include that in the "succeeded" log line (if in fact we really need both)
   c. scheduleJob - new method that also encapsulates creating the `Trigger`, which is returned so we can log `.getNextFireTime()`
   ```
   up to you if you have the time RN... but this is what to aim for :)
   
   



-- 
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: dev-unsubscribe@gobblin.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [gobblin] phet commented on a diff in pull request #3743: replace job props upon setting reminder scheduler event

Posted by "phet (via GitHub)" <gi...@apache.org>.
phet commented on code in PR #3743:
URL: https://github.com/apache/gobblin/pull/3743#discussion_r1298904021


##########
gobblin-service/src/main/java/org/apache/gobblin/service/modules/orchestration/FlowTriggerHandler.java:
##########
@@ -170,28 +174,80 @@ private void scheduleReminderForEvent(Properties jobProps, MultiActiveLeaseArbit
     // Add a small randomization to the minimum reminder wait time to avoid 'thundering herd' issue
     String cronExpression = createCronFromDelayPeriod(status.getMinimumLingerDurationMillis()
         + random.nextInt(schedulerMaxBackoffMillis));
-    jobProps.setProperty(ConfigurationKeys.JOB_SCHEDULE_KEY, cronExpression);
-    // Ensure we save the event timestamp that we're setting reminder for to have for debugging purposes
-    // in addition to the event we want to initiate
-    jobProps.setProperty(ConfigurationKeys.SCHEDULER_EVENT_TO_REVISIT_TIMESTAMP_MILLIS_KEY,
-        String.valueOf(status.getEventTimeMillis()));
-    jobProps.setProperty(ConfigurationKeys.SCHEDULER_EVENT_TO_TRIGGER_TIMESTAMP_MILLIS_KEY,
-        String.valueOf(originalEventTimeMillis));
-    JobKey key = new JobKey(flowAction.getFlowName(), flowAction.getFlowGroup());
-    // Create a new trigger for the flow in job scheduler that is set to fire at the minimum reminder wait time calculated
-    Trigger trigger = JobScheduler.createTriggerForJob(key, jobProps,
-        Optional.of(createSuffixForJobTrigger(status.getEventTimeMillis())));
+    JobKey origJobKey = new JobKey(jobProps.getProperty(ConfigurationKeys.JOB_NAME_KEY, "<<no job name>>"),
+        jobProps.getProperty(ConfigurationKeys.JOB_GROUP_KEY, "<<no job group>>"));
+    // Triggers:job have an N:1 relationship but the job properties must remain constant between both, which does not
+    // allow us to keep track of additional properties for reminder events. By reusing the same job key, we either
+    // encounter an exception that the job already exists and cannot add it to the scheduler or have to overwrite the
+    // original job properties with the reminder event schedule. Thus, we differentiate the job and trigger key from the
+    // original event.
+    JobKey newJobKey = new JobKey(origJobKey.getName() + createSuffixForJobTrigger(status.getEventTimeMillis()),
+        origJobKey.getGroup());

Review Comment:
   the best code is skimmable, and this is not, because there's too much to visually parse.  raise the level of abstraction, until each method call sings out its single immediately recognizable purpose.
   
   e.g. if we encapsulate the reaching inside of this object and that, which is so prevalent here, it would read:
   ```
   JobKey triggerJobKey = JobKey.fromJobProps(jobProperties);
   try {
       if (!this.schedulerService.getScheduler().checkExists(triggerJobKey)) {
           ...
       }
       JobDetailImpl jobDetail = updatePropsInJobDetail(triggerJobKey, status, originalEventTimeMillis);
       log.info("Flow Trigger Handler - [{}, eventTimestamp: {}] -  attempting to schedule reminder for event {} in {} "
           + "millis", flowAction, originalEventTimeMillis, status.getEventTimeMillis(), trigger.getNextFireTime());
       JobKey reminderJobKey = calcReminderJobKey(status, triggerJobKey);
       Trigger reminderTrigger = this.schedulerService.scheduleJob(reminderJobKey, jobDetail);
       log.info(...)
   }
   ```
   NOTES:
   ```
   a. updatePropsInJobDetail - change return type to avoid cast; callee accesses this.schedulerMaxBackoffMillis
   b. scheduleJob - new method that also encapsulates creating the `Trigger`; so we can log `.getNextFireTime(), that is returned
   ```
   up to you if you have the time RN... but this is what to aim for :)
   
   



-- 
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: dev-unsubscribe@gobblin.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [gobblin] phet commented on a diff in pull request #3743: replace job props upon setting reminder scheduler event

Posted by "phet (via GitHub)" <gi...@apache.org>.
phet commented on code in PR #3743:
URL: https://github.com/apache/gobblin/pull/3743#discussion_r1298904021


##########
gobblin-service/src/main/java/org/apache/gobblin/service/modules/orchestration/FlowTriggerHandler.java:
##########
@@ -170,28 +174,80 @@ private void scheduleReminderForEvent(Properties jobProps, MultiActiveLeaseArbit
     // Add a small randomization to the minimum reminder wait time to avoid 'thundering herd' issue
     String cronExpression = createCronFromDelayPeriod(status.getMinimumLingerDurationMillis()
         + random.nextInt(schedulerMaxBackoffMillis));
-    jobProps.setProperty(ConfigurationKeys.JOB_SCHEDULE_KEY, cronExpression);
-    // Ensure we save the event timestamp that we're setting reminder for to have for debugging purposes
-    // in addition to the event we want to initiate
-    jobProps.setProperty(ConfigurationKeys.SCHEDULER_EVENT_TO_REVISIT_TIMESTAMP_MILLIS_KEY,
-        String.valueOf(status.getEventTimeMillis()));
-    jobProps.setProperty(ConfigurationKeys.SCHEDULER_EVENT_TO_TRIGGER_TIMESTAMP_MILLIS_KEY,
-        String.valueOf(originalEventTimeMillis));
-    JobKey key = new JobKey(flowAction.getFlowName(), flowAction.getFlowGroup());
-    // Create a new trigger for the flow in job scheduler that is set to fire at the minimum reminder wait time calculated
-    Trigger trigger = JobScheduler.createTriggerForJob(key, jobProps,
-        Optional.of(createSuffixForJobTrigger(status.getEventTimeMillis())));
+    JobKey origJobKey = new JobKey(jobProps.getProperty(ConfigurationKeys.JOB_NAME_KEY, "<<no job name>>"),
+        jobProps.getProperty(ConfigurationKeys.JOB_GROUP_KEY, "<<no job group>>"));
+    // Triggers:job have an N:1 relationship but the job properties must remain constant between both, which does not
+    // allow us to keep track of additional properties for reminder events. By reusing the same job key, we either
+    // encounter an exception that the job already exists and cannot add it to the scheduler or have to overwrite the
+    // original job properties with the reminder event schedule. Thus, we differentiate the job and trigger key from the
+    // original event.
+    JobKey newJobKey = new JobKey(origJobKey.getName() + createSuffixForJobTrigger(status.getEventTimeMillis()),
+        origJobKey.getGroup());

Review Comment:
   the best code is skimmable, and this is not, because there's too much to visually parse.  raise the level of abstraction until each method call sings out its singular immediately-recognizable purpose.
   
   e.g. if we encapsulate the reaching inside of this object and that, which is so prevalent here, it would read:
   ```
   JobKey triggerJobKey = JobKey.fromJobProps(jobProperties);
   try {
       if (!this.schedulerService.getScheduler().checkExists(triggerJobKey)) {
           ...
       }
       JobDetailImpl jobDetail = updatePropsInJobDetail(triggerJobKey, status, originalEventTimeMillis);
       log.info("Flow Trigger Handler - [{}, eventTimestamp: {}] -  attempting to schedule reminder for event {}",
           flowAction, originalEventTimeMillis, status.getEventTimeMillis();
       JobKey reminderJobKey = calcReminderJobKey(status, triggerJobKey);
       Trigger reminderTrigger = this.schedulerService.scheduleJob(reminderJobKey, jobDetail);
       log.info(...)
   }
   ```
   NOTES:
   ```
   a. updatePropsInJobDetail - change return type to avoid cast; callee accesses this.schedulerMaxBackoffMillis
   b. leave the `getNextFireTime()` off the "about to call" logging, and only include that in the "succeeded" log line (if in fact we really need both)
   c. scheduleJob - new method that also encapsulates creating the `Trigger`, which is returned so we can log `.getNextFireTime()`
   ```
   up to you if you have the time RN... but this is what to aim for :)
   
   



-- 
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: dev-unsubscribe@gobblin.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [gobblin] umustafi commented on a diff in pull request #3743: replace job props upon setting reminder scheduler event

Posted by "umustafi (via GitHub)" <gi...@apache.org>.
umustafi commented on code in PR #3743:
URL: https://github.com/apache/gobblin/pull/3743#discussion_r1298939227


##########
gobblin-service/src/main/java/org/apache/gobblin/service/modules/orchestration/FlowTriggerHandler.java:
##########
@@ -170,28 +174,80 @@ private void scheduleReminderForEvent(Properties jobProps, MultiActiveLeaseArbit
     // Add a small randomization to the minimum reminder wait time to avoid 'thundering herd' issue
     String cronExpression = createCronFromDelayPeriod(status.getMinimumLingerDurationMillis()
         + random.nextInt(schedulerMaxBackoffMillis));
-    jobProps.setProperty(ConfigurationKeys.JOB_SCHEDULE_KEY, cronExpression);
-    // Ensure we save the event timestamp that we're setting reminder for to have for debugging purposes
-    // in addition to the event we want to initiate
-    jobProps.setProperty(ConfigurationKeys.SCHEDULER_EVENT_TO_REVISIT_TIMESTAMP_MILLIS_KEY,
-        String.valueOf(status.getEventTimeMillis()));
-    jobProps.setProperty(ConfigurationKeys.SCHEDULER_EVENT_TO_TRIGGER_TIMESTAMP_MILLIS_KEY,
-        String.valueOf(originalEventTimeMillis));
-    JobKey key = new JobKey(flowAction.getFlowName(), flowAction.getFlowGroup());
-    // Create a new trigger for the flow in job scheduler that is set to fire at the minimum reminder wait time calculated
-    Trigger trigger = JobScheduler.createTriggerForJob(key, jobProps,
-        Optional.of(createSuffixForJobTrigger(status.getEventTimeMillis())));
+    JobKey origJobKey = new JobKey(jobProps.getProperty(ConfigurationKeys.JOB_NAME_KEY, "<<no job name>>"),
+        jobProps.getProperty(ConfigurationKeys.JOB_GROUP_KEY, "<<no job group>>"));
+    // Triggers:job have an N:1 relationship but the job properties must remain constant between both, which does not
+    // allow us to keep track of additional properties for reminder events. By reusing the same job key, we either
+    // encounter an exception that the job already exists and cannot add it to the scheduler or have to overwrite the
+    // original job properties with the reminder event schedule. Thus, we differentiate the job and trigger key from the
+    // original event.
+    JobKey newJobKey = new JobKey(origJobKey.getName() + createSuffixForJobTrigger(status.getEventTimeMillis()),
+        origJobKey.getGroup());
     try {
-      log.info("Flow Trigger Handler - [{}, eventTimestamp: {}] -  attempting to schedule reminder for event {} in {} millis",
+      if (!this.schedulerService.getScheduler().checkExists(origJobKey)) {
+        log.warn("Attempting to set a reminder for a job that does not exist in the scheduler. Key: {}", origJobKey);

Review Comment:
   fixed both in 3746



-- 
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: dev-unsubscribe@gobblin.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [gobblin] Will-Lo merged pull request #3743: replace job props upon setting reminder scheduler event

Posted by "Will-Lo (via GitHub)" <gi...@apache.org>.
Will-Lo merged PR #3743:
URL: https://github.com/apache/gobblin/pull/3743


-- 
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: dev-unsubscribe@gobblin.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [gobblin] umustafi commented on a diff in pull request #3743: replace job props upon setting reminder scheduler event

Posted by "umustafi (via GitHub)" <gi...@apache.org>.
umustafi commented on code in PR #3743:
URL: https://github.com/apache/gobblin/pull/3743#discussion_r1298938973


##########
gobblin-service/src/main/java/org/apache/gobblin/service/modules/orchestration/FlowTriggerHandler.java:
##########
@@ -170,28 +174,80 @@ private void scheduleReminderForEvent(Properties jobProps, MultiActiveLeaseArbit
     // Add a small randomization to the minimum reminder wait time to avoid 'thundering herd' issue
     String cronExpression = createCronFromDelayPeriod(status.getMinimumLingerDurationMillis()
         + random.nextInt(schedulerMaxBackoffMillis));
-    jobProps.setProperty(ConfigurationKeys.JOB_SCHEDULE_KEY, cronExpression);
-    // Ensure we save the event timestamp that we're setting reminder for to have for debugging purposes
-    // in addition to the event we want to initiate
-    jobProps.setProperty(ConfigurationKeys.SCHEDULER_EVENT_TO_REVISIT_TIMESTAMP_MILLIS_KEY,
-        String.valueOf(status.getEventTimeMillis()));
-    jobProps.setProperty(ConfigurationKeys.SCHEDULER_EVENT_TO_TRIGGER_TIMESTAMP_MILLIS_KEY,
-        String.valueOf(originalEventTimeMillis));
-    JobKey key = new JobKey(flowAction.getFlowName(), flowAction.getFlowGroup());
-    // Create a new trigger for the flow in job scheduler that is set to fire at the minimum reminder wait time calculated
-    Trigger trigger = JobScheduler.createTriggerForJob(key, jobProps,
-        Optional.of(createSuffixForJobTrigger(status.getEventTimeMillis())));
+    JobKey origJobKey = new JobKey(jobProps.getProperty(ConfigurationKeys.JOB_NAME_KEY, "<<no job name>>"),
+        jobProps.getProperty(ConfigurationKeys.JOB_GROUP_KEY, "<<no job group>>"));
+    // Triggers:job have an N:1 relationship but the job properties must remain constant between both, which does not
+    // allow us to keep track of additional properties for reminder events. By reusing the same job key, we either
+    // encounter an exception that the job already exists and cannot add it to the scheduler or have to overwrite the
+    // original job properties with the reminder event schedule. Thus, we differentiate the job and trigger key from the

Review Comment:
   Removed in https://github.com/apache/gobblin/pull/3746 



-- 
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: dev-unsubscribe@gobblin.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [gobblin] phet commented on a diff in pull request #3743: replace job props upon setting reminder scheduler event

Posted by "phet (via GitHub)" <gi...@apache.org>.
phet commented on code in PR #3743:
URL: https://github.com/apache/gobblin/pull/3743#discussion_r1298904021


##########
gobblin-service/src/main/java/org/apache/gobblin/service/modules/orchestration/FlowTriggerHandler.java:
##########
@@ -170,28 +174,80 @@ private void scheduleReminderForEvent(Properties jobProps, MultiActiveLeaseArbit
     // Add a small randomization to the minimum reminder wait time to avoid 'thundering herd' issue
     String cronExpression = createCronFromDelayPeriod(status.getMinimumLingerDurationMillis()
         + random.nextInt(schedulerMaxBackoffMillis));
-    jobProps.setProperty(ConfigurationKeys.JOB_SCHEDULE_KEY, cronExpression);
-    // Ensure we save the event timestamp that we're setting reminder for to have for debugging purposes
-    // in addition to the event we want to initiate
-    jobProps.setProperty(ConfigurationKeys.SCHEDULER_EVENT_TO_REVISIT_TIMESTAMP_MILLIS_KEY,
-        String.valueOf(status.getEventTimeMillis()));
-    jobProps.setProperty(ConfigurationKeys.SCHEDULER_EVENT_TO_TRIGGER_TIMESTAMP_MILLIS_KEY,
-        String.valueOf(originalEventTimeMillis));
-    JobKey key = new JobKey(flowAction.getFlowName(), flowAction.getFlowGroup());
-    // Create a new trigger for the flow in job scheduler that is set to fire at the minimum reminder wait time calculated
-    Trigger trigger = JobScheduler.createTriggerForJob(key, jobProps,
-        Optional.of(createSuffixForJobTrigger(status.getEventTimeMillis())));
+    JobKey origJobKey = new JobKey(jobProps.getProperty(ConfigurationKeys.JOB_NAME_KEY, "<<no job name>>"),
+        jobProps.getProperty(ConfigurationKeys.JOB_GROUP_KEY, "<<no job group>>"));
+    // Triggers:job have an N:1 relationship but the job properties must remain constant between both, which does not
+    // allow us to keep track of additional properties for reminder events. By reusing the same job key, we either
+    // encounter an exception that the job already exists and cannot add it to the scheduler or have to overwrite the
+    // original job properties with the reminder event schedule. Thus, we differentiate the job and trigger key from the
+    // original event.
+    JobKey newJobKey = new JobKey(origJobKey.getName() + createSuffixForJobTrigger(status.getEventTimeMillis()),
+        origJobKey.getGroup());

Review Comment:
   the best code is skimmable, and this is not, because there's too much to visually parse.  raise the level of abstraction, until each method call sings out its single immediately recognizable purpose.
   
   e.g. if we encapsulate the reaching inside of this object and that, which is so prevalent here, it would read:
   ```
   JobKey triggerJobKey = JobKey.fromJobProps(jobProperties);
   try {
       if (!this.schedulerService.getScheduler().checkExists(triggerJobKey)) {
           ...
       }
       JobKey newJobKey = calcReminderJobKey(status, triggerJobKey);
       // NOTES: change return type to avoid cast; callee accesses this.schedulerMaxBackoffMillis
       JobDetailImpl jobDetail = updatePropsInJobDetail(triggerJobKey, status, originalEventTimeMillis);
       log.info("Flow Trigger Handler - [{}, eventTimestamp: {}] -  attempting to schedule reminder for event {} in {} "
           + "millis", flowAction, originalEventTimeMillis, status.getEventTimeMillis(), trigger.getNextFireTime());
       // NOTES: new method that also encapsulates creating the `Trigger`; so we can log `.getNextFireTime(), it returns that
       Trigger reminderTrigger = this.schedulerService.scheduleJob(reminderJobKey, jobDetail);
       log.info(...)
   }
   ```
   up to you if you have the time RN... but this is what to aim for :)
   
   



-- 
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: dev-unsubscribe@gobblin.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [gobblin] phet commented on a diff in pull request #3743: replace job props upon setting reminder scheduler event

Posted by "phet (via GitHub)" <gi...@apache.org>.
phet commented on code in PR #3743:
URL: https://github.com/apache/gobblin/pull/3743#discussion_r1298884575


##########
gobblin-service/src/main/java/org/apache/gobblin/service/modules/orchestration/FlowTriggerHandler.java:
##########
@@ -170,28 +174,80 @@ private void scheduleReminderForEvent(Properties jobProps, MultiActiveLeaseArbit
     // Add a small randomization to the minimum reminder wait time to avoid 'thundering herd' issue
     String cronExpression = createCronFromDelayPeriod(status.getMinimumLingerDurationMillis()
         + random.nextInt(schedulerMaxBackoffMillis));
-    jobProps.setProperty(ConfigurationKeys.JOB_SCHEDULE_KEY, cronExpression);
-    // Ensure we save the event timestamp that we're setting reminder for to have for debugging purposes
-    // in addition to the event we want to initiate
-    jobProps.setProperty(ConfigurationKeys.SCHEDULER_EVENT_TO_REVISIT_TIMESTAMP_MILLIS_KEY,
-        String.valueOf(status.getEventTimeMillis()));
-    jobProps.setProperty(ConfigurationKeys.SCHEDULER_EVENT_TO_TRIGGER_TIMESTAMP_MILLIS_KEY,
-        String.valueOf(originalEventTimeMillis));
-    JobKey key = new JobKey(flowAction.getFlowName(), flowAction.getFlowGroup());
-    // Create a new trigger for the flow in job scheduler that is set to fire at the minimum reminder wait time calculated
-    Trigger trigger = JobScheduler.createTriggerForJob(key, jobProps,
-        Optional.of(createSuffixForJobTrigger(status.getEventTimeMillis())));
+    JobKey origJobKey = new JobKey(jobProps.getProperty(ConfigurationKeys.JOB_NAME_KEY, "<<no job name>>"),
+        jobProps.getProperty(ConfigurationKeys.JOB_GROUP_KEY, "<<no job group>>"));
+    // Triggers:job have an N:1 relationship but the job properties must remain constant between both, which does not

Review Comment:
   please explain this N:1 relationship more clearly.  e.g. has there thus far been 1 trigger per scheduled job, but now we seek to also create reminder triggers?  if so tell the maintainer that multi-active reminders themselves gave rise to the N:1 relationship.
   
   ...or has it always been that way, even before multi-active?
   
   also, not necessarily related, I did notice this - https://github.com/apache/gobblin/blob/e07450f88bc2c3e2262377a5667df5e703cbf7fe/gobblin-runtime/src/main/java/org/apache/gobblin/scheduler/JobScheduler.java#L586



-- 
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: dev-unsubscribe@gobblin.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [gobblin] phet commented on a diff in pull request #3743: replace job props upon setting reminder scheduler event

Posted by "phet (via GitHub)" <gi...@apache.org>.
phet commented on code in PR #3743:
URL: https://github.com/apache/gobblin/pull/3743#discussion_r1298904021


##########
gobblin-service/src/main/java/org/apache/gobblin/service/modules/orchestration/FlowTriggerHandler.java:
##########
@@ -170,28 +174,80 @@ private void scheduleReminderForEvent(Properties jobProps, MultiActiveLeaseArbit
     // Add a small randomization to the minimum reminder wait time to avoid 'thundering herd' issue
     String cronExpression = createCronFromDelayPeriod(status.getMinimumLingerDurationMillis()
         + random.nextInt(schedulerMaxBackoffMillis));
-    jobProps.setProperty(ConfigurationKeys.JOB_SCHEDULE_KEY, cronExpression);
-    // Ensure we save the event timestamp that we're setting reminder for to have for debugging purposes
-    // in addition to the event we want to initiate
-    jobProps.setProperty(ConfigurationKeys.SCHEDULER_EVENT_TO_REVISIT_TIMESTAMP_MILLIS_KEY,
-        String.valueOf(status.getEventTimeMillis()));
-    jobProps.setProperty(ConfigurationKeys.SCHEDULER_EVENT_TO_TRIGGER_TIMESTAMP_MILLIS_KEY,
-        String.valueOf(originalEventTimeMillis));
-    JobKey key = new JobKey(flowAction.getFlowName(), flowAction.getFlowGroup());
-    // Create a new trigger for the flow in job scheduler that is set to fire at the minimum reminder wait time calculated
-    Trigger trigger = JobScheduler.createTriggerForJob(key, jobProps,
-        Optional.of(createSuffixForJobTrigger(status.getEventTimeMillis())));
+    JobKey origJobKey = new JobKey(jobProps.getProperty(ConfigurationKeys.JOB_NAME_KEY, "<<no job name>>"),
+        jobProps.getProperty(ConfigurationKeys.JOB_GROUP_KEY, "<<no job group>>"));
+    // Triggers:job have an N:1 relationship but the job properties must remain constant between both, which does not
+    // allow us to keep track of additional properties for reminder events. By reusing the same job key, we either
+    // encounter an exception that the job already exists and cannot add it to the scheduler or have to overwrite the
+    // original job properties with the reminder event schedule. Thus, we differentiate the job and trigger key from the
+    // original event.
+    JobKey newJobKey = new JobKey(origJobKey.getName() + createSuffixForJobTrigger(status.getEventTimeMillis()),
+        origJobKey.getGroup());

Review Comment:
   the best code is skimmable, and this is not, because there's too much to visually parse.  raise the level of abstraction.  each method call should sing out a single immediately recognizable concept.
   
   e.g. if we encapsulate the reaching inside of this object and that, which is so prevalent here, it would read:
   ```
   JobKey triggerJobKey = JobKey.fromJobProps(jobProperties);
   try {
       if (!this.schedulerService.getScheduler().checkExists(triggerJobKey)) {
           ...
       }
       JobKey newJobKey = calcReminderJobKey(status, triggerJobKey);
       // NOTES: change return type to avoid cast; callee accesses this.schedulerMaxBackoffMillis
       JobDetailImpl jobDetail = updatePropsInJobDetail(triggerJobKey, status, originalEventTimeMillis);
       log.info("Flow Trigger Handler - [{}, eventTimestamp: {}] -  attempting to schedule reminder for event {} in {} "
           + "millis", flowAction, originalEventTimeMillis, status.getEventTimeMillis(), trigger.getNextFireTime());
       // NOTES: new method that also encapsulates creating the `Trigger`; so we can log `.getNextFireTime(), it returns that
       Trigger reminderTrigger = this.schedulerService.scheduleJob(reminderJobKey, jobDetail);
       log.info(...)
   }
   ```
   up to you if you have the time RN... but this is what to aim for :)
   
   



##########
gobblin-service/src/main/java/org/apache/gobblin/service/modules/orchestration/FlowTriggerHandler.java:
##########
@@ -170,28 +174,80 @@ private void scheduleReminderForEvent(Properties jobProps, MultiActiveLeaseArbit
     // Add a small randomization to the minimum reminder wait time to avoid 'thundering herd' issue
     String cronExpression = createCronFromDelayPeriod(status.getMinimumLingerDurationMillis()
         + random.nextInt(schedulerMaxBackoffMillis));
-    jobProps.setProperty(ConfigurationKeys.JOB_SCHEDULE_KEY, cronExpression);
-    // Ensure we save the event timestamp that we're setting reminder for to have for debugging purposes
-    // in addition to the event we want to initiate
-    jobProps.setProperty(ConfigurationKeys.SCHEDULER_EVENT_TO_REVISIT_TIMESTAMP_MILLIS_KEY,
-        String.valueOf(status.getEventTimeMillis()));
-    jobProps.setProperty(ConfigurationKeys.SCHEDULER_EVENT_TO_TRIGGER_TIMESTAMP_MILLIS_KEY,
-        String.valueOf(originalEventTimeMillis));
-    JobKey key = new JobKey(flowAction.getFlowName(), flowAction.getFlowGroup());
-    // Create a new trigger for the flow in job scheduler that is set to fire at the minimum reminder wait time calculated
-    Trigger trigger = JobScheduler.createTriggerForJob(key, jobProps,
-        Optional.of(createSuffixForJobTrigger(status.getEventTimeMillis())));
+    JobKey origJobKey = new JobKey(jobProps.getProperty(ConfigurationKeys.JOB_NAME_KEY, "<<no job name>>"),
+        jobProps.getProperty(ConfigurationKeys.JOB_GROUP_KEY, "<<no job group>>"));
+    // Triggers:job have an N:1 relationship but the job properties must remain constant between both, which does not
+    // allow us to keep track of additional properties for reminder events. By reusing the same job key, we either
+    // encounter an exception that the job already exists and cannot add it to the scheduler or have to overwrite the
+    // original job properties with the reminder event schedule. Thus, we differentiate the job and trigger key from the
+    // original event.
+    JobKey newJobKey = new JobKey(origJobKey.getName() + createSuffixForJobTrigger(status.getEventTimeMillis()),
+        origJobKey.getGroup());
     try {
-      log.info("Flow Trigger Handler - [{}, eventTimestamp: {}] -  attempting to schedule reminder for event {} in {} millis",
+      if (!this.schedulerService.getScheduler().checkExists(origJobKey)) {
+        log.warn("Attempting to set a reminder for a job that does not exist in the scheduler. Key: {}", origJobKey);

Review Comment:
   it doesn't seem like we're actually "Attempting", but rather skipping.  if so, this logging is misleading.
   
   also, let's not create `newJobKey` before confirming a need for it.



##########
gobblin-service/src/main/java/org/apache/gobblin/service/modules/orchestration/DagManager.java:
##########
@@ -497,6 +497,7 @@ public void handleLaunchFlowEvent(DagActionStore.DagAction action) {
     FlowId flowId = action.getFlowId();
     FlowSpec spec;
     try {
+      log.info("Handle launch flow event for action: {}", action);

Review Comment:
   isn't similar logging also proposed in https://github.com/apache/gobblin/pull/3746 ?



##########
gobblin-service/src/main/java/org/apache/gobblin/service/modules/orchestration/FlowTriggerHandler.java:
##########
@@ -170,28 +174,80 @@ private void scheduleReminderForEvent(Properties jobProps, MultiActiveLeaseArbit
     // Add a small randomization to the minimum reminder wait time to avoid 'thundering herd' issue
     String cronExpression = createCronFromDelayPeriod(status.getMinimumLingerDurationMillis()
         + random.nextInt(schedulerMaxBackoffMillis));
-    jobProps.setProperty(ConfigurationKeys.JOB_SCHEDULE_KEY, cronExpression);
-    // Ensure we save the event timestamp that we're setting reminder for to have for debugging purposes
-    // in addition to the event we want to initiate
-    jobProps.setProperty(ConfigurationKeys.SCHEDULER_EVENT_TO_REVISIT_TIMESTAMP_MILLIS_KEY,
-        String.valueOf(status.getEventTimeMillis()));
-    jobProps.setProperty(ConfigurationKeys.SCHEDULER_EVENT_TO_TRIGGER_TIMESTAMP_MILLIS_KEY,
-        String.valueOf(originalEventTimeMillis));
-    JobKey key = new JobKey(flowAction.getFlowName(), flowAction.getFlowGroup());
-    // Create a new trigger for the flow in job scheduler that is set to fire at the minimum reminder wait time calculated
-    Trigger trigger = JobScheduler.createTriggerForJob(key, jobProps,
-        Optional.of(createSuffixForJobTrigger(status.getEventTimeMillis())));
+    JobKey origJobKey = new JobKey(jobProps.getProperty(ConfigurationKeys.JOB_NAME_KEY, "<<no job name>>"),
+        jobProps.getProperty(ConfigurationKeys.JOB_GROUP_KEY, "<<no job group>>"));
+    // Triggers:job have an N:1 relationship but the job properties must remain constant between both, which does not
+    // allow us to keep track of additional properties for reminder events. By reusing the same job key, we either
+    // encounter an exception that the job already exists and cannot add it to the scheduler or have to overwrite the
+    // original job properties with the reminder event schedule. Thus, we differentiate the job and trigger key from the

Review Comment:
   could we leave out "or have to overwrite..."? that wasn't ever really a viable solution was it?



##########
gobblin-service/src/main/java/org/apache/gobblin/service/modules/orchestration/FlowTriggerHandler.java:
##########
@@ -170,28 +174,80 @@ private void scheduleReminderForEvent(Properties jobProps, MultiActiveLeaseArbit
     // Add a small randomization to the minimum reminder wait time to avoid 'thundering herd' issue
     String cronExpression = createCronFromDelayPeriod(status.getMinimumLingerDurationMillis()
         + random.nextInt(schedulerMaxBackoffMillis));
-    jobProps.setProperty(ConfigurationKeys.JOB_SCHEDULE_KEY, cronExpression);
-    // Ensure we save the event timestamp that we're setting reminder for to have for debugging purposes
-    // in addition to the event we want to initiate
-    jobProps.setProperty(ConfigurationKeys.SCHEDULER_EVENT_TO_REVISIT_TIMESTAMP_MILLIS_KEY,
-        String.valueOf(status.getEventTimeMillis()));
-    jobProps.setProperty(ConfigurationKeys.SCHEDULER_EVENT_TO_TRIGGER_TIMESTAMP_MILLIS_KEY,
-        String.valueOf(originalEventTimeMillis));
-    JobKey key = new JobKey(flowAction.getFlowName(), flowAction.getFlowGroup());
-    // Create a new trigger for the flow in job scheduler that is set to fire at the minimum reminder wait time calculated
-    Trigger trigger = JobScheduler.createTriggerForJob(key, jobProps,
-        Optional.of(createSuffixForJobTrigger(status.getEventTimeMillis())));
+    JobKey origJobKey = new JobKey(jobProps.getProperty(ConfigurationKeys.JOB_NAME_KEY, "<<no job name>>"),
+        jobProps.getProperty(ConfigurationKeys.JOB_GROUP_KEY, "<<no job group>>"));
+    // Triggers:job have an N:1 relationship but the job properties must remain constant between both, which does not

Review Comment:
   please explain this N:1 relationship more clearly.  e.g. has there thus far been 1 trigger per scheduled job, but now we seek to also create reminder triggers?  in that case multi-active gave rise to the N:1 relationship.  or has it always been that way, even before multi-active?
   
   also, I did notice this - https://github.com/apache/gobblin/blob/e07450f88bc2c3e2262377a5667df5e703cbf7fe/gobblin-runtime/src/main/java/org/apache/gobblin/scheduler/JobScheduler.java#L586



-- 
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: dev-unsubscribe@gobblin.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [gobblin] phet commented on a diff in pull request #3743: replace job props upon setting reminder scheduler event

Posted by "phet (via GitHub)" <gi...@apache.org>.
phet commented on code in PR #3743:
URL: https://github.com/apache/gobblin/pull/3743#discussion_r1298904021


##########
gobblin-service/src/main/java/org/apache/gobblin/service/modules/orchestration/FlowTriggerHandler.java:
##########
@@ -170,28 +174,80 @@ private void scheduleReminderForEvent(Properties jobProps, MultiActiveLeaseArbit
     // Add a small randomization to the minimum reminder wait time to avoid 'thundering herd' issue
     String cronExpression = createCronFromDelayPeriod(status.getMinimumLingerDurationMillis()
         + random.nextInt(schedulerMaxBackoffMillis));
-    jobProps.setProperty(ConfigurationKeys.JOB_SCHEDULE_KEY, cronExpression);
-    // Ensure we save the event timestamp that we're setting reminder for to have for debugging purposes
-    // in addition to the event we want to initiate
-    jobProps.setProperty(ConfigurationKeys.SCHEDULER_EVENT_TO_REVISIT_TIMESTAMP_MILLIS_KEY,
-        String.valueOf(status.getEventTimeMillis()));
-    jobProps.setProperty(ConfigurationKeys.SCHEDULER_EVENT_TO_TRIGGER_TIMESTAMP_MILLIS_KEY,
-        String.valueOf(originalEventTimeMillis));
-    JobKey key = new JobKey(flowAction.getFlowName(), flowAction.getFlowGroup());
-    // Create a new trigger for the flow in job scheduler that is set to fire at the minimum reminder wait time calculated
-    Trigger trigger = JobScheduler.createTriggerForJob(key, jobProps,
-        Optional.of(createSuffixForJobTrigger(status.getEventTimeMillis())));
+    JobKey origJobKey = new JobKey(jobProps.getProperty(ConfigurationKeys.JOB_NAME_KEY, "<<no job name>>"),
+        jobProps.getProperty(ConfigurationKeys.JOB_GROUP_KEY, "<<no job group>>"));
+    // Triggers:job have an N:1 relationship but the job properties must remain constant between both, which does not
+    // allow us to keep track of additional properties for reminder events. By reusing the same job key, we either
+    // encounter an exception that the job already exists and cannot add it to the scheduler or have to overwrite the
+    // original job properties with the reminder event schedule. Thus, we differentiate the job and trigger key from the
+    // original event.
+    JobKey newJobKey = new JobKey(origJobKey.getName() + createSuffixForJobTrigger(status.getEventTimeMillis()),
+        origJobKey.getGroup());

Review Comment:
   the best code is skimmable, and this is not, because there's too much to visually parse.  raise the level of abstraction, until each method call sings out its single immediately recognizable purpose.
   
   e.g. if we encapsulate the reaching inside of this object and that, which is so prevalent here, it would read:
   ```
   JobKey triggerJobKey = JobKey.fromJobProps(jobProperties);
   try {
       if (!this.schedulerService.getScheduler().checkExists(triggerJobKey)) {
           ...
       }
       JobKey newJobKey = calcReminderJobKey(status, triggerJobKey);
       JobDetailImpl jobDetail = updatePropsInJobDetail(triggerJobKey, status, originalEventTimeMillis);
       log.info("Flow Trigger Handler - [{}, eventTimestamp: {}] -  attempting to schedule reminder for event {} in {} "
           + "millis", flowAction, originalEventTimeMillis, status.getEventTimeMillis(), trigger.getNextFireTime());
       Trigger reminderTrigger = this.schedulerService.scheduleJob(reminderJobKey, jobDetail);
       log.info(...)
   }
   ```
   NOTES:
   ```
   a. updatePropsInJobDetail - change return type to avoid cast; callee accesses this.schedulerMaxBackoffMillis
   b. scheduleJob - new method that also encapsulates creating the `Trigger`; so we can log `.getNextFireTime(), that is returned
   ```
   up to you if you have the time RN... but this is what to aim for :)
   
   



-- 
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: dev-unsubscribe@gobblin.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [gobblin] umustafi commented on a diff in pull request #3743: replace job props upon setting reminder scheduler event

Posted by "umustafi (via GitHub)" <gi...@apache.org>.
umustafi commented on code in PR #3743:
URL: https://github.com/apache/gobblin/pull/3743#discussion_r1298938764


##########
gobblin-service/src/main/java/org/apache/gobblin/service/modules/orchestration/FlowTriggerHandler.java:
##########
@@ -170,28 +174,80 @@ private void scheduleReminderForEvent(Properties jobProps, MultiActiveLeaseArbit
     // Add a small randomization to the minimum reminder wait time to avoid 'thundering herd' issue
     String cronExpression = createCronFromDelayPeriod(status.getMinimumLingerDurationMillis()
         + random.nextInt(schedulerMaxBackoffMillis));
-    jobProps.setProperty(ConfigurationKeys.JOB_SCHEDULE_KEY, cronExpression);
-    // Ensure we save the event timestamp that we're setting reminder for to have for debugging purposes
-    // in addition to the event we want to initiate
-    jobProps.setProperty(ConfigurationKeys.SCHEDULER_EVENT_TO_REVISIT_TIMESTAMP_MILLIS_KEY,
-        String.valueOf(status.getEventTimeMillis()));
-    jobProps.setProperty(ConfigurationKeys.SCHEDULER_EVENT_TO_TRIGGER_TIMESTAMP_MILLIS_KEY,
-        String.valueOf(originalEventTimeMillis));
-    JobKey key = new JobKey(flowAction.getFlowName(), flowAction.getFlowGroup());
-    // Create a new trigger for the flow in job scheduler that is set to fire at the minimum reminder wait time calculated
-    Trigger trigger = JobScheduler.createTriggerForJob(key, jobProps,
-        Optional.of(createSuffixForJobTrigger(status.getEventTimeMillis())));
+    JobKey origJobKey = new JobKey(jobProps.getProperty(ConfigurationKeys.JOB_NAME_KEY, "<<no job name>>"),
+        jobProps.getProperty(ConfigurationKeys.JOB_GROUP_KEY, "<<no job group>>"));
+    // Triggers:job have an N:1 relationship but the job properties must remain constant between both, which does not

Review Comment:
   I'm actually trying to explain that multiple triggers are _allowed_ for a single job in the `QuartzScheduler` but must maintain the same `jobProps`. Previously there was only one trigger for each job. Now I'm adding a second trigger which is the reminder event, and also trying to modify the `jobProps` so it does not work to re-use the original `Job` added to the `QuartzScheduler`, instead I modify the job name to indicate its a reminder event and add a new job-trigger combo. The job identifier used in `Quartz` is not utilized in our code anymore so it doesn't affect how we internally correlate the jobs. 



-- 
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: dev-unsubscribe@gobblin.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [gobblin] codecov-commenter commented on pull request #3743: replace job props upon setting reminder scheduler event

Posted by "codecov-commenter (via GitHub)" <gi...@apache.org>.
codecov-commenter commented on PR #3743:
URL: https://github.com/apache/gobblin/pull/3743#issuecomment-1681312269

   ## [Codecov](https://app.codecov.io/gh/apache/gobblin/pull/3743?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
   > Merging [#3743](https://app.codecov.io/gh/apache/gobblin/pull/3743?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) (9115b6e) into [master](https://app.codecov.io/gh/apache/gobblin/commit/69d7e0fa4df2499934462854514ddc9ddbfe7dc7?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) (69d7e0f) will **decrease** coverage by `1.67%`.
   > The diff coverage is `n/a`.
   
   ```diff
   @@             Coverage Diff              @@
   ##             master    #3743      +/-   ##
   ============================================
   - Coverage     47.09%   45.43%   -1.67%     
   + Complexity    10877     2139    -8738     
   ============================================
     Files          2147      413    -1734     
     Lines         84859    17956   -66903     
     Branches       9416     2184    -7232     
   ============================================
   - Hits          39968     8158   -31810     
   + Misses        41264     8930   -32334     
   + Partials       3627      868    -2759     
   ```
   
   
   [see 1739 files with indirect coverage changes](https://app.codecov.io/gh/apache/gobblin/pull/3743/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
   
   :mega: We’re building smart automated test selection to slash your CI/CD build times. [Learn more](https://about.codecov.io/iterative-testing/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
   


-- 
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: dev-unsubscribe@gobblin.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org