⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 unpack.c

📁 linux集群服务器软件代码包
💻 C
📖 第 1 页 / 共 3 页
字号:
		crm_verbose("Processing lrm agents");		unpack_lrm_agents(this_node, lrm_agents);		);	return TRUE;	}gbooleandetermine_online_status(crm_data_t * node_state, node_t *this_node){	gboolean online = FALSE;	const char *uname      = crm_element_value(node_state,XML_ATTR_UNAME);/*	const char *state      = crm_element_value(node_state,XML_NODE_ATTR_STATE); */	const char *exp_state  = crm_element_value(node_state,XML_CIB_ATTR_EXPSTATE);	const char *join_state = crm_element_value(node_state,XML_CIB_ATTR_JOINSTATE);	const char *crm_state  = crm_element_value(node_state,XML_CIB_ATTR_CRMDSTATE);	const char *ccm_state  = crm_element_value(node_state,XML_CIB_ATTR_INCCM);	const char *ha_state   = crm_element_value(node_state,XML_CIB_ATTR_HASTATE);	const char *shutdown   = crm_element_value(node_state,XML_CIB_ATTR_SHUTDOWN);	const char *unclean    = NULL;/*crm_element_value(node_state,XML_CIB_ATTR_STONITH); */		if(safe_str_eq(join_state, CRMD_JOINSTATE_MEMBER)	   && safe_str_eq(ccm_state, XML_BOOLEAN_YES)	   && (ha_state == NULL || safe_str_eq(ha_state, ACTIVESTATUS))	   && safe_str_eq(crm_state, ONLINESTATUS)	   && shutdown == NULL) {		if(this_node != NULL) {			this_node->details->online = TRUE;		}		crm_debug("Node %s is online", uname);		online = TRUE;			} else if(this_node != NULL) {		/* remove node from contention */		this_node->weight = -1;		this_node->fixed = TRUE;		crm_verbose("join_state=%s, expected=%s, shutdown=%s",			    crm_str(join_state), crm_str(exp_state),			    crm_str(shutdown));		if(unclean != NULL) {			this_node->details->unclean = TRUE;						} else if(is_node_unclean(node_state)) {			/* report and or take remedial action */			this_node->details->unclean = TRUE;		}				if(shutdown != NULL) {			this_node->details->shutdown = TRUE;		}		if(this_node->details->unclean) {			crm_warn("Node %s is unclean", uname);		}		if(this_node->details->shutdown) {			crm_debug("Node %s is due for shutdown", uname);		}	}	return online;}gbooleanis_node_unclean(crm_data_t * node_state){/*	const char *state      = crm_element_value(node_state,XML_NODE_ATTR_STATE); */	const char *uname      = crm_element_value(node_state,XML_ATTR_UNAME);	const char *exp_state  = crm_element_value(node_state,XML_CIB_ATTR_EXPSTATE);	const char *join_state = crm_element_value(node_state,XML_CIB_ATTR_JOINSTATE);	const char *crm_state  = crm_element_value(node_state,XML_CIB_ATTR_CRMDSTATE);	const char *ha_state  = crm_element_value(node_state,XML_CIB_ATTR_HASTATE);	const char *ccm_state  = crm_element_value(node_state,XML_CIB_ATTR_INCCM);	if(safe_str_eq(exp_state, CRMD_STATE_INACTIVE)) {		crm_debug("Node %s is safely inactive", uname);		return FALSE;	/* do an actual calculation once STONITH is available */	} else if(safe_str_neq(exp_state, CRMD_JOINSTATE_DOWN)) {		if(safe_str_eq(crm_state, OFFLINESTATUS)		   || (ha_state != NULL && safe_str_eq(ha_state, DEADSTATUS))		   || safe_str_eq(join_state, CRMD_JOINSTATE_DOWN)		   || safe_str_eq(ccm_state, XML_BOOLEAN_NO)) {			crm_warn("Node %s is un-expectedly down", uname);			return TRUE;		}		crm_debug("Node %s: ha=%s, join=%s, crm=%s, ccm=%s",			  uname, crm_str(ha_state), crm_str(join_state),			  crm_str(crm_state), crm_str(ccm_state));	} else {		crm_debug("Node %s was expected to be down", uname);	}	return FALSE;}gbooleanunpack_lrm_agents(node_t *node, crm_data_t * agent_list){	/* if the agent is not listed, remove the node from	 * the resource's list of allowed_nodes	 */	lrm_agent_t *agent   = NULL;	const char *version  = NULL;	if(agent_list == NULL) {		return FALSE;	}	xml_child_iter(		agent_list, xml_agent, XML_LRM_TAG_AGENT,		crm_malloc(agent, sizeof(lrm_agent_t));		if(agent == NULL) {			continue;		}				agent->class   = crm_element_value(xml_agent, XML_AGENT_ATTR_CLASS);		agent->type    = crm_element_value(xml_agent, XML_ATTR_TYPE);		version        = crm_element_value(xml_agent, XML_ATTR_VERSION);		agent->version = version?version:"0.0";		crm_trace("Adding agent %s/%s v%s to node %s",			  agent->class,			  agent->type,			  agent->version,			  node->details->uname);			  		node->details->agents = g_list_append(			node->details->agents, agent);		);		return TRUE;}gbooleanunpack_lrm_rsc_state(node_t *node, crm_data_t * lrm_rsc,		     GListPtr rsc_list, GListPtr nodes,		     GListPtr *actions, GListPtr *placement_constraints){	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;	resource_t *rsc_lh    = NULL;	op_status_t  action_status_i = LRM_OP_ERROR;	xml_child_iter(		lrm_rsc, rsc_entry, XML_LRM_TAG_RESOURCE,				rsc_id    = crm_element_value(rsc_entry, XML_ATTR_ID);		node_id   = crm_element_value(rsc_entry, XML_LRM_ATTR_TARGET);		rsc_state = crm_element_value(rsc_entry, XML_LRM_ATTR_RSCSTATE);		op_status = crm_element_value(rsc_entry, XML_LRM_ATTR_OPSTATUS);		last_rc   = crm_element_value(rsc_entry, XML_LRM_ATTR_RC);		last_op   = crm_element_value(rsc_entry, XML_LRM_ATTR_LASTOP);				rsc_lh    = pe_find_resource(rsc_list, rsc_id);		crm_verbose("[%s] Processing %s on %s (%s)",			    crm_element_name(rsc_entry), rsc_id, node_id, rsc_state);		if(rsc_lh == NULL) {			crm_err("Could not find a match for resource"				" %s in %s's status section",				rsc_id, node_id);			continue;		} else if(op_status == NULL) {			crm_err("Invalid resource status entry for %s in %s",				rsc_id, node_id);			continue;		}				action_status_i = atoi(op_status);		if(node->details->unclean) {			crm_info("Node %s (where %s is running) is unclean."				 "Further action depends on the value of %s",				 node->details->uname, rsc_lh->id,				 XML_RSC_ATTR_STOPFAIL);						/* map the status to an error and then handle as a			 * failed resource.			 */			action_status_i = LRM_OP_ERROR;					} else if(action_status_i == -1) {			/*			 * TODO: this may need some more thought			 * Some cases:			 * - PE reinvoked with pending action that will succeed			 * - PE reinvoked with pending action that will fail			 * - After DC election			 * - After startup			 *			 * pending start - required start			 * pending stop  - required stop			 * pending <any> on unavailable node - stonith			 *			 * For now this should do			 */			if(safe_str_eq(last_op, "stop")) {				/* map this to a timeout so it is re-issued */				action_status_i = LRM_OP_TIMEOUT;			} else {				/* map this to a "done" so it is not marked				 * as failed, then make sure it is re-issued				 */				action_new(rsc_lh, start_rsc, NULL);				action_status_i = LRM_OP_DONE;			}		}		switch(action_status_i) {			case LRM_OP_DONE:				unpack_healthy_resource(					placement_constraints, actions,					rsc_entry, rsc_lh,node);				break;			case LRM_OP_ERROR:			case LRM_OP_TIMEOUT:			case LRM_OP_NOTSUPPORTED:				unpack_failed_resource(placement_constraints, 						       rsc_entry, rsc_lh,node);				break;			case LRM_OP_CANCELLED:				/* do nothing?? */				crm_warn("Dont know what to do for cancelled ops yet");				break;		}		);		return TRUE;}gbooleanunpack_failed_resource(GListPtr *placement_constraints, 		       crm_data_t * rsc_entry, resource_t *rsc_lh, node_t *node){	const char *last_op  = crm_element_value(rsc_entry, XML_LRM_ATTR_LASTOP);	crm_devel("Unpacking failed action %s on %s", last_op, rsc_lh->id);		/* make sure we dont allocate the resource here again*/	rsc2node_new("dont_run__generated",		     rsc_lh, -1.0, FALSE, node, placement_constraints);		if(safe_str_eq(last_op, "start")) {		/* the resource is not actually running... nothing more to do*/		return TRUE;	} 	switch(rsc_lh->stopfail_type) {		case pesf_stonith:			/* treat it as if it is still running			 * but also mark the node as unclean			 */			native_add_running(rsc_lh, node);			node->details->running_rsc = g_list_append(				node->details->running_rsc, rsc_lh);						if(node->details->online) {				node->details->shutdown = TRUE;			}			node->details->unclean  = TRUE;			break;					case pesf_block: 			/* let this depend on the stop action which will fail			 * but make sure the transition continues...			 */			native_add_running(rsc_lh, node);			node->details->running_rsc = g_list_append(				node->details->running_rsc, rsc_lh);/* 			rsc_lh->stop->timeout = NULL; /\* wait forever *\/ */			break;			case pesf_ignore:			/* pretend nothing happened */			break;	}			return TRUE;}gbooleanunpack_healthy_resource(GListPtr *placement_constraints, GListPtr *actions,			crm_data_t * rsc_entry, resource_t *rsc_lh, node_t *node){	const char *last_op  = crm_element_value(rsc_entry, XML_LRM_ATTR_LASTOP);		crm_devel("Unpacking healthy action %s on %s", last_op, rsc_lh->id);	if(safe_str_neq(last_op, "stop")) {		/* create the link between this node and the rsc */		crm_verbose("Setting cur_node = %s for rsc = %s",			    node->details->uname, rsc_lh->id);		native_add_running(rsc_lh, node);				node->details->running_rsc = g_list_append(			node->details->running_rsc, rsc_lh);	}	return TRUE;}gbooleanrsc_dependancy_new(const char *id, enum con_strength strength,		   resource_t *rsc_lh, resource_t *rsc_rh){	rsc_dependancy_t *new_con      = NULL; 	rsc_dependancy_t *inverted_con = NULL; 	if(rsc_lh == NULL || rsc_rh == NULL){		/* error */		return FALSE;	}	crm_malloc(new_con, sizeof(rsc_dependancy_t));	if(new_con != NULL) {		new_con->id       = id;		new_con->rsc_lh   = rsc_lh;		new_con->rsc_rh   = rsc_rh;		new_con->strength = strength;				inverted_con = invert_constraint(new_con);		crm_devel("Adding constraint %s (%p) to %s",			  new_con->id, new_con, rsc_lh->id);				rsc_lh->rsc_cons = g_list_insert_sorted(			rsc_lh->rsc_cons, new_con, sort_cons_strength);				crm_devel("Adding constraint %s (%p) to %s",			  inverted_con->id, inverted_con, rsc_rh->id);		rsc_rh->rsc_cons = g_list_insert_sorted(			rsc_rh->rsc_cons, inverted_con, sort_cons_strength);	} else {		return FALSE;	}		return TRUE;}gbooleanorder_new(resource_t *lh_rsc, enum action_tasks lh_action_task, action_t *lh_action,	  resource_t *rh_rsc, enum action_tasks rh_action_task, action_t *rh_action,	  enum con_strength strength, GListPtr *ordering_constraints){	order_constraint_t *order = NULL;	if((lh_action == NULL && lh_rsc == NULL)	   || (rh_action == NULL && rh_rsc == NULL)	   || ordering_constraints == NULL){		crm_err("Invalid inputs lh_rsc=%p, lh_a=%p,"			" rh_rsc=%p, rh_a=%p,  l=%p",			lh_rsc, lh_action, rh_rsc, rh_action,			ordering_constraints);		return FALSE;	}	crm_malloc(order, sizeof(order_constraint_t));	if(order == NULL) {		return FALSE;	}		order->id             = order_id++;	order->strength       = strength;	order->lh_rsc         = lh_rsc;	order->rh_rsc         = rh_rsc;	order->lh_action      = lh_action;	order->rh_action      = rh_action;	order->lh_action_task = lh_action_task;	order->rh_action_task = rh_action_task;		*ordering_constraints = g_list_append(		*ordering_constraints, order);		if(lh_rsc != NULL && rh_rsc != NULL) {		crm_devel("Created ordering constraint %d (%s):"			 " %s/%s before %s/%s",			 order->id, strength2text(order->strength),			 lh_rsc->id, task2text(lh_action_task),			 rh_rsc->id, task2text(rh_action_task));			} else if(lh_rsc != NULL) {		crm_devel("Created ordering constraint %d (%s):"			 " %s/%s before action %d (%s)",			 order->id, strength2text(order->strength),			 lh_rsc->id, task2text(lh_action_task),			 rh_action->id, task2text(rh_action_task));			} else if(rh_rsc != NULL) {		crm_devel("Created ordering constraint %d (%s):"			 " action %d (%s) before %s/%s",			 order->id, strength2text(order->strength),			 lh_action->id, task2text(lh_action_task),			 rh_rsc->id, task2text(rh_action_task));			} else {		crm_devel("Created ordering constraint %d (%s):"			 " action %d (%s) before action %d (%s)",			 order->id, strength2text(order->strength),			 lh_action->id, task2text(lh_action_task),			 rh_action->id, task2text(rh_action_task));	}		return TRUE;}gbooleanunpack_rsc_dependancy(crm_data_t * xml_obj,		  GListPtr rsc_list,		  GListPtr *ordering_constraints){	enum con_strength strength_e = pecs_ignore;	const char *id_lh    = crm_element_value(xml_obj, XML_CONS_ATTR_FROM);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -