📄 fsa.c
字号:
else IF_FSA_ACTION(A_PE_START, do_pe_control) /* sub-system restart */ else IF_FSA_ACTION(O_CIB_RESTART, do_cib_control) else IF_FSA_ACTION(O_PE_RESTART, do_pe_control) else IF_FSA_ACTION(O_TE_RESTART, do_te_control) /* Timers *//* else IF_FSA_ACTION(O_DC_TIMER_RESTART, do_timer_control) */ else IF_FSA_ACTION(A_DC_TIMER_STOP, do_timer_control) else IF_FSA_ACTION(A_INTEGRATE_TIMER_STOP, do_timer_control) else IF_FSA_ACTION(A_INTEGRATE_TIMER_START, do_timer_control) else IF_FSA_ACTION(A_FINALIZE_TIMER_STOP, do_timer_control) else IF_FSA_ACTION(A_FINALIZE_TIMER_START, do_timer_control) /* * Highest priority actions */ else IF_FSA_ACTION(A_CIB_BUMPGEN, do_cib_invoke) else IF_FSA_ACTION(A_MSG_ROUTE, do_msg_route) else IF_FSA_ACTION(A_RECOVER, do_recover) else IF_FSA_ACTION(A_CL_JOIN_REQUEST, do_cl_join_request) else IF_FSA_ACTION(A_CL_JOIN_RESULT, do_cl_join_result) else IF_FSA_ACTION(A_SHUTDOWN_REQ, do_shutdown_req) else IF_FSA_ACTION(A_ELECTION_START, do_election_vote) else IF_FSA_ACTION(A_ELECTION_VOTE, do_election_vote) else IF_FSA_ACTION(A_ELECTION_COUNT, do_election_count_vote) /* * High priority actions * Update the cache first */ else IF_FSA_ACTION(A_CCM_UPDATE_CACHE, do_ccm_update_cache) else IF_FSA_ACTION(A_CCM_EVENT, do_ccm_event) else IF_FSA_ACTION(A_STARTED, do_started) else IF_FSA_ACTION(A_CL_JOIN_QUERY, do_cl_join_query) else IF_FSA_ACTION(A_DC_TIMER_START, do_timer_control) /* * Medium priority actions */ else IF_FSA_ACTION(A_DC_TAKEOVER, do_dc_takeover) else IF_FSA_ACTION(A_DC_RELEASE, do_dc_release) else IF_FSA_ACTION(A_DC_JOIN_OFFER_ALL, do_dc_join_offer_all) else IF_FSA_ACTION(A_DC_JOIN_OFFER_ONE, do_dc_join_offer_one) else IF_FSA_ACTION(A_DC_JOIN_PROCESS_REQ,do_dc_join_req) else IF_FSA_ACTION(A_DC_JOIN_PROCESS_ACK,do_dc_join_ack) /* * Low(er) priority actions * Make sure the CIB is always updated before invoking the * PE, and the PE before the TE */ else IF_FSA_ACTION(A_CIB_INVOKE_LOCAL, do_cib_invoke) else IF_FSA_ACTION(A_CIB_INVOKE, do_cib_invoke) else IF_FSA_ACTION(A_DC_JOIN_FINALIZE, do_dc_join_finalize) else IF_FSA_ACTION(A_LRM_INVOKE, do_lrm_invoke) else IF_FSA_ACTION(A_LRM_EVENT, do_lrm_event) else IF_FSA_ACTION(A_TE_CANCEL, do_te_invoke) else IF_FSA_ACTION(A_PE_INVOKE, do_pe_invoke) else IF_FSA_ACTION(A_TE_INVOKE, do_te_invoke) else IF_FSA_ACTION(A_CL_JOIN_ANNOUNCE, do_cl_join_announce) /* sub-system stop */ else IF_FSA_ACTION(A_DC_RELEASED, do_dc_release) else IF_FSA_ACTION(A_PE_STOP, do_pe_control) else IF_FSA_ACTION(A_TE_STOP, do_te_control) else IF_FSA_ACTION(A_CCM_DISCONNECT, do_ccm_control) else IF_FSA_ACTION(A_SHUTDOWN, do_shutdown) else IF_FSA_ACTION(A_LRM_DISCONNECT, do_lrm_control) else IF_FSA_ACTION(A_HA_DISCONNECT, do_ha_control) else IF_FSA_ACTION(A_CIB_STOP, do_cib_control) else IF_FSA_ACTION(A_STOP, do_stop) /* exit gracefully */ else IF_FSA_ACTION(A_EXIT_0, do_exit)/* else IF_FSA_ACTION(A_, do_) */ /* Error checking and reporting */ else if(cur_input != I_NULL && fsa_actions == A_NOTHING) { crm_warn( "No action specified for input,state (%s,%s)", fsa_input2string(cur_input), fsa_state2string(fsa_state)); next_input = I_NULL; } else if(cur_input == I_NULL && fsa_actions == A_NOTHING) {#ifdef FSA_TRACE crm_info("Nothing left to do..."); fsa_dump_actions(fsa_actions, "still here");#endif break; } else { crm_err("Action %s (0x%llx) not supported ", fsa_action2string(fsa_actions), fsa_actions); next_input = I_ERROR; } } now = time(NULL); crm_debug(DOT_PREFIX"\t// ### Exiting the FSA (%s%s): %s\n", fsa_state2string(fsa_state), do_fsa_stall?": paused":"", asctime(localtime(&now))); /* cleanup inputs? */ delete_fsa_input(fsa_data); crm_debug("Register contents (0x%llx)", fsa_input_register); fsa_dump_queue(LOG_DEBUG); return fsa_state;}long long do_state_transition(long long actions, enum crmd_fsa_cause cause, enum crmd_fsa_state cur_state, enum crmd_fsa_state next_state, enum crmd_fsa_input current_input, fsa_data_t *msg_data){ gboolean clear_recovery_bit = TRUE; long long tmp = actions; const char *state_from = fsa_state2string(cur_state); const char *state_to = fsa_state2string(next_state); const char *input = fsa_input2string(current_input); time_t now = time(NULL); if(cur_state == next_state) { crm_err("%s called in state %s with no transtion", __FUNCTION__, state_from); return A_NOTHING; } crm_debug(DOT_PREFIX"\t%s -> %s [ label=%s cause=%s origin=%s ] // %s", state_from, state_to, input, fsa_cause2string(cause), msg_data->origin, asctime(localtime(&now))); crm_info("State transition %s -> %s [ input=%s cause=%s origin=%s %s ]", state_from, state_to, input, fsa_cause2string(cause), msg_data->origin, asctime(localtime(&now))); /* the last two clauses might cause trouble later */ if(election_timeout != NULL && next_state != S_ELECTION && next_state != S_RELEASE_DC && next_state != S_PENDING) { stopTimer(election_timeout);/* } else { *//* startTimer(election_timeout); */ }#if 0 if(is_set(fsa_input_register, R_SHUTDOWN)){ set_bit_inplace(tmp, A_DC_TIMER_STOP); }#endif if(next_state == S_INTEGRATION) { set_bit_inplace(tmp, A_INTEGRATE_TIMER_START); } else { set_bit_inplace(tmp, A_INTEGRATE_TIMER_STOP); } if(next_state == S_FINALIZE_JOIN) { set_bit_inplace(tmp, A_FINALIZE_TIMER_START); } else { set_bit_inplace(tmp, A_FINALIZE_TIMER_STOP); } if(next_state == S_PENDING) { set_bit_inplace(tmp, A_DC_TIMER_START); } else { set_bit_inplace(tmp, A_DC_TIMER_STOP); } switch(next_state) { case S_PENDING: case S_ELECTION: crm_info("Resetting our DC to NULL on election"); crm_free(fsa_our_dc); fsa_our_dc = NULL; break; case S_NOT_DC: if(is_set(fsa_input_register, R_SHUTDOWN)){ crm_info("(Re)Issuing shutdown request now" " that we have a new DC"); set_bit_inplace(tmp, A_SHUTDOWN_REQ); } CRM_DEV_ASSERT(fsa_our_dc != NULL); if(fsa_our_dc == NULL) { crm_err("Reached S_NOT_DC without a DC" " being recorded"); } break; case S_RECOVERY: clear_recovery_bit = FALSE; break; case S_FINALIZE_JOIN: if(cause != C_FSA_INTERNAL) { crm_warn("Progressed to state %s after %s", fsa_state2string(cur_state), fsa_cause2string(cause)); } if(g_hash_table_size(join_requests) != fsa_membership_copy->members_size) { crm_warn("Only %d (of %d) cluster nodes " "responded to the join offer.", g_hash_table_size(join_requests), fsa_membership_copy->members_size); } else { crm_info("All %d clusters nodes " "responded to the join offer.", fsa_membership_copy->members_size); } break; case S_POLICY_ENGINE: if(cause != C_FSA_INTERNAL) { crm_warn("Progressed to state %s after %s", fsa_state2string(cur_state), fsa_cause2string(cause)); } if(g_hash_table_size(confirmed_nodes) == fsa_membership_copy->members_size) { crm_info("All %d clusters nodes are" " eligable to run resources.", fsa_membership_copy->members_size); } else if(g_hash_table_size(confirmed_nodes) == num_join_invites) { crm_warn("All %d (%d total) cluster " "nodes are eligable to run resources", g_hash_table_size(confirmed_nodes), fsa_membership_copy->members_size); } else { crm_warn("Only %d of %d (%d total) cluster " "nodes are eligable to run resources", g_hash_table_size(confirmed_nodes), num_join_invites, fsa_membership_copy->members_size); }/* initialize_join(FALSE); */ break; case S_IDLE: dump_rsc_info(); break; default: break; } if(clear_recovery_bit && next_state != S_PENDING) { tmp = clear_bit(tmp, A_RECOVER); } else if(clear_recovery_bit == FALSE) { tmp = set_bit(tmp, A_RECOVER); } if(tmp != actions) { fsa_dump_actions(actions ^ tmp, "New actions"); actions = tmp; } return actions;}long longclear_flags(long long actions, enum crmd_fsa_cause cause, enum crmd_fsa_state cur_state, enum crmd_fsa_input cur_input){ long long saved_actions = actions; if(is_set(fsa_input_register, R_SHUTDOWN) && cur_state == S_STARTING) { clear_bit_inplace( actions, A_STARTUP|A_CIB_START|A_LRM_CONNECT|A_CCM_CONNECT|A_HA_CONNECT|A_READCONFIG|A_STARTED|A_CL_JOIN_QUERY|A_DC_TIMER_START); } fsa_dump_actions(actions ^ saved_actions, "Cleared Actions"); return actions;}voiddump_rsc_info(void){ crm_data_t *local_cib = get_cib_copy(fsa_cib_conn); crm_data_t *root = get_object_root(XML_CIB_TAG_STATUS, local_cib); crm_data_t *resources = NULL; const char *rsc_id = NULL; const char *node_id = NULL; const char *rsc_state = NULL; const char *op_status = NULL; const char *last_rc = NULL; const char *last_op = NULL; const char *path[] = { XML_CIB_TAG_LRM, XML_LRM_TAG_RESOURCES }; xml_child_iter( root, node, XML_CIB_TAG_STATE, resources = find_xml_node_nested(node, path, DIMOF(path)); xml_child_iter( resources, rsc, XML_LRM_TAG_RESOURCE, rsc_id = crm_element_value(rsc, XML_ATTR_ID); node_id = crm_element_value(rsc, XML_LRM_ATTR_TARGET); rsc_state = crm_element_value(rsc, XML_LRM_ATTR_RSCSTATE); op_status = crm_element_value(rsc, XML_LRM_ATTR_OPSTATUS); last_rc = crm_element_value(rsc, XML_LRM_ATTR_RC); last_op = crm_element_value(rsc, XML_LRM_ATTR_LASTOP); /* if(safe_str_eq(rsc_state, "stopped")) { *//* continue; *//* } */ if(safe_str_neq(op_status, "-1")) { crm_info("Resource state: %s %s " "[%s (rc=%s) after %s] on %s", rsc_id, rsc_state, op_status, last_rc, last_op, node_id); } else { crm_warn("Resource state: %s %s " "[pending %s] on %s", rsc_id, rsc_state, last_op, node_id); } ); );}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -