소스 검색

Allow services to use the openais.conf file for setting custom options.

(Logical change 1.195)


git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@637 fd59a12c-fef9-0310-b244-a6a79926bd2f
Mark Haverkamp 21 년 전
부모
커밋
632a94dd7d
12개의 변경된 파일83개의 추가작업 그리고 68개의 파일을 삭제
  1. 2 2
      exec/amf.c
  2. 2 2
      exec/ckpt.c
  3. 2 2
      exec/clm.c
  4. 2 2
      exec/evs.c
  5. 1 1
      exec/handlers.h
  6. 5 6
      exec/main.c
  7. 19 1
      exec/parse.c
  8. 25 0
      exec/parse.h
  9. 4 10
      exec/totempg.c
  10. 3 5
      exec/totempg.h
  11. 15 14
      exec/totemsrp.c
  12. 3 23
      exec/totemsrp.h

+ 2 - 2
exec/amf.c

@@ -248,7 +248,7 @@ static void amf_dump (void);
 
 static int amf_exit_fn (struct conn_info *conn_info);
 
-static int amf_exec_init_fn (void);
+static int amf_exec_init_fn (struct openais_config *);
 
 static int amf_init_two_fn (struct conn_info *conn_info);
 
@@ -1810,7 +1810,7 @@ static void response_handler_csisetcallback (struct conn_info *conn_info,
 	}
 }
 
