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

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.

主站蜘蛛池模板: 拜泉县| 通州区| 松滋市| 龙岩市| 石城县| 界首市| 鄂托克旗| 米脂县| 如东县| 雷波县| 河北区| 蚌埠市| 黔江区| 方山县| 梁山县| 平利县| 阜新市| 澄迈县| 孝义市| 五河县| 武穴市| 阜南县| 永安市| 游戏| 怀仁县| 西乌珠穆沁旗| 临汾市| 太仆寺旗| 罗山县| 邓州市| 安阳市| 东阳市| 溧阳市| 客服| 依安县| 牟定县| 炉霍县| 垦利县| 绥棱县| 基隆市| 泌阳县|