例えば、レプリケーションするビューが2つあり、1つのビューが他のビューを使用している場合などです。Data VirtualTUALity Server はレプリケーションジョブのスケジュール間の依存関係を設定および使用できます。このセクションでは、Chained Schedulesの基本的なシンタックスと2種類の依存関係について説明します。

Creating a Chained Schedule

Chained SchedulesはcreateScheduleストアドプロシージャで作成されます:

CALL SYSADMIN.createSchedule"(
"jobId" => <biginteger jobId>,
"type" => 'chained',
"intervl" => 0 ,
"startDelay" => 0,
"cronExpression" => null,
"enabled" => <bool enabled>,
"chainedToScheduleId" => <biginteger chainedToScheduleId>,
"chainCondition" => <string chainCondition>,
"chainString" => <string chainString>,
"scheduleName" => NULL,
"jobUuid" => <string jobUuid>
);;

jobIdまたは を指定してください。jobUuid

このプロシージャは、単純な依存関係と複雑な依存関係の両方を持つスケジュールに共通する以下のパラメータを取ります:

To view the full table, click the expand button in its top right corner

Parameter

Description

jobId

Replication job id for which this schedule will be created

type

Type of schedule; here, it is always chained

intervl

Always 0 for this type of schedule

startDelay

Always 0 for this type of schedule

cronExpression

Always NULL for this type of schedule

enabled

Whether the schedules will actively be in use. Possible values are TRUE or FALSE

scheduleName

Name of the schedule; may be provided on schedule creation. If not provided, will be generated by the system

jobUuid

Replication job UUID for which this schedule will be created

以下のパラメータは、単純な依存関係を持つ Chained Schedules 固有のものです:

To view the full table, click the expand button in its top right corner

jobUuid and uuid parameters in SYSADMIN.createSchedule are available since v4.1

Parameter

Description

chainedToScheduleId

Identifies the schedule the new schedule will be chained to for simple dependencies. Set to NULL in case of a complex dependency.

chainCondition

Status of the chained schedule's run in case of simple dependency. Set to NULL in case of a complex dependency.

The value specifies which status is required to trigger the schedule. Possible values are as follows:

  • NULL or UNCONDITIONAL: the outcome of the other schedule can be success or failure. The chained schedule will always be triggered;
  • SUCCESS: the chained schedule will be triggered only if the previous schedule has run successfully;
  • FAILURE: the chained schedule will be triggered only if the previous schedule has failed.

Chained job schedules ignore the interim FAILED_AUTORETRY job status and will be triggered only when the job schedule gets the final SUCCESS or FAILURE status

また、複雑な依存関係を持つChained Schedulesに特有のパラメータが1つありますが、単純な依存関係を定義するためにも使用できます:

Parameter

Description

chainString

  • Defines the mode for a complex dependency (normal or atomic). Normal mode is defined by omitting any keyword for mode, while the atomic mode is defined by providing the atomic keyword for mode;
  • Identifies the schedules or jobs the new schedule will be chained to for complex dependencies. In case of a schedule, set id or uuid of of the schedule, and for a job, the id or uuid of the job with character j preceding the id. For example, chainString => '15' means chain to schedule with Id 15, while chainString => 'J15=SUCCESS' means chain to (any schedule of) the job with Id 15 which was run successfully;
  • Regardless of whether id or uuid are used to create a chained schedule in the config database, chainstring will be stored with uuid. For example chainString => 'J15=SUCCESS' will be stored as chainString => 'Jbd3c7690-677f-11ee-8c99-0242ac120002=SUCCESS' 
    where bd3c7690-677f-11ee-8c99-0242ac120002 is the uuid of the job with id 15;
  • Defines the chain condition for complex dependencies. For defining the conditions, the same values and rules apply as described for the simple dependency parameter chainCondition.
Please note that chainedToScheduleId/chainCondition and chainString are mutually exclusive. Either chainedToScheduleId/chainCondition or chainString can be used. The variant which is not used must be set to NULL in the createSchedule call.

Simple Dependency

単純な依存関係とは、スケジュールが他の1つのスケジュールやジョブに連鎖していることを意味します。以下のいずれかの方法で定義できます:

  • chainedToScheduleIdパラメータを使用してスケジュールを識別し、chainConditionで条件を定義します;
  • chainStringパラメータを使用します。

いくつか例を挙げましょう:

