[Openais] Patch Amf node leave and join #2

Hans Feldt Hans.Feldt at ericsson.com
Tue Sep 5 00:54:44 PDT 2006


Committed revision 1237.

print.c changes excluded, need separate patch.

/Hans

Lars Holm wrote:
> The patch contains:
> 
> 
> 1.    Improvement to manage more than one SG within an Application  and 
> to          asymmetrically distribute the SG:s among the Nodes.         
> 2.    strcmp bug fixes  several *_find functions.
> 3.    Minor bug fixes.
> 
> Test:
> 
> The patch is tested on a few different configurations:
>     *     Three Nodes,Three SGs with 2/3 SUs each and 1/2 Components in 
> each
>     *      8 Si
>     *      1+1,1+1 redundancy models in SG1,SG2 and SG3
> 
> 
> The test cases performed:
>    *      Component restart by kill testamf1
>    *      Su Restart by kill testamf1 and escalation
>    *      Su Fail over by kill testamf1 and escalation
>    *      Node Leave by kill aisexec on different Nodes
>    *     Node Join  by starting aisexec.
> 
> Regards
> Lars Holm & Anders Ericsson
> 
> 
> ------------------------------------------------------------------------
> 
> Index: exec/amfsg.c
> ===================================================================
> --- exec/amfsg.c	(revision 1235)
> +++ exec/amfsg.c	(working copy)
> @@ -150,7 +150,7 @@
>  
>  static void acsm_enter_activating_standby (struct amf_sg *sg);
>  static void delete_si_assignments_in_scope (struct amf_sg *sg);
> -
> +static void acsm_enter_repairing_su (struct amf_sg *sg);
>  static void standby_su_activated_cbfn (
>  	struct amf_si_assignment *si_assignment, int result);
>  
> @@ -173,14 +173,20 @@
>  	if (sg->recovery_scope.recovery_type != 0) {
>  		switch (sg->recovery_scope.recovery_type) {
>  			case SG_RT_FailoverSU:
> -			case SG_RT_FailoverNode:
>  				assert (sg->recovery_scope.sus[0] != NULL);
>  				amf_su_dn_make (sg->recovery_scope.sus[0], &dn);
>  				log_printf (
>  					LOG_NOTICE, "'%s' %s recovery action finished",
>  					dn.value,
>  					sg_recovery_type_text[sg->recovery_scope.recovery_type]);
> +
>  				break;
> +			case SG_RT_FailoverNode:
> +				log_printf (
> +					LOG_NOTICE, "'%s for %s' recovery action finished",
> +					sg_recovery_type_text[sg->recovery_scope.recovery_type],
> +					sg->name.value);
> +				break;
>  			default:
>  				log_printf (
>  					LOG_NOTICE, "'%s' recovery action finished",
> @@ -195,6 +201,7 @@
>  		free ((void *)sg->recovery_scope.sis);
>  	}
>  	memset (&sg->recovery_scope, 0, sizeof (struct sg_recovery_scope));
> +	sg->node_to_start = NULL;
>  }
>  
>  static int su_instantiated_count (struct amf_sg *sg)
> @@ -327,7 +334,8 @@
>  	dependent_si_deactivated_cbfn2 (sg);
>  }
>  
> -static struct amf_si *si_get_dependent (struct amf_si *si)
> +
> +static struct amf_si *si_get_dependent (struct amf_si *si) 
>  {
>  
>  	struct amf_si *tmp_si = NULL;
> @@ -357,7 +365,7 @@
>  }
>  
>  struct amf_si *amf_dependent_get_next (struct amf_si *si, 
> -	struct amf_si *si_iter)
> +	struct amf_si *si_iter) 
>  {
>  	struct amf_si *tmp_si;
>  	struct amf_application *application;
> @@ -435,7 +443,6 @@
>  			timer_function_dependent_si_deactivated2, &handle);
>  	}
>  }
> -
>  /**
>   * Enter function for state SG_AC_ActivatingStandby. It activates
>   * one STANDBY assignment for each SI in the recovery scope.
> @@ -445,6 +452,7 @@
>  {
>  	struct amf_si **sis= sg->recovery_scope.sis;
>  	struct amf_si_assignment *si_assignment;
> +	int is_no_standby_activated = 1;
>  	ENTER("'%s'",sg->name.value); 
>  	sg->avail_state = SG_AC_ActivatingStandby;
>  
> @@ -459,12 +467,18 @@
>  				si_assignment->requested_ha_state = SA_AMF_HA_ACTIVE;
>  				amf_si_ha_state_assume (
>  					si_assignment, standby_su_activated_cbfn);
> +				is_no_standby_activated = 0;
>  				break;
>  			}
>  			si_assignment = si_assignment->next;
>  		}
>  		sis++;
>  	}
> +
> +	if (is_no_standby_activated) {
> +		sg->avail_state = SG_AC_AssigningStandbyToSpare;
> +		acsm_enter_repairing_su (sg);	
> +	}
>  }
>  
>  static void acsm_enter_repairing_su (struct amf_sg *sg)
> @@ -472,7 +486,7 @@
>  	struct amf_su **sus= sg->recovery_scope.sus;
>  	ENTER("'%s'",sg->name.value);
>  	sg->avail_state = SG_AC_ReparingSu;
> -
> +	int is_any_su_instantiated = 0;
>  	/*                                                              
>  	 * Instantiate SUs in current recovery scope until the configured
>  	 * preference is fulfiled.
> @@ -487,6 +501,7 @@
>  				openais_exit_error (AIS_DONE_FATAL_ERR);
>  			}
>  			if (node->saAmfNodeOperState == SA_AMF_OPERATIONAL_ENABLED) {
> +				is_any_su_instantiated = 1;	
>  				amf_su_instantiate ((*sus));
>  			} else {
>  				return_to_idle (sg);
> @@ -495,6 +510,9 @@
>  		}
>  		sus++;
>  	}
> +	if (is_any_su_instantiated == 0) {
> +		return_to_idle (sg);
> +	}
>  }
>  
>  /**
> @@ -542,9 +560,9 @@
>  		tmp_sis++;
>  	}
>  
> -	*tmp_sis= si;
> +	*tmp_sis = si;
> +	*(++tmp_sis) = NULL;
>  }
> -
>  /**
>   * Adds the ssu pointed out to the scope.
>   * @param sg
> @@ -570,7 +588,8 @@
>  		tmp_sus++;
>  	}
>  
> -	*tmp_sus= su;
> +	*tmp_sus = su;
> +	*(++tmp_sus) = NULL; 
>  }
>  
>  /**
> @@ -584,8 +603,10 @@
>  	struct amf_si_assignment *si_assignment;
>  	struct amf_si **sis;
>  	struct amf_su **sus;
> +	SaNameT dn;
> +	sg->recovery_scope.recovery_type = SG_RT_FailoverSU;
>  
> -	sg->recovery_scope.recovery_type = SG_RT_FailoverSU;
> +
>  	sg->recovery_scope.comp = NULL;
>  	sg->recovery_scope.sus = (struct amf_su **)
>  	calloc (2, sizeof (struct amf_su *));
> @@ -596,6 +617,12 @@
>  		(sg->recovery_scope.sis != NULL));
>  	sg->recovery_scope.sus[0] = su;
>  
> +	amf_su_dn_make (sg->recovery_scope.sus[0], &dn);
> +	log_printf (
> +		LOG_NOTICE, "'%s' for %s recovery action started",
> +		sg_recovery_type_text[sg->recovery_scope.recovery_type],
> +		dn.value);
> +
>  	si_assignment = amf_su_get_next_si_assignment (su, NULL);
>  	while (si_assignment != NULL) {
>  		if (is_si_in_scope(sg, si_assignment->si) == 0) {
> @@ -604,7 +631,7 @@
>  		si_assignment = amf_su_get_next_si_assignment (su, si_assignment);
>  	}
>  
> -	sus= sg->recovery_scope.sus;
> +	sus = sg->recovery_scope.sus;
>  	dprintf("The following sus are within the scope:\n");
>  	while (*sus != NULL) {
>  		dprintf("%s\n", (*sus)->name.value);
> @@ -617,7 +644,6 @@
>  		sis++;
>  	}
>  }
> -
>  static void set_scope_for_failover_node (struct amf_sg *sg, struct amf_node *node)
>  {
>  	struct amf_si_assignment *si_assignment;
> @@ -633,6 +659,11 @@
>  	sg->recovery_scope.sis = (struct amf_si **)
>  	calloc (1, sizeof (struct amf_si *));
>  
> +	log_printf (
> +		LOG_NOTICE, "'%s' for node %s recovery action started",
> +		sg_recovery_type_text[sg->recovery_scope.recovery_type],
> +		node->name.value);
> +
>  	assert ((sg->recovery_scope.sus != NULL) &&
>  		(sg->recovery_scope.sis != NULL));
>  	for (su = sg->su_head; su != NULL; su = su->next) {
> @@ -654,7 +685,7 @@
>  		sus++;
>  	}
>  
> -	sus= sg->recovery_scope.sus;
> +	sus = sg->recovery_scope.sus;
>  	dprintf("The following sus are within the scope:\n");
>  	while (*sus != NULL) {
>  		dprintf("%s\n", (*sus)->name.value);
> @@ -678,10 +709,13 @@
>  	struct amf_csi *csi;
>  	struct amf_si *si;
>  	struct amf_si_assignment *si_assignment;
> -
> +	struct amf_si_assignment **prev;	
>  	ENTER ("'%s'", su->name.value);
>  
>  	for (si = su->sg->application->si_head; si != NULL; si = si->next) {
> +
> +		prev = &si->assigned_sis;
> +
>  		if (!name_match (&si->saAmfSIProtectedbySG, &su->sg->name)) {
>  			continue;
>  		}
> @@ -690,20 +724,19 @@
>  			amf_csi_delete_assignments (csi, su);
>  		}
>  
> -		/*                                                              
> -		 * TODO: this only works for n+m where each SI list has only two
> -		 * assignments, one active and one standby.
> -		 * TODO: use DN instead
> -		 */
> -		if (si->assigned_sis->su == su) {
> -			si_assignment = si->assigned_sis;
> -			si->assigned_sis = si_assignment->next;
> -		} else {
> -			si_assignment = si->assigned_sis->next;
> -			si->assigned_sis->next = NULL;
> +
> +		for (si_assignment = si->assigned_sis; si_assignment != NULL;
> +			si_assignment = si_assignment->next) {
> +			if (si_assignment->su == su) {
> +				struct amf_si_assignment *tmp = si_assignment;
> +				*prev = si_assignment->next;
> +				dprintf ("SI assignment %s unlinked", tmp->name.value);
> +				free (tmp);
> +			} else {
> +				prev = &si_assignment->next;
> +			}
>  		}
> -		assert (si_assignment != NULL);
> -		free (si_assignment);
> +
>  	}
>  }
>  
> @@ -890,21 +923,31 @@
>  }
>  
>  static int all_su_has_presence_state (
> -	struct amf_sg *sg, SaAmfPresenceStateT state)
> +	struct amf_sg *sg, struct amf_node *node_to_start, 
> +	SaAmfPresenceStateT state)
>  {
>  	struct amf_su   *su;
>  	int all_set = 1;
>  
>  	for (su = sg->su_head; su != NULL; su = su->next) {
> +
>  		if (su->saAmfSUPresenceState != state) {
> -			all_set = 0;
> -			break;
> +			if (node_to_start == NULL) {
> +				all_set = 0;
> +				break;
> +			} else {
> +				if (name_match(&node_to_start->name,
> +					&su->saAmfSUHostedByNode)) {
> +					all_set = 0;
> +					break;
> +				}
> +			}
>  		}
>  	}
> -
>  	return all_set;
>  }
>  
> +
>  static int all_su_in_scope_has_presence_state (
>  	struct amf_sg *sg, SaAmfPresenceStateT state)
>  {
> @@ -937,6 +980,34 @@
>  	return(cnt);
>  }
>  
> +int amf_si_get_saAmfSINumReqActiveAssignments(struct amf_si *si) 
> +{
> +	struct amf_si_assignment *si_assignment = si->assigned_sis;
> +	int number_of_req_active_assignments = 0;
> +
> +	for (; si_assignment != NULL; si_assignment = si_assignment->next) {
> +
> +		if (si_assignment->requested_ha_state == SA_AMF_HA_ACTIVE) {
> +			number_of_req_active_assignments++;
> +		}
> +	}
> +	return number_of_req_active_assignments;
> +}
> +
> +
> +int amf_si_get_saAmfSINumReqStandbyAssignments(struct amf_si *si) 
> +{
> +	struct amf_si_assignment *si_assignment = si->assigned_sis;
> +	int number_of_req_active_assignments = 0;
> +
> +	for (; si_assignment != NULL; si_assignment = si_assignment->next) {
> +		if (si_assignment->requested_ha_state == SA_AMF_HA_STANDBY) {
> +			number_of_req_active_assignments++;
> +		}
> +	}
> +	return number_of_req_active_assignments;
> +}
> +
>  static int sg_assign_nm_active (struct amf_sg *sg, int su_active_assign)
>  {
>  	struct amf_su *su;
> @@ -970,21 +1041,19 @@
>  		si = sg->application->si_head;
>  		assigned = 0;
>  		assign_to_su = div_round (si_left, su_left_to_assign);
> +		if (assign_to_su > sg->saAmfSGMaxActiveSIsperSUs) {
> +			assign_to_su = sg->saAmfSGMaxActiveSIsperSUs;
> +		}
>  		while (si != NULL) {
>  
>  			if (name_match (&si->saAmfSIProtectedbySG, &sg->name) &&
>  				assigned < assign_to_su && 
> -				amf_si_get_saAmfSINumCurrActiveAssignments(si) < 
> -				su_active_assign) {
> -
> -				if (amf_si_su_get_saAmfSINumCurrActiveAssignments (si, su) == 
> -					0) {
> -
> +				amf_si_get_saAmfSINumReqActiveAssignments(si) == 0) {
>  					assigned += 1;
>  					total_assigned += 1;
>  					amf_su_assign_si (su, si, SA_AMF_HA_ACTIVE);
> -				}
> -			}
> +		    	}
> +			
>  			si = si->next;
>  		}
>  		su = su->next;
> @@ -1041,19 +1110,16 @@
>  		si = sg->application->si_head;
>  		assigned = 0;
>  		assign_to_su = div_round (si_left, su_left_to_assign);
> +		if (assign_to_su > sg->saAmfSGMaxStandbySIsperSUs) {
> +			assign_to_su = sg->saAmfSGMaxStandbySIsperSUs;
> +		}
>  		while (si != NULL) {
>  			if (name_match (&si->saAmfSIProtectedbySG, &sg->name) &&
>  				assigned < assign_to_su && 
> -				amf_si_get_saAmfSINumCurrStandbyAssignments (si) < 
> -				su_standby_assign) {
> -
> -				if (amf_si_su_get_saAmfSINumCurrStandbyAssignments (si, su) == 
> -					0) {
> -
> +				amf_si_get_saAmfSINumReqStandbyAssignments (si) == 0) {
>  					assigned += 1;
>  					total_assigned += 1;
>  					amf_su_assign_si (su, si, SA_AMF_HA_STANDBY);
> -				}
>  			}
>  			si = si->next;
>  		}
> @@ -1094,7 +1160,7 @@
>   * @param sg
>   * @param dependency_level
>   */
> -static void assign_si (struct amf_sg *sg, int dependency_level)
> +static int assign_si (struct amf_sg *sg, int dependency_level)
>  {
>  	int active_sus_needed;
>  	int standby_sus_needed;
> @@ -1105,8 +1171,8 @@
>  	int assigned = 0;
>  
>  	ENTER ("'%s'", sg->name.value);
> +	
>  
> -
>  	/**
>  	 * Phase 1: Calculate assignments and create all runtime objects in
>  	 * information model. Do not do the actual assignment, done in
> @@ -1118,14 +1184,26 @@
>  	 */
>  	inservice_count = (float)su_inservice_count_get (sg);
>  
> -	active_sus_needed = div_round (
> -		sg_si_count_get (sg) * sg->saAmfSGNumPrefActiveSUs,
> -		sg->saAmfSGMaxActiveSIsperSUs);
>  
> -	standby_sus_needed = div_round (
> -		sg_si_count_get (sg) * sg->saAmfSGNumPrefStandbySUs,
> -		sg->saAmfSGMaxStandbySIsperSUs);
> +	if (sg->saAmfSGNumPrefActiveSUs > 0) {
> +		active_sus_needed = div_round (
> +			sg_si_count_get (sg),
> +			sg->saAmfSGMaxActiveSIsperSUs);
> +	} else {
> +		log_printf (LOG_LEVEL_ERROR, "ERROR: saAmfSGNumPrefActiveSUs == 0 !!");
> +		openais_exit_error (AIS_DONE_FATAL_ERR);
> +	}
>  
> +	if (sg->saAmfSGNumPrefStandbySUs > 0) {
> +		standby_sus_needed = div_round (
> +			sg_si_count_get (sg),
> +			sg->saAmfSGMaxStandbySIsperSUs);
> +	} else {
> +		log_printf (LOG_LEVEL_ERROR, "ERROR: saAmfSGNumPrefStandbySUs == 0 !!");
> +		openais_exit_error (AIS_DONE_FATAL_ERR);
> +
> +	}
> +
>  	dprintf ("(inservice=%d) (active_sus_needed=%d) (standby_sus_needed=%d)"
>  		"\n",
>  		inservice_count, active_sus_needed, standby_sus_needed);
> @@ -1185,30 +1263,35 @@
>  	dprintf ("(inservice=%d) (assigning active=%d) (assigning standby=%d)"
>  		" (assigning spares=%d)\n",
>  		inservice_count, su_active_assign, su_standby_assign, su_spare_assign);
> -	assigned = sg_assign_nm_active (sg, su_active_assign);
> -	assigned += sg_assign_nm_standby (sg, su_standby_assign);
>  
> -	assert (assigned > 0);
> +	if (inservice_count > 0) {
> +		assigned = sg_assign_nm_active (sg, su_active_assign);
> +		assigned += sg_assign_nm_standby (sg, su_standby_assign);
>  
> -	sg->saAmfSGNumCurrAssignedSUs = inservice_count;
> +#if 0
> +		assert (assigned > 0);
> +#endif
> +		sg->saAmfSGNumCurrAssignedSUs = inservice_count;
>  
>  	/**
>  	 * Phase 2: do the actual assignment to the component
>  	 * TODO: first do active, then standby
>  	 */
> -	{
> -		struct amf_si *si;
> -		struct amf_si_assignment *si_assignment;
> +		{
> +			struct amf_si *si;
> +			struct amf_si_assignment *si_assignment;
>  
> -		for (si = sg->application->si_head; si != NULL; si = si->next) {
> -			if (name_match (&si->saAmfSIProtectedbySG, &sg->name)) {
> -				for (si_assignment = si->assigned_sis; si_assignment != NULL;
> -					si_assignment = si_assignment->next) {
> +			for (si = sg->application->si_head; si != NULL; si = si->next) {
> +				if (name_match (&si->saAmfSIProtectedbySG, &sg->name)) {
> +					for (si_assignment = si->assigned_sis; 
> +						si_assignment != NULL;
> +						si_assignment = si_assignment->next) {
>  
> -					if (si_assignment->requested_ha_state !=
> -						si_assignment->saAmfSISUHAState) {
> -						amf_si_ha_state_assume (
> -							si_assignment, assign_si_assumed_cbfn);
> +						if (si_assignment->requested_ha_state !=
> +							si_assignment->saAmfSISUHAState) {
> +							amf_si_ha_state_assume (
> +								si_assignment, assign_si_assumed_cbfn);
> +						}
>  					}
>  				}
>  			}
> @@ -1216,19 +1299,24 @@
>  	}
>  
>  	LEAVE ("'%s'", sg->name.value);
> +	return assigned;
>  }
>  
>  void amf_sg_assign_si (struct amf_sg *sg, int dependency_level)
> -{       
> +{   
> +
>  	sg->avail_state = SG_AC_AssigningOnRequest;
> -	assign_si (sg, dependency_level);
> +	if (assign_si (sg, dependency_level) == 0) {
> +		return_to_idle (sg);	
> +		amf_application_sg_assigned (sg->application, sg);	
> +	}
>  }
>  
>  void amf_sg_failover_node_req (
>  	struct amf_sg *sg, struct amf_node *node) 
>  {
>  
> -	ENTER("'%s'",node->name.value);
> +	ENTER("'%s, %s'",node->name.value, sg->name.value);
>  
>     /*                                                              
>  	 * TODO: Defer all new events. Workaround is to exit.
> @@ -1277,7 +1365,6 @@
>  	} 
>  
>  }
> -
>  void amf_sg_start (struct amf_sg *sg, struct amf_node *node)
>  {
>  	struct amf_su *su;
> @@ -1286,6 +1373,8 @@
>  
>  	ENTER ("'%s'", sg->name.value);
>  
> +	sg->node_to_start = node;
> +
>  	sg->avail_state = SG_AC_InstantiatingServiceUnits;
>  
>  	for (su = sg->su_head; su != NULL; su = su->next) {
> @@ -1294,7 +1383,7 @@
>  			amf_su_instantiate (su);
>  			instantiated_sus++;
>  		} else {
> -            /* Node start, match if SU is hosted on the specified node */
> +			/* Node start, match if SU is hosted on the specified node*/
>  			if (name_match (&node->name, &su->saAmfSUHostedByNode)) {
>  				amf_su_instantiate (su);
>  				instantiated_sus++;
> @@ -1316,7 +1405,7 @@
>  	if (type == SA_AMF_PRESENCE_STATE) {
>  		if (state == SA_AMF_PRESENCE_INSTANTIATED) {
>  			if (sg->avail_state == SG_AC_InstantiatingServiceUnits) {
> -				if (all_su_has_presence_state(su->sg,
> +				if (all_su_has_presence_state(sg, sg->node_to_start, 
>  					SA_AMF_PRESENCE_INSTANTIATED)) {
>  					su->sg->avail_state = SG_AC_Idle;
>  					amf_application_sg_started (
> @@ -1326,7 +1415,9 @@
>  				if (all_su_in_scope_has_presence_state(su->sg,
>  					SA_AMF_PRESENCE_INSTANTIATED)) {
>  					su->sg->avail_state = SG_AC_AssigningStandBy;
> -					assign_si (sg, 0);
> +					if (assign_si (sg, 0) == 0) {
> +						return_to_idle (sg);	
> +					}
>  
>  				} else {
>  					dprintf ("avail-state: %u", sg->avail_state);
> @@ -1399,7 +1490,7 @@
>   * @return struct amf_sg*
>   */
>  
> -struct amf_sg *amf_sg_new (struct amf_application *app, char *name)
> +struct amf_sg *amf_sg_new (struct amf_application *app, char *name) 
>  {
>  	struct amf_sg *sg = calloc (1, sizeof (struct amf_sg));
>  
> @@ -1421,6 +1512,7 @@
>  	sg->saAmfSGAutoRepair = SA_TRUE;
>  	sg->application = app;
>  	setSaNameT (&sg->name, name);
> +	sg->node_to_start = NULL;
>  
>  	return sg;
>  }
> @@ -1492,7 +1584,7 @@
>  }
>  
>  struct amf_sg *amf_sg_deserialize (
> -	struct amf_application *app, char *buf, int size)
> +	struct amf_application *app, char *buf, int size) 
>  {
>  	char *tmp = buf;
>  	struct amf_sg *sg;
> @@ -1524,14 +1616,13 @@
>  	return sg;
>  }
>  
> -struct amf_sg *amf_sg_find (struct amf_application *app, char *name)
> +struct amf_sg *amf_sg_find (struct amf_application *app, char *name) 
>  {
>  	struct amf_sg *sg;
>  
> -	assert (app != NULL && name != NULL);
> -
>  	for (sg = app->sg_head; sg != NULL; sg = sg->next) {
> -		if (strncmp (name, (char*)sg->name.value, sg->name.length) == 0) {
> +		if (sg->name.length == strlen(name) && 
> +			strncmp (name, (char*)sg->name.value, sg->name.length) == 0) {
>  			break;
>  		}
>  	}
> Index: exec/amfsi.c
> ===================================================================
> --- exec/amfsi.c	(revision 1235)
> +++ exec/amfsi.c	(working copy)
> @@ -647,8 +647,10 @@
>  {
>  	struct amf_si *si;
>  
> +
>  	for (si = app->si_head; si != NULL; si = si->next) {
> -		if (strncmp (name, (char*)si->name.value, si->name.length) == 0) {
> +		if (si->name.length == strlen(name) && 
> +			strncmp (name, (char*)si->name.value, si->name.length) == 0) {
>  			break;
>  		}
>  	}
> @@ -727,7 +729,8 @@
>  	struct amf_csi *csi;
>  
>  	for (csi = si->csi_head; csi != NULL; csi = csi->next) {
> -		if (strncmp (name, (char*)csi->name.value, csi->name.length) == 0) {
> +		if (csi->name.length == strlen(name) && 
> +			strncmp (name, (char*)csi->name.value, csi->name.length) == 0) {
>  			break;
>  		}
>  	}
> @@ -893,7 +896,8 @@
>  	for (csi_assignment = csi->assigned_csis; csi_assignment != NULL;
>  		csi_assignment = csi_assignment->next) {
>  
> -		if (strncmp (csi_assignment_name,
> +		if (csi_assignment->name.length == strlen(csi_assignment_name) && 
> +			strncmp (csi_assignment_name,
>  			(char*)csi_assignment->name.value,
>  			csi_assignment->name.length) == 0) {
>  			goto end;
> @@ -901,6 +905,8 @@
>  	}
>  
>  end:
> +	assert(csi_assignment);
> +
>  	free (buf);
>  	return csi_assignment;
>  }
> Index: exec/amfapp.c
> ===================================================================
> --- exec/amfapp.c	(revision 1235)
> +++ exec/amfapp.c	(working copy)
> @@ -78,17 +78,14 @@
>  static int all_sg_started (struct amf_application *app)
>  {
>  	struct amf_sg *sg;
> -	struct amf_su *su;
>  	int all_su_instantiated = 1;
>  
>  	/* TODO: spare SUs... */
>  
>  	for (sg = app->sg_head; sg != NULL; sg = sg->next) {
> -		for (su = sg->su_head; su != NULL; su = su->next) {
> -			if (su->saAmfSUPresenceState != SA_AMF_PRESENCE_INSTANTIATED) {
> -				all_su_instantiated = 0;
> -				break;
> -			}
> +		if (sg->avail_state != SG_AC_Idle) {
> +			all_su_instantiated = 0;
> +			break;
>  		}
>  	}
>  
> @@ -233,7 +230,9 @@
>  	struct amf_application *app;
>  
>  	for (app = cluster->application_head; app != NULL; app = app->next) {
> -		if (strncmp (name, (char*)app->name.value, app->name.length) == 0) {
> +		
> +		if (app->name.length == strlen(name) && 
> +			strncmp (name, (char*)app->name.value, app->name.length) == 0) {
>  			break;
>  		}
>  	}
> Index: exec/amfsu.c
> ===================================================================
> --- exec/amfsu.c	(revision 1235)
> +++ exec/amfsu.c	(working copy)
> @@ -235,7 +235,7 @@
>  
>  	amf_su_dn_make (su, &dn);
>  	log_printf (LOG_NOTICE, "Error detected for '%s', recovery "
> -		"action:\n\t\tSU restart", dn.value);
> +		"action: SU restart", dn.value);
>  
>  	su->restart_control_state = SU_RC_RESTART_SU_DEACTIVATING;
>  	su->restart_control_state = SU_RC_RESTART_SU_INSTANTIATING;
> @@ -256,7 +256,7 @@
>  	ENTER ("'%s'", comp->name.value);
>  	amf_comp_dn_make (comp, &dn);
>  	log_printf (LOG_NOTICE, "Error detected for '%s', recovery "
> -		"action:\n\t\tcomponent restart", dn.value);
> +		"action: Component restart", dn.value);
>  
>  	comp->su->restart_control_state = SU_RC_RESTART_COMP_DEACTIVATING;
>  	comp->su->restart_control_state = SU_RC_RESTART_COMP_RESTARTING;
> @@ -900,7 +900,8 @@
>  		if (strncmp (sg_name, (char*)sg->name.value,
>  			sg->name.length) == 0) {
>  			for (su = sg->su_head; su != NULL; su = su->next) {
> -				if (strncmp (su_name, (char*)su->name.value,
> +				if (su->name.length == strlen(su_name) && 
> +					strncmp (su_name, (char*)su->name.value,
>  					su->name.length) == 0) {
>  					goto end;
>  				}
> Index: exec/amfcomp.c
> ===================================================================
> --- exec/amfcomp.c	(revision 1235)
> +++ exec/amfcomp.c	(working copy)
> @@ -794,7 +794,8 @@
>  	for (su = sg->su_head; su != NULL; su = su->next) {
>  		if (strncmp (su_name, (char*)su->name.value, su->name.length) == 0) {
>  			for (comp = su->comp_head; comp != NULL; comp = comp->next) {
> -				if (strncmp (comp_name, (char*)comp->name.value,
> +				if (comp->name.length == strlen(comp_name) && 
> +					strncmp (comp_name, (char*)comp->name.value,
>  					comp->name.length) == 0) {
>  					goto end;
>  				}
> @@ -2080,6 +2081,9 @@
>  	} else {
>  		struct amf_healthcheck *obj = amf_malloc (sizeof (struct amf_healthcheck));
>  		memcpy (obj, buf, objsz);
> +		obj->active = 0;
> +		obj->timer_handle_duration = 0;
> +		obj->timer_handle_period = 0;
>  		obj->comp = comp;
>  		obj->next = comp->healthcheck_head;
>  		comp->healthcheck_head = obj;
> Index: exec/amf.h
> ===================================================================
> --- exec/amf.h	(revision 1235)
> +++ exec/amf.h	(working copy)
> @@ -258,6 +258,7 @@
>  	struct amf_sg            *next;
>  	sg_avail_control_state_t  avail_state;
>      struct sg_recovery_scope  recovery_scope;
> +	struct amf_node *node_to_start;
>  };
>  
>  struct amf_su {
> @@ -849,7 +850,10 @@
>  	struct amf_si_assignment *si_assignment, int *len);
>  extern struct amf_si_assignment *amf_si_assignment_deserialize (
>  	struct amf_si *si, char *buf, int size);
> -
> +#if 0
> +char *amf_si_assignment_dn_make (struct amf_su *su, struct amf_si *si,
> +	SaNameT *name);
> +#endif
>  /**
>   * Get number of active assignments for the specified SI
>   * @param si
> Index: exec/print.c
> ===================================================================
> --- exec/print.c	(revision 1235)
> +++ exec/print.c	(working copy)
> @@ -54,6 +54,7 @@
>  #endif
>  #include <syslog.h>
>  #include <stdlib.h>
> +#include <unistd.h>
>  #include <pthread.h>
>  #include <signal.h>
>  
> @@ -236,6 +237,7 @@
>  	}
>  
>  #ifndef DEBUG
> +
>  	if (log_setup_called) {
>  		int res = worker_thread_group_work_add (&log_thread_group, &log_data);
>  		if (res == 0) {
> @@ -291,8 +293,13 @@
>  	signal (SIGUSR2, sigusr2_handler);
>  #endif
>  
> +
>  	if (config->logmode & LOG_MODE_FILE) {
> -		log_file_fp = fopen (config->logfile, "a+");
> +		char hostname[256];
> +		char logfile[256];
> +		gethostname (hostname, 256);
> +		sprintf (logfile,"%s_%s", config->logfile, hostname);
> +		log_file_fp = fopen (logfile, "a+");
>  		if (log_file_fp == 0) {
>  			sprintf (error_string_response,
>  				"Can't open logfile '%s' for reason (%s).\n",
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> Openais mailing list
> Openais at lists.osdl.org
> https://lists.osdl.org/mailman/listinfo/openais




More information about the Openais mailing list