官术网_书友最值得收藏!

Rules

Rules in a chain describe the way the Scheduler should read the job description. A chain must have a proper starting point and end point. Steps in a chain are activated when the rules in the chain definition evaluate to true (as rules are Boolean) and mention the specific step names to be started.

Let's return to the backup example once more. We know there is only one location where it makes sense to start the job—the step that shuts down the database. How can we make the Scheduler know that? Let's start with an overview of what we know. The steps are:

  1. Always start with SHUTDOWN.
  2. If SHUTDOWN is successful, start COPYFILES.
  3. If COPYFILES is successful, start STARTUP.
  4. If STARTUP is successful, start END 0.

    This lists the optimum order of executions, but does not take into account a situation with failures. What should we do if SHUTDOWN fails? What should we do if COPYFILES fails? What should we do if STARTUP fails? If it is important that we act on a status, we should tell this to the Scheduler. With the current list of rules, we would end up in CHAIN_STALLED as soon as one of the steps fails. To prevent this we should add at least one extra rule that tells the Scheduler what to do if any one of the defined steps fail.

  5. If SHUTDOWN, or COPYFILES, or STARTUP fails, start END 1.

This last rule makes sure that our example backup always ends. It returns an error code 0 when everything succeeds and returns an error code 1 when any step in the chain fails. The error code 0 means "no error", and any other value means "failure". In this short example, it is easy to make one rule that handles all FAILED situations. When the list of steps grows, it is more likely that we forget to mention a step. In the long run, it might be smarter to give every step its own FAILED rule. In doing so, we end up with a larger list of rules but they are easier to check for completeness and should help us to prevent getting stuck in CHAIN_STALLED situations.

主站蜘蛛池模板: 长沙县| 奉贤区| 建阳市| 武安市| 安庆市| 高邮市| 深圳市| 临高县| 湄潭县| 广河县| 军事| 车险| 合山市| 诸城市| 鄂伦春自治旗| 金坛市| 鞍山市| 文山县| 烟台市| 五台县| 策勒县| 横峰县| 吐鲁番市| 涞水县| 洛川县| 京山县| 泰来县| 景洪市| 会昌县| 灯塔市| 宜春市| 商南县| 磴口县| 台山市| 庆安县| 东平县| 巴林右旗| 吉林市| 永安市| 遵义县| 郧西县|