[Openais] A patch for configuration change of AMF

SAKAI MIYOTAKA sakai.miyotaka at nttcom.co.jp
Tue Sep 14 09:29:06 PDT 2004


Steve ,

I made the patch .

If you have any problem ,please let me know .

Regards
- Miyotaka sakai 


Steven Dake wrote:

>Sakai-san,
>
>Some comments inline on the patch.  Could you address them and post
>another patch?
>
>On Sun, 2004-09-12 at 07:54, SAKAI MIYOTAKA wrote:
>  
>
>>Steave ,
>>
>>I  made a patch for configuration change .
>>This patch  is also corresponding to a certain node joining .
>>
>>Could you review the patch attached to this message ?
>>
>>I think this path works well .
>>
>>If you accept this patch ,next step is that each separate node has 
>>Active unit ,when joining each other.
>>For example ,
>>Node A has the unit that is Active .
>>Node B has the unit that is Active .
>>After that these nodes joining each other .
>>
>>In that case this patch doesn't work .
>>
>>SAKAI MIYOTAKA wrote:
>>
>>    
>>
>>>Steve ,
>>>
>>>I made a patch for configuration change when a certain node leaves.
>>>
>>>Could you review the patch attached to this message ?
>>>
>>>I think review points are followings 
>>>
>>>- The basic frame of configuration change for AMF.
>>>- Adding source_addr to saAmfComponent as a member.
>>>
>>>thanks 
>>>- Miyotaka saka
>>>
-------------- next part --------------
diff -Nur openais.2004-09-09.21.30/exec/amf.c openais/exec/amf.c
--- openais.2004-09-09.21.30/exec/amf.c	2004-09-10 13:30:02.000000000 +0900
+++ openais/exec/amf.c	2004-09-15 00:00:56.000000000 +0900
@@ -36,6 +36,7 @@
 #include <sys/socket.h>
 #include <sys/un.h>
 #include <netinet/in.h>
+#include <arpa/inet.h>
 #include <unistd.h>
 #include <fcntl.h>
 #include <stdlib.h>
@@ -142,12 +143,15 @@
 static int activeServiceUnitsCount (
 	struct saAmfGroup *saAmfGroup);
 
-#ifdef COMPILE_OUT
-static void enumerateComponents (
+static void component_register( struct saAmfComponent *component );
+
+static void component_unregister ( struct saAmfComponent *component );
+
+static void enumerate_components (
 	void (*function)(struct saAmfComponent *, void *data),
 	void *data);
 
-
+#ifdef COMPILE_OUT
 static void CSIRemove (
 	struct conn_info *conn_info);
 
@@ -223,6 +227,17 @@
 
 static int amfExecutiveInitialize (void);
 
+static void amf_confchg_nleave ( struct saAmfComponent *component, void *data);
+
+static void amf_confchg_njoin ( struct saAmfComponent *component, void *data);
+
+static void amf_confchg_nsync ( struct saAmfComponent *component, void *data);
+
+static int amf_confchg_fn (
+	   struct sockaddr_in *member_list, int member_list_entries,
+	   struct sockaddr_in *left_list, int left_list_entries,
+	   struct sockaddr_in *joined_list, int joined_list_entries);
+
 static int message_handler_req_exec_amf_componentregister (void *message, struct in_addr source_addr);
 
 static int message_handler_req_exec_amf_componentunregister (void *message, struct in_addr source_addr);
@@ -371,7 +386,7 @@
 	.libais_handlers_count		= sizeof (amf_libais_handlers) / sizeof (struct libais_handler),
 	.aisexec_handler_fns		= amf_aisexec_handler_fns,
 	.aisexec_handler_fns_count	= sizeof (amf_aisexec_handler_fns) / sizeof (int (*)),
-	.confchg_fn					= 0,
+	.confchg_fn				= amf_confchg_fn,
 	.libais_init_fn				= message_handler_req_amf_init,
 	.libais_exit_fn				= amf_exit_fn,
 	.aisexec_init_fn			= amfExecutiveInitialize
@@ -454,7 +469,7 @@
 	return (0);
 }
 
