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

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.

主站蜘蛛池模板: 卓资县| 玛纳斯县| 乌鲁木齐县| 巍山| 洛阳市| 桐梓县| 渑池县| 柏乡县| 镇江市| 义乌市| 介休市| 隆化县| 邹城市| 文化| 西畴县| 皮山县| 汤原县| 休宁县| 竹北市| 山东| 临西县| 昌江| 新和县| 如东县| 灌南县| 怀安县| 邢台县| 土默特右旗| 福安市| 汝阳县| 涿州市| 枣阳市| 安义县| 保靖县| 永兴县| 乌鲁木齐县| 耿马| 保康县| 右玉县| 广德县| 南通市|