[Openais] A patch for configuration change of AMF
SAKAI MIYOTAKA
sakai.miyotaka at nttcom.co.jp
Sun Sep 12 07:54:38 PDT 2004
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 sakai
> =
>
-------------- next part --------------
diff -uNr 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-12 22:49:09.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,6 +143,10 @@
static int activeServiceUnitsCount (
struct saAmfGroup *saAmfGroup);
=
+static void componentRegister( struct saAmfComponent *component );
+
+static void componentUnregister ( struct saAmfComponent *component );
+
#ifdef COMPILE_OUT
static void enumerateComponents (
void (*function)(struct saAmfComponent *, void *data),
@@ -223,6 +228,18 @@
=
static int amfExecutiveInitialize (void);
=
+static void amf_confchg_nleave ( struct saAmfComponent *component ,void *d=
ata );
+
+static void amf_confchg_njoin ( struct saAmfComponent *component ,void *da=
ta );
+
+static void amf_confchg_nsync ( struct saAmfComponent *component ,void *da=
ta );
+
+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 +388,7 @@
.libais_handlers_count =3D sizeof (amf_libais_handlers) / sizeof (struct=
libais_handler),
.aisexec_handler_fns =3D amf_aisexec_handler_fns,
.aisexec_handler_fns_count =3D sizeof (amf_aisexec_handler_fns) / sizeof =
(int (*)),
- .confchg_fn =3D 0,
+ .confchg_fn =3D amf_confchg_fn,
.libais_init_fn =3D message_handler_req_amf_init,
.libais_exit_fn =3D amf_exit_fn,
.aisexec_init_fn =3D amfExecutiveInitialize
@@ -488,8 +505,41 @@
gmi_mcast (&aisexec_groupname, iovecs, 1, GMI_PRIO_MED);
}
=
-#ifdef COMPILE_OUT
-This should be used for a partition I think
+void componentRegister (
+ struct saAmfComponent *component)
+{
+ struct req_exec_amf_componentregister req_exec_amf_componentregister;
+ struct iovec iovecs[2];
+
+ /*
+ * This only works on local components
+ */
+ if (component =3D=3D 0 || component->local !=3D 1) {
+ return;
+ }
+ log_printf (LOG_LEVEL_DEBUG, "componentRegister: registering component %s=
\n",
+ getSaNameT (&component->name));
+// component->probableCause =3D SA_AMF_NOT_RESPONDING;
+
+ req_exec_amf_componentregister.header.size =3D sizeof (struct req_exec_am=
f_componentregister);
+ req_exec_amf_componentregister.header.id =3D MESSAGE_REQ_EXEC_AMF_COMPONE=
NTREGISTER;
+
+ req_exec_amf_componentregister.source.conn_info =3D 0;
+ req_exec_amf_componentregister.source.in_addr.s_addr =3D 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.com=
pName,
+ &component->name,
+ sizeof (SaNameT));
+
+ iovecs[0].iov_base =3D (char *)&req_exec_amf_componentregister;
+ iovecs[0].iov_len =3D sizeof (req_exec_amf_componentregister);
+
+ gmi_mcast (&aisexec_groupname, iovecs, 1, GMI_PRIO_HIGH);
+}
+
+// This should be used for a partition I think
// This should be used for partition changes
void enumerateComponents (
void (*function)(struct saAmfComponent *, void *data),
@@ -503,7 +553,6 @@
struct saAmfUnit *AmfUnit;
struct saAmfComponent *AmfComponent;
=
-
/*
* Search all groups
*/
@@ -539,7 +588,6 @@
}
}
}
-#endif
=
int activeServiceUnitsCount (struct saAmfGroup *saAmfGroup) {
struct saAmfUnit *saAmfUnit;
@@ -568,8 +616,7 @@
=
saAmfComponent =3D list_entry (saAmfComponentList,
struct saAmfComponent, saAmfComponentList);
-
- if (saAmfComponent->currentHAState !=3D SA_AMF_ACTIVE) {
+ if (saAmfComponent->/*currentHAState*/newHAState !=3D SA_AMF_ACTIVE) {
thisServiceUnitActive =3D 0;
}
}
@@ -1623,6 +1670,79 @@
return (0);
}
=
+void amf_confchg_nleave( struct saAmfComponent *component ,void *data ) {
+
+ struct in_addr *source_addr;
+ source_addr =3D ( struct in_addr *) data;
+
+// printf( "amf_confchg_nleave(%s)\n" ,(char *)inet_ntoa(*source_addr));
+// printf( " (%s)\n" ,(char *)inet_ntoa(component->source=
_addr));
+
+ if ( memcmp( &(component->source_addr) ,source_addr ,sizeof(*sourc=
e_addr)) ) {
+ return;
+ }
+
+ component -> local =3D 1;
+ componentUnregister( 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;
+ }
+
+ componentRegister( 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;
+ }
+
+ 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;
+ void *data;
+
+ /*
+ * If node join , component register =
+ */
+ if ( joined_list_entries > 0 ) {
+ enumerateComponents ( amf_confchg_njoin ,NULL );
+ enumerateComponents ( amf_confchg_nsync ,NULL );
+ }
+
+ /*
+ * If node leave , component unregister =
+ */
+ size =3D sizeof((member_list->sin_addr));
+ if ( memcmp( &(member_list->sin_addr), &(this_ip.sin_addr.s_addr) =
,size ) ){
+ return(0);
+ }
+
+ for ( i =3D 0; i<left_list_entries ; i++ ) {
+ data =3D ( void *)&(left_list->sin_addr); left_list ++;
+ enumerateComponents ( amf_confchg_nleave ,data );
+ }
+
+ return (0);
+}
+
int amf_exit_fn (struct conn_info *conn_info)
{
/*
@@ -1647,7 +1767,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 =3D=
(struct req_exec_amf_componentregister *)message;
@@ -1700,6 +1819,7 @@
component->local =3D 0;
component->registered =3D 1;
component->conn_info =3D req_exec_amf_componentregister->source.conn_inf=
o;
+ component->source_addr =3D source_addr;
component->currentReadinessState =3D SA_AMF_OUT_OF_SERVICE;
component->newReadinessState =3D SA_AMF_OUT_OF_SERVICE;
component->currentHAState =3D SA_AMF_QUIESCED;
@@ -1916,6 +2036,7 @@
req_exec_amf_readinessstateset->readinessState);
=
component->currentReadinessState =3D req_exec_amf_readinessstateset->rea=
dinessState;
+ component->newReadinessState =3D component->currentReadinessState;
dsm (component);
}
=
@@ -1939,6 +2060,7 @@
getSaNameT (&component->name),
req_exec_amf_hastateset->haState);
component->currentHAState =3D req_exec_amf_hastateset->haState;
+ component->newHAState =3D component->currentHAState;
dsm (component);
}
=
diff -uNr 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 +09=
00
+++ 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