Help Center/ DataArts Studio/ Best Practices/ Advanced Data Development Guidance/ Scheduling by Discrete Hours and Scheduling by the Nearest Job Instance
Updated on 2024-08-30 GMT+08:00

Scheduling by Discrete Hours and Scheduling by the Nearest Job Instance

Currently, DataArts Factory supports two types of job dependency policies, that is, dependency between jobs whose scheduling periods are traditional periods and dependency between jobs whose scheduling periods are natural periods.

For details about the dependency between jobs whose scheduling periods are traditional periods, see Traditional Periodic Scheduling.

For details about the dependency between jobs whose scheduling periods are natural periods, see Natural Periodic Scheduling.

Now many new rules are available for natural periodic scheduling, such as scheduling by discrete hours and scheduling by the nearest job instance. This section describes the two scheduling rules in detail.

Scheduling by Discrete Hours

Scenario 1: Jobs scheduled by discrete hours depend on all monthly, weekly, and daily jobs within calendar days, or the other way round.

Table 1 Dependency logic 1 for jobs scheduled by discrete hours

Scenario

Dependency Processing Logic

A job scheduled by discrete hours depends on a monthly job.

Check whether the job instances from 00:00 on the current day (included) to 00:00 on the next day (excluded) are successfully executed.

Example 1: Job A is scheduled at 02:00, 05:00, and 15:00. Job B is scheduled at 12:00 on the third day of each month. Job A depends on job B. If the current day is the third day of a month, the instances generated for job A at 02:00, 05:00, and 15:00 are executed only after the instance generated for job B at 12:00 is successfully executed.

Example 2: Job A is scheduled at 02:00, 05:00, and 15:00. Job B is scheduled at 12:00 on the third day of each month. Job A depends on job B. If the current day is not the third day of a month, no instance is generated for job B, and the instances generated for job A at 02:00, 05:00, and 15:00 are directly executed.

A monthly job depends on a job scheduled by discrete hours.

Check whether the job instances from 00:00 on the current day (included) to 00:00 on the next day (excluded) are successfully executed.

Example: Job A is scheduled at 02:00, 05:00, and 15:00. Job B is scheduled at 12:00 on the third day of each month. Job B depends on job A. When job B is scheduled on the third day of a month, the instance generated for it at 12:00 is scheduled only after the instances generated for job A at 02:00, 05:00, and 15:00 are successfully executed.

A job scheduled by discrete hours depends on a weekly job.

Check whether the job instances from 00:00 on the current day (included) to 00:00 on the next day (excluded) are successfully executed.

Example 1: Job A is scheduled at 02:00, 05:00, and 15:00. Job B is scheduled at 12:00 on every Monday. Job A depends on job B. If the current day is Monday, the instances generated for job A at 02:00, 05:00, and 15:00 are executed only after the instance generated for job B at 12:00 is successfully executed.

Example 2: Job A is scheduled at 02:00, 05:00, and 15:00. Job B is scheduled at 12:00 on every Monday. Job A depends on job B. If the current day is not Monday, no instance is generated for job B, and the instances generated for job A at 02:00, 05:00, and 15:00 are directly executed.

A weekly job depends on a job scheduled by discrete hours.

Check whether the job instances from 00:00 on the current day (included) to 00:00 on the next day (excluded) are successfully executed.

Example: Job A is scheduled at 02:00, 05:00, and 15:00. Job B is scheduled at 12:00 on every Monday. Job B depends on job A. When job B is scheduled on Monday, the instance generated for it at 12:00 is scheduled only after the instances generated for job A at 02:00, 05:00, and 15:00 are successfully executed.

A job scheduled by discrete hours depends on a daily job.

Check whether the job instances from 00:00 on the current day (included) to 00:00 on the next day (excluded) are successfully executed.

Example: Job A is scheduled at 02:00, 05:00, and 15:00. Job B is scheduled at 12:00 every day. Job A depends on job B. The instances generated for job A at 02:00, 05:00, and 15:00 are executed only after the instance generated for job B at 12:00 is successfully executed.

A daily job depends on a job scheduled by discrete hours.

Check whether the job instances from 00:00 on the current day (included) to 00:00 on the next day (excluded) are successfully executed.

Example: Job A is scheduled at 02:00, 05:00, and 15:00. Job B is scheduled at 12:00 every day. Job B depends on job A. The instance generated for job B at 12:00 is scheduled only after the instances generated for job A at 02:00, 05:00, and 15:00 are successfully executed.

