呆羊在曬太陽  
          公告
          • Y:哦,是你呀。
            X:我現在正在忙。
            Y:忙什么?
            X:呵呵,今天出太陽了,我把錢搬出來曬一曬。
            ***********************
            abc
            小叉
            很高興能結識大家!
            ***********************
          日歷
          <2006年9月>
          272829303112
          3456789
          10111213141516
          17181920212223
          24252627282930
          1234567
          統計
          • 隨筆 - 164
          • 文章 - 2
          • 評論 - 196
          • 引用 - 0

          導航

          常用鏈接

          留言簿(7)

          隨筆分類(158)

          文章分類(2)

          相冊

          log

          搜索

          •  

          積分與排名

          • 積分 - 71133
          • 排名 - 777

          最新評論

          閱讀排行榜

           

          quartz是一個高質量的任務調度軟件包。其主要組成部分為:

          Scheduler接口: quartz的執行線程,它根據Trigger決定調度時刻,根據JobDetail的說明實例化并運行Job

          JobDetail類: 可持久化的任務描述信息。任務雖然分組,但是僅用作管理標示,任務之間并無實質性關聯, 例如無法定義job chain。

          Trigger類:任務的調度策略。這里的特點是調度策略與任務描述分開,調度策略和任務描述都可以分別在Scheduler注冊,然后再關聯起來。JobDetail與Trigger的關系是一對多。

          JobDataMap: 將任務的運行時可持久化狀態信息從JobDetail類中分離出來

          Job接口: 任務的執行代碼

          StatefulJob接口: 無狀態任務對應的JobDataMap可以認為是只讀的,而有狀態的任務在多次執行過程中保留對JobDataMap所作的修改,一個后果是有狀態任務無法被并發執行。

          JobExecutionException類: 可以通過JobExecutionException調整調度程序的下一步動作
          Calendar接口: 用于從trigger的調度計劃中排除某些時間段,例如假期等。

          以上幾個部分的交互關系如下:
          class JobImpl implements Job{
          ??? public void execute(JobExecutionContext context) throws JobExecutionException{
          ??????? JobDetail detail = context.getJobDetail();
          ??????? JobDataMap dataMap = detail.getJobDataMap();
          ??????? ...
          ??? }
          }

          scheduler.addCalendar("myHolidays", holidayCalendar, false);
          trigger.setCanlendarName("myHolidays");

          JobDetail jobDetail = new JobDetail(jobName, jobGroupName, JobImpl.class);

          scheduler.scheduleJob(jobDetail, trigger);

          JobDetail可以設置如下屬性:
          1. Durability: non-durable的任務當不再與任何active trigger關聯的時候將會從scheduler中被自動刪除。
          2. Volatility: volatile的任務在scheduler的兩次啟動之間不會被持久化
          3. RequestsRecovery: 如果在執行過程中程序意外崩潰,標記為"request recovery"的任務在scheduler重起之后將會被再次執行,此時JobExecutionContext.isRecovering()返回true.

          Trigger可以設置如下屬性:
          1. misfireInstruction: 設定當trigger錯過了觸發時刻的時候需要采取的處理策略

          SimpleTrigger按照固定的時間間隔進行觸發
          startTime, endTime, repeatCount, repeatInterval

          CronTrigger按照日歷間隔進行觸發
          seconds minutes hours day-of-month month day-of-week

          在quartz內部,QuartzSchedulerThread按照時間順序選擇trigger(沒有任務優先級的概念), 然后在JobRunShell中運行Job。

          JobRunShell中的調用順序如下:

          TriggerListener.triggerFired
          ??? Called by the Scheduler when a Trigger has fired, and it's associated JobDetail is about to be executed.

          TriggerListener.vetoJobExecution
          ??? Called by the Scheduler when a Trigger has fired, and it's associated JobDetail is about to be executed.

          JobListener.jobToBeExecuted
          ??? Called by the Scheduler when a JobDetail is about to be executed (an associated Trigger has occured).

          Job.execute
          ??? Called by the Scheduler when a Trigger fires that is associated with the Job.
          ?
          JobListener.jobWasExecuted
          ??? Called by the Scheduler after a JobDetail has been executed, and be for the associated Trigger's triggered(xx) method has

          been called.

          Trigger.executionComplete
          ??? Called after the Scheduler has executed the JobDetail associated with the Trigger in order to get the final instruction

          code from the trigger.

          TriggerListener.triggerComplete
          ???? Called by the Scheduler when a Trigger has fired, it's associated JobDetail has been executed, and it's triggered(xx)

          method has been called.

          SchedulerListener.triggerFinalized [if(trigger.getNextFireTime() == null)]
          ???? Called by the Scheduler when a Trigger has reached the condition in which it will never fire again.
          posted on 2006-09-21 14:33 小叉 閱讀(284) 評論(0)  編輯  收藏

          只有注冊用戶登錄后才能發表評論。


          網站導航:
           
           
          Copyright © 小叉 Powered by: 博客園 模板提供:滬江博客
          主站蜘蛛池模板: 永泰县| 布拖县| 高邑县| 洛浦县| 安吉县| 青田县| 余庆县| 紫金县| 温泉县| 濮阳市| 巴彦淖尔市| 洞头县| 吉木萨尔县| 秦安县| 安丘市| 贡嘎县| 黄浦区| 镶黄旗| 赤壁市| 罗平县| 贵德县| 建平县| 新邵县| 黎平县| 拉萨市| 聂荣县| 饶阳县| 通榆县| 胶南市| 闽侯县| 宝鸡市| 贞丰县| 称多县| 兴文县| 珠海市| 白城市| 比如县| 雷州市| 海宁市| 那曲县| 鱼台县|