You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@oozie.apache.org by "Satish Subhashrao Saley (JIRA)" <ji...@apache.org> on 2016/11/04 21:34:58 UTC

[jira] [Created] (OOZIE-2724) coord:current resolves monthly/yearly dependencies incorrectly

Satish Subhashrao Saley created OOZIE-2724:
----------------------------------------------

             Summary: coord:current resolves monthly/yearly dependencies incorrectly
                 Key: OOZIE-2724
                 URL: https://issues.apache.org/jira/browse/OOZIE-2724
             Project: Oozie
          Issue Type: Bug
    Affects Versions: 4.2.0
            Reporter: Satish Subhashrao Saley
            Assignee: Satish Subhashrao Saley
            Priority: Critical


We calculate the difference between two dates to get the instance count. Consider a case where, {{initial instance = Thu Dec 31 16:00:00 PST 2009}} and {{effective date (nominal time) = Sun Oct 30 17:55:00 PDT 2016}}. Frequency is monthly. So the instance count would be simply number of months between these two dates. The number of months between are 81 (inclusively).  But following code returns 83. A later part of code decreases (possibly some offset deletion logic) this by 1, making it 82.
{code}
Calendar org.apache.oozie.coord.CoordELFunctions.getCurrentInstance(Date effectiveTime, int[] instanceCount, ELEvaluator eval)

...
...
            case END_OF_MONTH:
                instanceCount[0] = (int) ((effectiveTime.getTime() - datasetInitialInstance.getTime()) / MONTH_MSEC);
                break;
....
{code}
later part of code which is reducing the value by 1:
{code}
        if (instanceCount[0] > 2) {
            instanceCount[0] = (instanceCount[0] / dsFreq);
            current.add(dsTimeUnit.getCalendarUnit(), instanceCount[0] * dsFreq);
        } else {
            instanceCount[0] = 0;
        }
        while (!current.getTime().after(effectiveTime)) {
            current.add(dsTimeUnit.getCalendarUnit(), dsFreq);
            instanceCount[0]++;
        }
        current.add(dsTimeUnit.getCalendarUnit(), -dsFreq);
        instanceCount[0]--;
        return current;
{code}
This happens because there we consider only 30 number of days in a month while calculating the milliseconds in a month. It will also affect yearly jobs because leap year has 366 days.

{code}
    public static final long MONTH_MSEC = 30 * DAY_MSEC;
    public static final long YEAR_MSEC = 365 * DAY_MSEC;
{code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)