1. chainedToScheduleIdchainConditionパラメータを使用した単純な依存関係の作成:

CALL SYSADMIN.createSchedule(32779, 'chained', 0, 0, NULL, TRUE, 10, NULL, NULL, NULL)
 
CALL SYSADMIN.createSchedule('chained', 0, 0, NULL, TRUE, 10, 'UNCONDITIONAL', NULL, NULL, 'bd3c7690-677f-11ee-8c99-0242ac120002')

どちらのスケジュールもレプリケーション・ジョブ32779の新しいスケジュールを作成します。新しいスケジュールは、スケジュール10の結果次第。NULLUNCONDITIONALは、このプロシージャでは意味的に等しいので、両方のスクリプトは常にスケジュール番号 10 が実行されるとすぐに新しいスケジュールをトリガーします。

次の2つの例では、レプリケーションジョブが特定の結果(それぞれ成功または失敗)になった場合にのみ、新しいスケジュールがトリガーされます:

CALL SYSADMIN.createSchedule(32779, 'chained', 0, 0, NULL, TRUE, 10, 'SUCCESS', NULL, NULL)
 
CALL SYSADMIN.createSchedule('chained', 0, 0, NULL, TRUE, 10, 'FAILURE', NULL, NULL, 'bd3c7690-677f-11ee-8c99-0242ac120002')

2. chainStringパラメータを使用した単純な依存関係の作成:

CALL SYSADMIN.createSchedule(32779, 'chained', 0, 0, NULL, TRUE, NULL, NULL, 'J10', NULL)
 
CALL SYSADMIN.createSchedule(32779, 'chained', 0, 0, NULL, TRUE, NULL, NULL, 'Jbd3c7690-677f-11ee-8c99-0242ac120002=UNCONDITIONAL', NULL)

これらの呼び出し例は、chainedToScheduleIdchainConditionを使った最初の2つの例と同様に動作します。唯一の違いは、ジョブ ID とその希望する結果がchainString内で組み合わされていることです。

レプリケーション・ジョブが特定の結果をもたらした場合にのみスケジュールを起動する場合については、2つの表現方法があります:

CALL SYSADMIN.createSchedule(32779, 'chained', 0, 0, NULL, TRUE, NULL, NULL, 'J10=SUCCESS', NULL)
 
CALL SYSADMIN.createSchedule(32779, 'chained', 0, 0, NULL, TRUE, NULL, NULL, '!(Jbd3c7690-677f-11ee-8c99-0242ac120002=FAILURE)', NULL)

!(10=FAILURE)は意味的に と同じです。10=SUCCESS否定する文は括弧で囲むことに注意してください。

Complex Dependency

複雑な依存関係とは、スケジュールが複数のスケジュールやジョブに連鎖していることを意味します。これがその仕組みです:

  1. Chained Schedulesはすべての基本スケジュールからの結果を待ちます。 
  2. 連鎖スケジュールは、すべての基本スケジュールジョブの実行が適切な結果(すなわち、chainString)で終了したときに実行されます。

複雑な依存関係がどのように機能するかは、選択したモードによって異なります:ノーマルまたはアトミック

Normal Mode (Default)

これが通常モードでの複雑な依存関係の仕組みです:

  • ベーススケジュールジョブがサイクル内で複数回実行されている可能性があります。連鎖スケジュールの条件が満たされているかどうかをチェックするために、1サイクル内に到達したすべての実行状態が考慮されます。つまり、ある基本スケジュールのジョブが成功で終了し、その基本スケジュールがサイクル内で成功で1回、失敗で1回(この順番で)終了した場合、ノーマルモードで連鎖したスケジュールでは成功条件が満たされたとみなされます。
  • 新しいサイクルは、Chained Schedulesが起動したときにのみ開始されます。新しいサイクルは、Chained Schedulesに割り当てられたジョブが終了した後に開始されます。
  • resetAtomicScheduleストアドプロシージャを使用して、サイクルを手動で再起動できます。

Atomic Mode

