[Openais] A patch for configuration change of AMF

SAKAI MIYOTAKA sakai.miyotaka at nttcom.co.jp
Sat Sep 25 19:55:50 PDT 2004


Steve ,

I made a patch attached to this message .

Now I can't access bitkeeper server .
I am asking OSDL support to access the bk repository for write access .
Please give me some time .

So ,Could you please merge this patch this time ?
I appreciate for your help .

Thanks -
Miyotaka Sakai.

Steven Dake wrote:
> A few comments inline.  After those few changes we are ready to merge. 
> I can either merge, or if you wait for your bk account to be
> configuration and you can do the merge.
> 
> Let me know what you prefer.  If you merge, please enter the bug number
> in the comments field at bk commit stage.  Also please attach the patch
> to the bugzilla bug.
> 
> The bug # is 45.
> 
> You can obtain a bugzilla account at 
> 
> http://www.osdl.org/developer_bugzilla/createaccount.cgi
> 
> Thanks!
> -steve
> 
> On Tue, 2004-09-14 at 09:29, SAKAI MIYOTAKA wrote:
-------------- next part --------------
diff -Nur openais.2004-09-24.21.30/exec/amf.c openais/exec/amf.c
--- openais.2004-09-24.21.30/exec/amf.c	2004-09-25 13:30:03.000000000 +0900
+++ openais/exec/amf.c	2004-09-26 11:01:13.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,17 @@
 static int activeServiceUnitsCount (
 	struct saAmfGroup *saAmfGroup);
 
-#ifdef COMPILE_OUT
-static void enumerateComponents (
+static void component_unregister (
+	struct saAmfComponent *component);
+
+static void component_register (
+	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);
 
@@ -218,6 +224,17 @@
 	struct conn_info *conn_info,
 	struct req_amf_response *req_amf_response);
 
+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 (
 	enum gmi_configuration_type configuration_type,
@@ -397,7 +414,7 @@
 			(newsize) * sizeof (struct libamf_ci_trackentry));
 		if (tracks == 0) {
 #ifdef DEBUG
-			printf ("grow_amf_track_table: out of memory, woops\n");
+			printf("grow_amf_track_table: out of memory, woops\n");
 #endif
 // TODO
 			exit (1);
@@ -460,7 +477,7 @@
 	return (0);
 }
 
-void componentUnregister (
+static void component_unregister (
 	struct saAmfComponent *component)
 {
 	struct req_exec_amf_componentunregister req_exec_amf_componentunregister;
@@ -472,7 +489,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;
 
@@ -494,10 +511,44 @@
 	assert (gmi_mcast (&aisexec_groupname, iovecs, 1, GMI_PRIO_MED) == 0);
 }
 
-#ifdef COMPILE_OUT
+static 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);
+
+	assert (gmi_mcast (&aisexec_groupname, iovecs, 1, GMI_PRIO_RECOVERY) == 0);
+}
+
+/***
 This should be used for a partition I think
-// This should be used for partition changes
-void enumerateComponents (
+**/
+void enumerate_components (
 	void (*function)(struct saAmfComponent *, void *data),
 	void *data)
 {
@@ -545,7 +596,6 @@
 		}
 	}
 }
-#endif
 
 int activeServiceUnitsCount (struct saAmfGroup *saAmfGroup) {
 	struct saAmfUnit *saAmfUnit;
@@ -575,7 +625,7 @@
 			saAmfComponent = list_entry (saAmfComponentList,
 				struct saAmfComponent, saAmfComponentList);
 
-			if (saAmfComponent->currentHAState != SA_AMF_ACTIVE) {
+			if (saAmfComponent->newHAState != SA_AMF_ACTIVE) {
 				thisServiceUnitActive = 0;
 			}
 		}
@@ -1640,6 +1690,51 @@
 	return (0);
 }
 
+void amf_confchg_nleave( struct saAmfComponent *component ,void *data)
+{
+	int size;
+	struct in_addr *source_addr;
+	source_addr = ( struct in_addr *) data;
+
+	size = sizeof(struct in_addr);
+	if (memcmp(&(component->source_addr),source_addr ,size)) {
+		return;
+	}
+
+	component->local = 1;
+	component_unregister (component);
+
+	return;
+}
+
+void amf_confchg_njoin ( struct saAmfComponent *component ,void *data)
+{
+	int size;
+
+	size = sizeof(struct in_addr);
+	if(memcmp(&(component->source_addr),&(this_ip.sin_addr.s_addr),size)){
+		return;
+	}
+
+	component_register (component);
+	return;
+}
+
+void amf_confchg_nsync ( struct saAmfComponent *component ,void *data)
+{
+	int size;
+
+	size = sizeof(struct in_addr);
+	if(memcmp(&(component->source_addr),&(this_ip.sin_addr.s_addr),size)){
+		return;
+	}
+
+	/* dsm change mast be needed */
+	readinessStateSetCluster (component, component->currentReadinessState);
+	haStateSetCluster (component, component->currentHAState);
+
+	return;
+}
 
 static int amf_confchg_fn (
 	enum gmi_configuration_type configuration_type,
@@ -1647,9 +1742,33 @@
     struct sockaddr_in *left_list, int left_list_entries,
     struct sockaddr_in *joined_list, int joined_list_entries)
 {
+	int i;
+	int size;
+
 	if (configuration_type == GMI_CONFIGURATION_REGULAR) {
 		gmi_recovery_plug_unplug (amf_recovery_plug_handle);
 	}
+
+	/*
+	 * 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);
 }
 
@@ -1659,7 +1778,7 @@
 	 * 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,
@@ -1730,6 +1849,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;
@@ -1784,7 +1904,7 @@
 	struct saAmfComponent *amfProxyComponent;
 	SaErrorT error;
 
-	log_printf (LOG_LEVEL_DEBUG, "Executive: ComponentUnregister for %s\n",
+	log_printf (LOG_LEVEL_DEBUG, "Executive: Component_unregister for %s\n",
 		getSaNameT (&req_exec_amf_componentunregister->req_lib_amf_componentunregister.compName));
 
 	component = findComponent (&req_exec_amf_componentunregister->req_lib_amf_componentunregister.compName);
@@ -1946,6 +2066,7 @@
 			req_exec_amf_readinessstateset->readinessState);
 
 		component->currentReadinessState = req_exec_amf_readinessstateset->readinessState;
+		component->newReadinessState     = component->currentReadinessState;
 		dsm (component);
 	}
 	
@@ -1969,6 +2090,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-24.21.30/exec/parse.h openais/exec/parse.h
--- openais.2004-09-24.21.30/exec/parse.h	2004-09-25 13:30:03.000000000 +0900
+++ openais/exec/parse.h	2004-09-26 09:06:06.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