retries:连接失败重试的次数,如果重试该次数后还不能正常服务,则断开连接。 3 检测机制 3.1 相关数据结构 struct server { ...... int health; /* 0->rise-1 = bad; rise->rise+fall-1 = good */ int consecutive_errors; /* current number of consecutive errors */ int rise, fall; /* time in iterations */ int consecutive_errors_limit; /* number of consecutive errors that triggers an event */ short observe, onerror; /* observing mode: one of HANA_OBS_*; what to do on error: on of ANA_ONERR_* */ int inter, fastinter, downinter; /* checks: time in milliseconds */ ...... } 3.2 check流程
3.3 server状态切换条件
UP-->DOWN 初始为s->health=s->rise; if (s->health < s->rise + s->fall – 1) then s->health = s->rise + s->fall – 1; check失败:s->health-- if (s->health <= s->rise) then set_server_down(), s->health = 0;