-void componentUnregister (
+void component_unregister (
 	struct saAmfComponent *component)
 {
 	struct req_exec_amf_componentunregister req_exec_amf_componentunregister;
@@ -466,7 +481,7 @@
 	if (component == 0 || component->local != 1) {
 		return;
 	}
-	log_printf (LOG_LEVEL_DEBUG, "componentUnregister: unregistering component %s\n",
+	log_printf (LOG_LEVEL_DEBUG, "component_unregister: unregistering component %s\n",
 		getSaNameT (&component->name));
 	component->probableCause = SA_AMF_NOT_RESPONDING;
 
@@ -488,10 +503,43 @@
 	gmi_mcast (&aisexec_groupname, iovecs, 1, GMI_PRIO_MED);
 }
 
-#ifdef COMPILE_OUT
-This should be used for a partition I think
-// This should be used for partition changes
-void enumerateComponents (
+void component_register (
+	struct saAmfComponent *component)
+{
+	struct req_exec_amf_componentregister req_exec_amf_componentregister;
+	struct iovec iovecs[2];
+
+	/*
+	 * This only works on local components
+	 */
+	if (component == 0 || component->local != 1) {
+		return;
+	}
+	log_printf (LOG_LEVEL_DEBUG, "component_register: registering component %s\n",
+		getSaNameT (&component->name));
+	/******
+	component->probableCause = SA_AMF_NOT_RESPONDING;
+	******/
+
+	req_exec_amf_componentregister.header.size = sizeof (struct req_exec_amf_componentregister);
+	req_exec_amf_componentregister.header.id = MESSAGE_REQ_EXEC_AMF_COMPONENTREGISTER;
+
+	req_exec_amf_componentregister.source.conn_info = 0;
+	req_exec_amf_componentregister.source.in_addr.s_addr = 0;
+
+	memset (&req_exec_amf_componentregister.req_lib_amf_componentregister,
+		0, sizeof (struct req_lib_amf_componentregister));
+	memcpy (&req_exec_amf_componentregister.req_lib_amf_componentregister.compName,
+		&component->name,
+		sizeof (SaNameT));
+
+	iovecs[0].iov_base = (char *)&req_exec_amf_componentregister;
+	iovecs[0].iov_len = sizeof (req_exec_amf_componentregister);
+
+	gmi_mcast (&aisexec_groupname, iovecs, 1, GMI_PRIO_RECOVERY);
+}
+
+void enumerate_components (
 	void (*function)(struct saAmfComponent *, void *data),
 	void *data)
 {
@@ -503,7 +551,6 @@
 	struct saAmfUnit *AmfUnit;
 	struct saAmfComponent *AmfComponent;
 
-
 	/*
 	 * Search all groups
 	 */
@@ -539,7 +586,6 @@
 		}
 	}
 }
-#endif
 
 int activeServiceUnitsCount (struct saAmfGroup *saAmfGroup) {
 	struct saAmfUnit *saAmfUnit;
@@ -568,8 +614,7 @@
 
 			saAmfComponent = list_entry (saAmfComponentList,
 				struct saAmfComponent, saAmfComponentList);
-
-			if (saAmfComponent->currentHAState != SA_AMF_ACTIVE) {
+			if (saAmfComponent->newHAState != SA_AMF_ACTIVE) {
 				thisServiceUnitActive = 0;
 			}
 		}
@@ -1623,13 +1668,82 @@
 	return (0);
 }
 
+void amf_confchg_nleave( struct saAmfComponent *component ,void *data ) {
+
+	struct in_addr *source_addr;
+	source_addr = ( struct in_addr *) data;
+
+        if ( memcmp( &(component->source_addr) ,source_addr ,sizeof(*source_addr)) ) {
+		return;
+        }
+
+        component->local = 1;
+        component_unregister (component);
+
+        return;
+}
+
+void amf_confchg_njoin ( struct saAmfComponent *component ,void *data ) {
+
+	if ( memcmp(&(component->source_addr),&(this_ip.sin_addr.s_addr),sizeof(component->source_addr)) ) {
+		return;
+ 	}
+
+	component_register (component);
+	return;
+}
+
+void amf_confchg_nsync ( struct saAmfComponent *component ,void *data ) {
+
+	if ( memcmp( &(component->source_addr),&(this_ip.sin_addr.s_addr),sizeof(component->source_addr)) ) {
+		return;
+ 	}
+
+	/* dsm change mast be needed */
+	readinessStateSetCluster (component, component->currentReadinessState);
+	haStateSetCluster (component, component->currentHAState);
+
+	return;
+}
+
+int amf_confchg_fn (
+	struct sockaddr_in *member_list, int member_list_entries,
+	struct sockaddr_in *left_list, int left_list_entries,
+	struct sockaddr_in *joined_list, int joined_list_entries){
+
+	int i;
+	int size;
+
+	/*
+	* If node join , component register 
+	*/
+	if ( joined_list_entries > 0 ) {
+		enumerate_components (amf_confchg_njoin ,NULL );
+		enumerate_components (amf_confchg_nsync ,NULL );
+	}
+
+        /*
+         * If node leave , component unregister 
+         */
+        size = sizeof((member_list->sin_addr));
+        if ( memcmp( &(member_list->sin_addr), &(this_ip.sin_addr.s_addr) ,size ) ){
+		return (0);
+        }
+
+        for ( i = 0; i<left_list_entries ; i++ ) {
+		enumerate_components (amf_confchg_nleave, (void *)&(left_list[i].sin_addr));
+        }
+
+        return (0);
+}
+
 int amf_exit_fn (struct conn_info *conn_info)
 {
 	/*
 	 * Unregister all components registered to this file descriptor
 	 */
 	if (conn_info->service == SOCKET_SERVICE_AMF) {
-		componentUnregister (conn_info->component);
+		component_unregister (conn_info->component);
 
 		if (conn_info->component && conn_info->component->timer_healthcheck) {
 			poll_timer_delete (aisexec_poll_handle,
@@ -1647,7 +1761,6 @@
 	return (0);
 }
 
-
 static int message_handler_req_exec_amf_componentregister (void *message, struct in_addr source_addr)
 {
 	struct req_exec_amf_componentregister *req_exec_amf_componentregister = (struct req_exec_amf_componentregister *)message;
@@ -1700,6 +1813,7 @@
 		component->local = 0;
 		component->registered = 1;
 		component->conn_info = req_exec_amf_componentregister->source.conn_info;
+		component->source_addr = source_addr;
 		component->currentReadinessState = SA_AMF_OUT_OF_SERVICE;
 		component->newReadinessState = SA_AMF_OUT_OF_SERVICE;
 		component->currentHAState = SA_AMF_QUIESCED;
@@ -1916,6 +2030,7 @@
 			req_exec_amf_readinessstateset->readinessState);
 
 		component->currentReadinessState = req_exec_amf_readinessstateset->readinessState;
+		component->newReadinessState     = component->currentReadinessState;
 		dsm (component);
 	}
 	
@@ -1939,6 +2054,7 @@
 			getSaNameT (&component->name),
 			req_exec_amf_hastateset->haState);
 		component->currentHAState = req_exec_amf_hastateset->haState;
+		component->newHAState     = component->currentHAState;
 		dsm (component);
 	}
 	
diff -Nur openais.2004-09-09.21.30/exec/parse.h openais/exec/parse.h
--- openais.2004-09-09.21.30/exec/parse.h	2004-09-10 13:30:02.000000000 +0900
+++ openais/exec/parse.h	2004-09-11 10:42:04.000000000 +0900
@@ -130,6 +130,7 @@
 	int registered;
 	int local;
 	struct conn_info *conn_info;
+	struct in_addr source_addr;
 	SaNameT name;
 	SaAmfReadinessStateT currentReadinessState;
 	SaAmfReadinessStateT newReadinessState;


More information about the Openais mailing list