Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[GOBBLIN-1885] Ensure All Logged Timestamps are in UTC #3747

Merged
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@ public synchronized void scheduleJob(Properties jobProps, JobListener jobListene
protected void logNewlyScheduledJob(JobDetail job, Trigger trigger) {
Properties jobProps = (Properties) job.getJobDataMap().get(PROPERTIES_KEY);
log.info(jobSchedulerTracePrefixBuilder(jobProps) + "nextTriggerTime: {} - Job newly scheduled",
trigger.getNextFireTime().getTime());
getMillisecondsSinceEpochInUTC(trigger.getNextFireTime()));
}

protected static String jobSchedulerTracePrefixBuilder(Properties jobProps) {
Expand All @@ -467,6 +467,18 @@ protected static String jobSchedulerTracePrefixBuilder(Properties jobProps) {
jobProps.getProperty(ConfigurationKeys.FLOW_GROUP_KEY, "<<no flow group>>"));
}

/**
* Takes a given Date object and converts the timezone to UTC before returning the number of millseconds since epoch
* @param date
*/
public static long getMillisecondsSinceEpochInUTC(Date date) {
// Create a Calendar object and set it to the given Date
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
calendar.setTimeZone(TimeZone.getTimeZone("UTC"));
return calendar.getTimeInMillis();
}
umustafi marked this conversation as resolved.
Show resolved Hide resolved

@Override
public void runJob(Properties jobProps, JobListener jobListener) throws JobException {
try {
Expand Down Expand Up @@ -716,11 +728,11 @@ public void executeImpl(JobExecutionContext context) throws JobExecutionExceptio
// Obtain trigger timestamp from trigger to pass to jobProps
Trigger trigger = context.getTrigger();
// THIS current event has already fired if this method is called, so it now exists in <previousFireTime>
long triggerTimestampMillis = trigger.getPreviousFireTime().getTime();
long triggerTimestampMillis = getMillisecondsSinceEpochInUTC(trigger.getPreviousFireTime());
jobProps.setProperty(ConfigurationKeys.SCHEDULER_EVENT_TO_TRIGGER_TIMESTAMP_MILLIS_KEY,
String.valueOf(triggerTimestampMillis));
_log.info(jobSchedulerTracePrefixBuilder(jobProps) + "triggerTime: {} nextTriggerTime: {} - Job triggered by "
+ "scheduler", triggerTimestampMillis, trigger.getNextFireTime().getTime());
+ "scheduler", triggerTimestampMillis, getMillisecondsSinceEpochInUTC(trigger.getNextFireTime()));
try {
jobScheduler.runJob(jobProps, jobListener);
} catch (Throwable t) {
Expand Down