これがアトミックモードでの複雑な依存関係の仕組みです:

  • ベーススケジュールジョブがサイクル内で複数回実行されている可能性があります。最後に実行された状態のみが、連鎖されたスケジュールの条件が満たされているかどうかをチェックするために考慮されます。そのため、ある基本スケジュールのジョブが成功で終了し、その基本スケジュールがサイクル内で成功で1回、失敗で1回(この順番で)終了した場合、not  アトミックモードの連鎖スケジュールでは成功条件が満たされたとみなされます。
  • 新しいサイクルは、走行の結果に関係なく、すべての基本スケジュールが発射されたときに開始されます。そのため、Chained Schedulesが実行されたかどうかに関係なく、すべての基本スケジュールが少なくとも1回実行された後にサイクルが再開されます。
  • 条件が満たされていないためにサイクル再起動時に起動されなかったアトミック連鎖スケジュールは、NOT_STARTED
  • resetAtomicScheduleストアドプロシージャを使用して、サイクルを手動で再起動できます。

アトミックモードを有効にするには、chainStringの先頭にatomicキーワードを追加します。

Examples

ノーマルモードとアトミックモードの違いを示す例を示します:

  • 通常モード:
CALL SYSADMIN.createSchedule(32779, 'chained', 0, 0, NULL, TRUE, NULL, NULL, '10=SUCCESS & 11=SUCCESS', NULL)
  • ATOMICモード:
CALL SYSADMIN.createSchedule(32779, 'chained', 0, 0, NULL, TRUE, NULL, NULL, 'atomic 10=SUCCESS & 11=SUCCESS', NULL)

ISの現状はこうです:

Scheduled

Result

10

SUCCESS

11

FAILURE

A new cycle starts for the atomic chained schedule; the schedule is not triggered

11

SUCCESS

A normal chained schedule is triggered, and a new cycle starts

10

SUCCESS

An atomic chained schedule is triggered, and a new cycle starts

10

FAILURE

11

SUCCESS

A normal chained schedule is triggered, and a new cycle starts

A new cycle starts for the atomic chained schedule; the schedule is not triggered

11

SUCCESS

10

SUCCESS

Both chained schedules are triggered, and new cycles start


More Examples

1. 新しいスケジュールを実行するかどうかを決定するために、サーバーから2つのスケジュールが考慮されます。Job 10とSchedules 11は両方とも正常に実行されました。Job 10とSchedule 11は必ずしも同時に実行される必要はないので、サーバーはどちらかのSchedule が終了するとすぐにその前のステータスをチェックします。ジョブ10の最後の実行が成功し、スケジュール11が初めて実行されたと仮定すると、スケジュール11が終了するとすぐに、システムは両方のスケジュールの最後のステータスをチェックします。つまり、スケジュール11が失敗して終了した場合、新しいスケジュールはスリープモードのままで、それ以外の場合に開始されます:

CALL SYSADMIN.createSchedule(32779, 'chained', 0, 0, NULL, TRUE, NULL, NULL, 'J10=SUCCESS & 11=SUCCESS', NULL)

この動作は、Chained Schedulesの実行時間に影響することに注意してください。

2. 今回も10番と11番の2つのScheduleがあり、常に成功を収めています。さらに、Schedule 10は常にxx:00とxx:30に開始し、Schedule 11は常にxx:15とxx:45に開始します。これで以下のスケジュールが作成されました:

CALL SYSADMIN.createSchedule(32779, 'chained', 0, 0, NULL, TRUE, NULL, NULL, '10=SUCCESS & 11=SUCCESS', NULL)

つのScheduleが終了するたびに、新しく作成されたScheduleがトリガーされます。したがって、新しいスケジュールは1時間に4回(xx:00、xx:15、xx:30、xx:45)運行されます。これは、非常に複雑なchainStringが使用され、スケジュールが2つ以上の他のものに依存している場合に考慮されるべきです。

3. これらの2つの例は、異なる論理演算子と連鎖条件を1つのchainStringにまとめる方法を示しています:

CALL SYSADMIN.createSchedule(32779, 'chained', 0, 0, NULL, TRUE, NULL, NULL, '!(10=SUCCESS & 11=FAILURE)', NULL)
 
CALL SYSADMIN.createSchedule(32779, 'chained', 0, 0, NULL, TRUE, NULL, NULL, '10=FAILURE | 11=SUCCESS)', NULL)

これらは同じで、スケジュール10が失敗したとき、またはスケジュール11が成功したときにトリガーされます。

4. この例では、スケジュールはスケジュール10、11、22のいずれかが失敗するとすぐにトリガーされます:

CALL SYSADMIN.createSchedule(32781, 'chained', 0, 0, NULL, TRUE, NULL, NULL, '!(10=SUCCESS & 11=SUCCESS) | 22=FAILURE', NULL)