ofbiz-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jacques Le Roux (JIRA)" <j...@apache.org>
Subject [jira] [Updated] (OFBIZ-9374) Fix TemporalExpressions.Frequency to avoid moving job start times away from given freqCount raster
Date Sat, 27 May 2017 12:34:04 GMT

     [ https://issues.apache.org/jira/browse/OFBIZ-9374?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Jacques Le Roux updated OFBIZ-9374:
-----------------------------------
    Fix Version/s:     (was: Release Branch 16.11)
                   16.11.03

Hi Michael,

We don't use the "Released versions" in the "Fix Version/s" field for the pending release
but the corresponding one in "Unreleased versions". So I changed from "Release Branch R16.11"
to "16.11.03"

I know the rules are a bit complicated, I tried to explain them here https://cwiki.apache.org/confluence/display/OFBADMIN/OFBiz+Committers+Roles+and+Responsibilities#OFBizCommittersRolesandResponsibilities-ManageJIRA%27sissues

To complete: last exchange with Jacopo about it https://s.apache.org/awBU

Thanks

>  Fix TemporalExpressions.Frequency to avoid moving job start times away from given freqCount
raster
> ---------------------------------------------------------------------------------------------------
>
>                 Key: OFBIZ-9374
>                 URL: https://issues.apache.org/jira/browse/OFBIZ-9374
>             Project: OFBiz
>          Issue Type: Bug
>          Components: framework
>    Affects Versions: Trunk
>            Reporter: Tobias Laufkötter
>            Assignee: Michael Brohl
>             Fix For: Release Branch 14.12, Release Branch 15.12, 16.11.03
>
>         Attachments: OFBIZ-9374.patch
>
>
> If a job is scheduled using TemporalExpressions.Frequency the start time of the job will
gradually move forward when the excecution of the job is delayed by one or more units of the
frequency type. 
> Example: Job is set up to start at 2017-01-01 00:00:00 and run every ten minutes. One
month later due to some circumstances the job starts at 2017-02-01 00:01:01 which results
in the next execution to be scheduled at 2017-02-01 01:11:00 in stead of 2017-02-01 01:10:00.
> The reason behind this behaviour is the TemporalExpressions.Frequency#prepareCal function.
It has the purpose to jump from the first starting time to the latest possible execution of
the job. But instead it just sets it to the current time (with the precision of the chosen
frequency type) and calculates the next execution time from this point.
> {code:title=Frequencies.java}
>         protected Calendar prepareCal(Calendar cal) {
>             // Performs a "sane" skip forward in time - avoids time consuming loops
>             // like incrementing every second from Jan 1 2000 until today
>             Calendar skip = (Calendar) cal.clone();
>             skip.setTime(this.start);
>             long deltaMillis = cal.getTimeInMillis() - this.start.getTime();
>             if (deltaMillis < 1000) {
>                 return skip;
>             }
>             long divisor = deltaMillis;
>             if (this.freqType == Calendar.DAY_OF_MONTH) {
>                 divisor = 86400000;
>             } else if (this.freqType == Calendar.HOUR) {
>                 divisor = 3600000;
>             } else if (this.freqType == Calendar.MINUTE) {
>                 divisor = 60000;
>             } else if (this.freqType == Calendar.SECOND) {
>                 divisor = 1000;
>             } else {
>                 return skip;
>             }
>             float units = deltaMillis / divisor;
>             units = (units / this.freqCount) * this.freqCount;
>             skip.add(this.freqType, (int)units);
>             while (skip.after(cal)) {
>                 skip.add(this.freqType, -this.freqCount);
>             }
>             return skip;
>         }
> {code}
> The error is at {{units = (units / this.freqCount) * this.freqCount;}}. This is no operation.
What should have been done (and to me it looks like this was the intention), is a substraction
of the remainder of an integer division of {{units}} and {{this.freqCount}} to get the number
of units of the frequency type that have passed since the first start time.



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

Mime
View raw message