-static int amf_exec_init_fn (void)
+static int amf_exec_init_fn (struct openais_config *openais_config)
 {
 #ifdef TODO
 	int res;

+ 2 - 2
exec/ckpt.c

@@ -78,7 +78,7 @@ typedef enum {
 
 /* TODO static totempg_recovery_plug_handle ckpt_checkpoint_recovery_plug_handle; */
 
-static int ckpt_exec_init_fn (void);
+static int ckpt_exec_init_fn (struct openais_config *);
 
 static int ckpt_exit_fn (struct conn_info *conn_info);
 
@@ -949,7 +949,7 @@ int ckpt_checkpoint_close (struct saCkptCheckpoint *checkpoint) {
 	return (-1);
 }
 
-static int ckpt_exec_init_fn (void)
+static int ckpt_exec_init_fn (struct openais_config *openais_config)
 {
 	/*
 	 *  Initialize the saved ring ID.

+ 2 - 2
exec/clm.c

@@ -113,7 +113,7 @@ static void clm_sync_activate (void);
 
 static void clm_sync_abort (void);
 
-static int clm_exec_init_fn (void);
+static int clm_exec_init_fn (struct openais_config *);
 
 static int clm_init_two_fn (struct conn_info *conn_info);
 
@@ -184,7 +184,7 @@ struct service_handler clm_service_handler = {
 	.sync_abort					= clm_sync_abort,
 };
 
-static int clm_exec_init_fn (void)
+static int clm_exec_init_fn (struct openais_config *openais_config)
 {
 	memset (clusterNodes, 0, sizeof (SaClmClusterNodeT) * NODE_MAX);
 

+ 2 - 2
exec/evs.c

@@ -69,7 +69,7 @@ static DECLARE_LIST_INIT (confchg_notify);
 /*
  * Service Interfaces required by service_message_handler struct
  */
-static int evs_executive_initialize (void);
+static int evs_executive_initialize (struct openais_config *);
 
 static int evs_confchg_fn (
 	enum totem_configuration_type configuration_type,
@@ -133,7 +133,7 @@ struct service_handler evs_service_handler = {
 	.exec_dump_fn				= 0
 };
 
-static int evs_executive_initialize (void)
+static int evs_executive_initialize (struct openais_config *openais_config)
 {
 	return (0);
 }

+ 1 - 1
exec/handlers.h

@@ -65,7 +65,7 @@ struct service_handler {
 	int (*libais_init_fn) (struct conn_info *conn_info, void *msg);
 	int (*libais_init_two_fn) (struct conn_info *conn_info);
 	int (*libais_exit_fn) (struct conn_info *conn_info);
-	int (*exec_init_fn) (void);
+	int (*exec_init_fn) (struct openais_config *);
 	void (*exec_dump_fn) (void);
 
 	void (*sync_init) (void);

+ 5 - 6
exec/main.c

@@ -967,7 +967,7 @@ static void aisexec_tty_detach (void)
 #undef DEBUG
 }
 
-static void aisexec_service_handlers_init (void)
+static void aisexec_service_handlers_init (struct openais_config *openais_config)
 {
 	int i;
 	/*
@@ -978,7 +978,7 @@ static void aisexec_service_handlers_init (void)
 			if (!ais_service_handlers[i]->exec_init_fn) {
 				continue;
 			}
-			ais_service_handlers[i]->exec_init_fn ();
+			ais_service_handlers[i]->exec_init_fn (openais_config);
 		}
 	}
 }
@@ -1144,14 +1144,13 @@ int main (int argc, char **argv)
 		mklog (LOG_LEVEL_NOTICE, LOG_SERVICE_GMI),
 		mklog (LOG_LEVEL_DEBUG, LOG_SERVICE_GMI));
 
-	totempg_initialize (&openais_config.mcast_addr, openais_config.interfaces, 1,
+	totempg_initialize (&openais_config,
 		&aisexec_poll_handle,
 		private_key,
 		sizeof (private_key),
 		0,
 		0,
-		deliver_fn, confchg_fn,
-		openais_config.timeouts);
+		deliver_fn, confchg_fn);
 	
 	this_ip = &openais_config.interfaces[0].boundto;
 
@@ -1181,7 +1180,7 @@ int main (int argc, char **argv)
 
 	signal (SIGINT, sigintr_handler);
 
-	aisexec_service_handlers_init ();
+	aisexec_service_handlers_init (&openais_config);
 
 	aisexec_libais_bind (&libais_server_fd);
 

+ 19 - 1
exec/parse.c

@@ -64,7 +64,8 @@ typedef enum {
 	MAIN_NETWORK,
 	MAIN_LOGGING,
 	MAIN_KEY,
-	MAIN_TIMEOUT
+	MAIN_TIMEOUT,
+	MAIN_EVENT
 } main_parse_t;
 
 void setSaNameT (SaNameT *name, char *str) {
@@ -418,6 +419,7 @@ extern int openais_main_config_read (char **error_string,
 	int logging_parsed = 0;
 	int key_parsed = 0;
 	int timeout_parsed = 0;
+	int event_parsed = 0;
 	char *loc;
 	int i;
 	int parse_done = 0;
@@ -483,6 +485,10 @@ extern int openais_main_config_read (char **error_string,
 			if (timeout_parsed == 0 && strstr_rs (line, "timeout{")) {
 				timeout_parsed = 1;
 				parse = MAIN_TIMEOUT;
+			} else 
+			if (event_parsed == 0 && strstr_rs (line, "event{")) {
+				event_parsed = 1;
+				parse = MAIN_EVENT;
 			} else {
 				goto parse_error;
 			}
@@ -578,6 +584,18 @@ extern int openais_main_config_read (char **error_string,
 			}
 			break;
 
+		case MAIN_EVENT:
+			if ((loc = strstr_rs (line, "delivery_queue_size:"))) {
+					openais_config->evt_delivery_queue_size = atoi(loc);
+			} else if ((loc = strstr_rs (line, "delivery_queue_resume:"))) {
+					openais_config->evt_delivery_queue_resume = atoi(loc);
+			} else if ((loc = strstr_rs (line, "}"))) {
+				parse = MAIN_HEAD;
+			} else {
+				goto parse_error;
+			}
+			break;
+
 		default:
 			assert (0 == 1); /* SHOULDN'T HAPPEN */
 			break;	

+ 25 - 0
exec/parse.h

@@ -55,6 +55,25 @@ enum amfOperationalAdministrativeState {
 	AMF_ENABLED_STOPPING = 3
 };
 
+/*
+ * Array location of various timeouts as
+ * specified in openais.conf.  The last enum
+ * specifies the size of the timeouts array and
+ * needs to remain the last item in the list.
+ */
+enum {
+	TOTEM_TOKEN,
+	TOTEM_RETRANSMIT_TOKEN,
+	TOTEM_JOIN,
+	TOTEM_CONSENSUS,
+	TOTEM_MERGE,
+	TOTEM_DOWNCHECK,
+	TOTEM_FAIL_RECV_CONST,
+
+	MAX_TOTEM_TIMEOUTS	/* Last item */
+} totem_timeout_types;
+
+
 struct openais_config {
 	/*
 	 * network
@@ -79,6 +98,12 @@ struct openais_config {
 	 * Timeout
 	 */
 	unsigned int timeouts[MAX_TOTEM_TIMEOUTS];
+
+	/*
+	 * Event service
+	 */
+	unsigned int evt_delivery_queue_size;
+	unsigned int evt_delivery_queue_resume;
 };
 
 struct saAmfUnit {

+ 4 - 10
exec/totempg.c

@@ -435,9 +435,7 @@ int callback_token_received_fn (enum totem_callback_token_type type,
  * Initialize the totem process group abstraction
  */
 int totempg_initialize (
-	struct sockaddr_in *sockaddr_mcast,
-	struct totem_interface *interfaces,
-	int interface_count,
+	struct openais_config *openais_config,
 	poll_handle *poll_handle,
 	unsigned char *private_key,
 	int private_key_len,
@@ -453,22 +451,18 @@ int totempg_initialize (
 		struct in_addr *member_list, int member_list_entries,
 		struct in_addr *left_list, int left_list_entries,
 		struct in_addr *joined_list, int joined_list_entries,
-		struct memb_ring_id *ring_id),
-	unsigned int *timeouts)
+		struct memb_ring_id *ring_id))
 {
 	int res;
 
 	app_deliver_fn = deliver_fn;
 	app_confchg_fn = confchg_fn;
 
-	res = totemsrp_initialize (sockaddr_mcast,
-		interfaces,
-		interface_count,
+	res = totemsrp_initialize (openais_config,
 		poll_handle,
 		private_key, private_key_len,
 		member_private, member_private_len,
-		totempg_deliver_fn, totempg_confchg_fn, 
-		timeouts);
+		totempg_deliver_fn, totempg_confchg_fn);
  
 	totemsrp_callback_token_create (&callback_token_received_handle, 
 		TOTEM_CALLBACK_TOKEN_RECEIVED,

+ 3 - 5
exec/totempg.h

@@ -38,6 +38,7 @@
 #include <netinet/in.h>
 #include "aispoll.h"
 #include "totemsrp.h"
+#include "parse.h"
 
 #define MESSAGE_SIZE_MAX		256000
 
@@ -63,9 +64,7 @@ void totempg_log_printf_init (
  * Initialize the group messaging interface
  */
 int totempg_initialize (
-	struct sockaddr_in *sockaddr_mcast,
-	struct totem_interface *interfaces,
-	int interface_count,
+	struct openais_config *openais_config,
 	poll_handle *poll_handle,
 	unsigned char *private_key,
 	int private_key_len,
@@ -81,8 +80,7 @@ int totempg_initialize (
 		struct in_addr *member_list, int member_list_entries,
 		struct in_addr *left_list, int left_list_entries,
 		struct in_addr *joined_list, int joined_list_entries,
-		struct memb_ring_id *ring_id),
-	unsigned int *timeouts);
+		struct memb_ring_id *ring_id));
 
 /*
  * Multicast a message

+ 15 - 14
exec/totemsrp.c

@@ -570,9 +570,7 @@ void print_msg (unsigned char *msg, int size)
  * Exported interfaces
  */
 int totemsrp_initialize (
-	struct sockaddr_in *sockaddr_mcast,
-	struct totem_interface *interfaces,
-	int interface_count,
+	struct openais_config *openais_config,
 	poll_handle *poll_handle,
 	unsigned char *private_key,
 	int private_key_len,
@@ -588,9 +586,10 @@ int totemsrp_initialize (
 		struct in_addr *member_list, int member_list_entries,
 		struct in_addr *left_list, int left_list_entries,
 		struct in_addr *joined_list, int joined_list_entries,
-		struct memb_ring_id *ring_id),
-	unsigned int *timeouts)
+		struct memb_ring_id *ring_id))
 {
+	unsigned int *timeouts = openais_config->timeouts;
+
 	int i;
 
 	/*
@@ -605,7 +604,8 @@ int totemsrp_initialize (
 	/*
 	 * Initialize local variables for totemsrp
 	 */
-	memcpy (&sockaddr_in_mcast, sockaddr_mcast, sizeof (struct sockaddr_in));
+	memcpy (&sockaddr_in_mcast, &openais_config->mcast_addr, 
+			sizeof (struct sockaddr_in));
 	memset (&next_memb, 0, sizeof (struct sockaddr_in));
 	memset (iov_buffer, 0, PACKET_SIZE_MAX);
 
@@ -672,8 +672,9 @@ int totemsrp_initialize (
 	sq_init (&recovery_sort_queue,
 		QUEUE_RTR_ITEMS_SIZE_MAX, sizeof (struct sort_queue_item), 0);
 
-	totemsrp_interfaces = interfaces;
-	totemsrp_interface_count = interface_count;
+	totemsrp_interfaces = openais_config->interfaces;
+	totemsrp_interface_count = 1;
+	/* totemsrp_interface_count = openais_config->interface_count; */
 	totemsrp_poll_handle = poll_handle;
 
 	netif_down_check();
@@ -1208,7 +1209,7 @@ static void memb_state_operational_enter (void)
 	ring_reset ();
 	deliver_messages_from_recovery_to_regular ();
 
-	totemsrp_log_printf (totemsrp_log_level_notice,
+	totemsrp_log_printf (totemsrp_log_level_debug,
 		"Delivering to app %d to %d\n",
 		my_high_delivered + 1, old_ring_state_high_seq_received);
 
@@ -2374,8 +2375,8 @@ static int orf_token_mcast (
 		 */
 		sq_item_add (sort_queue,
 			&sort_queue_item, message_item->mcast->seq);
-		printf ("ORIG [%s.%d-%d]\n", inet_ntoa (message_item->mcast->source),
-			message_item->mcast->seq, message_item->mcast->this_seqno);
+// XXX		printf ("ORIG [%s.%d-%d]\n", inet_ntoa (message_item->mcast->source),
+// XXX			message_item->mcast->seq, message_item->mcast->this_seqno);
 
 		/*
 		 * Delete item from pending queue
@@ -3331,7 +3332,7 @@ static void messages_deliver_to_app (int skip, int end_point)
     int res;
     struct mcast *mcast;
 
-	totemsrp_log_printf (totemsrp_log_level_notice,
+	totemsrp_log_printf (totemsrp_log_level_debug,
 		"Delivering %d to %d\n", my_high_delivered + 1,
 		end_point);
 
@@ -3360,8 +3361,8 @@ printf ("-skipping %d-\n", i);
 		mcast = sort_queue_item_p->iovec[0].iov_base;
 		assert (mcast != (struct mcast *)0xdeadbeef);
 
-		printf ("[%s.%d-%d]\n", inet_ntoa (mcast->source),
-			mcast->seq, mcast->this_seqno);
+// XXX		printf ("[%s.%d-%d]\n", inet_ntoa (mcast->source),
+// XXX			mcast->seq, mcast->this_seqno);
 
 		/*
 		 * Skip messages not originated in my_deliver_memb

+ 3 - 23
exec/totemsrp.h

@@ -36,6 +36,7 @@
 
 #include "totem.h"
 #include "aispoll.h"
+#include "parse.h"
 
 #define TOTEMSRP_PACKET_SIZE_MAX	1404
 
@@ -58,9 +59,7 @@ void totemsrp_log_printf_init (
  * Initialize the group messaging interface
  */
 int totemsrp_initialize (
-	struct sockaddr_in *sockaddr_mcast,
-	struct totem_interface *interfaces,
-	int interface_count,
+	struct openais_config *openais_config,
 	poll_handle *poll_handle,
 	unsigned char *private_key,
 	int private_key_len,
@@ -77,26 +76,7 @@ int totemsrp_initialize (
 		struct in_addr *member_list, int member_list_entries,
 		struct in_addr *left_list, int left_list_entries,
 		struct in_addr *joined_list, int joined_list_entries,
-		struct memb_ring_id *ring_id),
-	unsigned int *timeouts);
-
-/*
- * Array location of various timeouts as
- * specified in openais.conf.  The last enum
- * specifies the size of the timeouts array and
- * needs to remain the last item in the list.
- */
-enum {
-	TOTEM_TOKEN,
-	TOTEM_RETRANSMIT_TOKEN,
-	TOTEM_JOIN,
-	TOTEM_CONSENSUS,
-	TOTEM_MERGE,
-	TOTEM_DOWNCHECK,
-	TOTEM_FAIL_RECV_CONST,
-
-	MAX_TOTEM_TIMEOUTS	/* Last item */
-} totem_timeout_types;
+		struct memb_ring_id *ring_id));
 
 /*
  * Multicast a message