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

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.

主站蜘蛛池模板: 博乐市| 盐山县| 永和县| 宜都市| 安多县| 泗阳县| 德江县| 正宁县| 永胜县| 深水埗区| 沁阳市| 师宗县| 舒城县| 勃利县| 海伦市| 大名县| 馆陶县| 平阴县| 综艺| 株洲县| 灵丘县| 许昌县| 赣榆县| 永川市| 清徐县| 仁怀市| 苏尼特左旗| 兴化市| 乌海市| 资阳市| 东丽区| 山丹县| 澜沧| 阿拉善盟| 自治县| 长岭县| 余江县| 昌黎县| 巴彦淖尔市| 桓台县| 梁山县|