调度表还可以在工作流代码中指定为对象工作流的属性。这里使用的属性语法不同于 CLI 调度表创建。这里使用了三个属性:
|
下面的代码示例说明了属性的用法。请注意,内嵌运算有助于让 offset 和 period 声明更加易读。
// Example of using Schedule definitions within a workflow var MyTextObject = { MyVersion: '1.0', MyName: 'Example 9', MyDescription: 'Example of use of Timer', Origin: 'Oracle' }; var MySchedules = [ // half hr interval { offset: 0, period: 1800, units: "seconds" }, // offset 2 days, 4hr, 30min , week interval {offset: 2*24*60*60+4*60*60+30*60, period: 604800,units: "seconds" } ]; var workflow = { name: MyTextObject.MyName, description: MyTextObject.MyDescription, version: MyTextObject.MyVersion, alert: false, setid: true, schedules: MySchedules, scheduled: true, origin: MyTextObject.Origin, execute: function () { audit('workflow started for timer; '); } } };
对象 MySchedules 中的属性 units 指定用于属性 offset 和 period 的单位类型。它们可以设置为 seconds 或 month。属性 period 指定事件的频率,offset 指定期间中的单位。在上面的示例中,第二个调度表的期间设置为一周,开始于第二天的 4:30。可以在 schedules 属性中定义多个调度表。
示例中的对象 MySchedules 使用以下三个属性:
offset(偏移)-这是调度表自 1970 年 1 月 1 日的起始偏移。偏移量以属性 "units" 定义的单位进行提供。
period(期间)-这是调度的时间间隔,也以属性 "units" 定义的单位进行指定。
units(单位)-这可以定义为秒或月。
每周调度表的起始时间是星期四。这是由于新时间定义为自 1970 年 1 月 1 日起,而这天是星期四。
示例 23 CLI 中显示的工作流调度表在上例中,第二个调度表中的时间间隔使用的起始偏移量为 2 天 + 4 小时 + 30 分钟。这导致开始日期变为 1970 年 1 月 3 日上午 4:30。此调度表将无限期地在每周六上午 4:30 执行。下面显示了 CLI 中的调度表。
<small>dory:> maintenance workflows dory:maintenance workflows> list WORKFLOW NAME OWNER SETID ORIGIN VERSION workflow-000 Configure for Oracle Solaris Cluster NFS root false Oracle Corporation 1.0.0 workflow-001 Unconfigure Oracle Solaris Cluster NFS root false Oracle Corporation 1.0.0 workflow-002 Configure for Oracle Enterprise Manager Monitoring root false Sun Microsystems, Inc. 1.1 workflow-003 Unconfigure Oracle Enterprise Manager Monitoring root false Sun Microsystems, Inc. 1.0</small>
dory:maintenance workflow-002 schedules> NAME FREQUENCY DAY HH:MM schedule-000 halfhour - --:00 schedule-001 week Saturday 04:30