Scenario 2: Jobs scheduled by discrete hours depend on hourly or minute-level jobs or jobs scheduled by discrete hours, or hourly or minute-level jobs depend on jobs scheduled by discrete hours. The dependency rules are as follows:

  • Rule 1: If the number of upstream and downstream tasks in the dependency relationship is the same within a calendar day, each downstream instance depends on one upstream instance.

    For example, job A depends on job B. Job A is scheduled at 03:00, 06:00, and 08:00 every day, so three instances are generated for job A in a day. Job B is scheduled every eight hours at 00:00, 08:00, and 16:00 every day, so three instances are generated for job B in a day.

    Each instance of job A (downstream) depends on an instance of job B (upstream).

    The instance generated for job A at 03:00 depends on the instance generated for job B at 00:00. The instance generated for job A at 06:00 depends on the instance generated for job B at 08:00. The instance generated for job A at 08:00 depends on the instance generated for job B at 16:00.

  • Rule 2: If the number of upstream tasks is inconsistent with that of downstream tasks in a calendar day, a periodic instance generated on the day when a downstream task runs depends on the upstream instance that is closest to the scheduling time of the periodic instance.

    The periodic instance may depend on the upstream instances in an entire time range before the periodic instance's scheduling time or the nearest instance after the periodic instance's scheduling time.

    The following figure shows an example of how the periodic instance depends on the upstream instances in an entire time range before the periodic instance's scheduling time.

    Figure 1 The periodic instance depends on the upstream instances in an entire time range before the periodic instance's scheduling time

    The following figure shows an example of how the periodic instance depends on the nearest instance after the periodic instance's scheduling time.

    Figure 2 The periodic instance depends on the nearest instance after the periodic instance's scheduling time
Table 2 Dependency logic 2 for jobs scheduled by discrete hours

Scenario

Dependency Processing Logic

A job scheduled by discrete hours depends on an hourly job.

The dependency time range is 00:00 of the current day (included) to 00:00 of the next day (excluded). Job A is scheduled by discrete hours and depends on hourly job B.

If job A and job B have the same number of instances in a day, each instance of job A depends on an instance of job B.

If the number of instances of job A is different from that of job B in a day, each instance of job A depends on the upstream instances in an entire range before the instance's scheduling time, or depends on the nearest instance after the instance's scheduling time.

An hourly job depends on a job scheduled by discrete hours.

The dependency time range is 00:00 of the current day (included) to 00:00 of the next day (excluded). Job A is an hourly job and depends on job B which is scheduled by discrete hours.

If job A and job B have the same number of instances in a day, each instance of job A depends on an instance of job B.

If the number of instances of job A is different from that of job B in a day, each instance of job A depends on the upstream instances in an entire range before the instance's scheduling time, or depends on the nearest instance after the instance's scheduling time.

A job scheduled by discrete hours depends on a minute-level job.

The dependency time range is 00:00 of the current day (included) to 00:00 of the next day (excluded). Job A is scheduled by discrete hours and depends on minute-level job B.

If job A and job B have the same number of instances in a day, each instance of job A depends on an instance of job B.

If the number of instances of job A is different from that of job B in a day, each instance of job A depends on the upstream instances in an entire range before the instance's scheduling time, or depends on the nearest instance after the instance's scheduling time.

A minute-level job depends on a job scheduled by discrete hours.

The dependency time range is 00:00 of the current day (included) to 00:00 of the next day (excluded). Job A is a minute-level job and depends on job B which is scheduled by discrete hours.

If job A and job B have the same number of instances in a day, each instance of job A depends on an instance of job B.

If the number of instances of job A is different from that of job B in a day, each instance of job A depends on the upstream instances in an entire range before the instance's scheduling time, or depends on the nearest instance after the instance's scheduling time.

A job scheduled by discrete hours depends on another job scheduled by discrete hours.

The dependency time range is 00:00 of the current day (included) to 00:00 of the next day (excluded). Job A is a job scheduled by discrete hours and depends on job B which is also scheduled by discrete hours.

If job A and job B have the same number of instances in a day, each instance of job A depends on an instance of job B.

If the number of instances of job A is different from that of job B in a day, each instance of job A depends on the upstream instances in an entire range before the instance's scheduling time, or depends on the nearest instance after the instance's scheduling time.

Scheduling by the Nearest Job Instance

This function allows you to choose the nearest job instance in the following dependency scenarios: a daily job depends on an hour job; a daily job depends on a minute-level job; an hourly job depends on a minute-level job.

Table 3 Scheduling by the nearest job instance

Scenario

Dependency Processing Logic

A daily job depends on an hourly job (depends on the latest instance).

The dependency time range is 00:00 of the current day (included) to 00:00 of the next day (excluded) and cannot cross days.

Example 1: Job A is scheduled at 08:00 every day, and job B is scheduled at the 15th minute of every hour. In this case, job A depends on the latest instance of job B, that is, the instance generated at 07:15.

Example 2: Job A is scheduled at 00:30 every day, and job B is scheduled at the 40th minute of every hour. There is no instance generated for job B before job A starts every day, so job A does not depend on any instance of job B, and is executed directly.

A daily job depends on a minute-level job (depends on the latest instance).

The dependency time range is 00:00 of the current day (included) to 00:00 of the next day (excluded) and cannot cross days.

An hourly job depends on a minute-level job (depends on the latest instance).

An instance of the hourly job depends on the latest instance of the minute-level job generated before the instance of the hourly job is generated.

Example: Job A is scheduled at the 15th minute of every hour, and job B is scheduled every 15 minutes from 01:00. The instance of job A generated at 00:15 depends on the instance of job B generated at 23:45 on the previous day. The instance of job A generated at 01:15 depends on the instance of job B generated at 01:15 on the current day.