This patch makes the event service work in trunk of openais.
This relies on a patch for corosync trunk which allows loading and
unloading of interfaces from the coroapi. The event service now loads
the external services programming interface for the clm service and
allows the event service to query information from the clm service.
The API could be anything really but this is what was needed by the clm
service.
For examples of how this works and the current api available, look at
services/clm.h.
Regards
-steve
Index: test/Makefile
===================================================================
--- test/Makefile (revision 1624)
+++ test/Makefile (working copy)
@@ -37,9 +37,9 @@
override LDFLAGS += -lnsl -lsocket -lrt
endif
-LIBRARIES= ../lib/libSaCkpt.a ../lib/libSaMsg.a sa_error.o
+LIBRARIES= ../lib/libSaCkpt.a ../lib/libSaMsg.a ../lib/libSaEvt.a sa_error.o
LIBS = $(LIBRARIES)
-BINARIES= testckpt testmsg testmsg2
+BINARIES= testckpt testmsg testmsg2 testevt
override CFLAGS += -I../include
override LDFLAGS += -L../lib
@@ -58,6 +58,8 @@
testmsg2: testmsg2.o $(LIBRARIES)
$(CC) $(LDFLAGS) -o testmsg2 testmsg2.o $(LIBS)
+testevt: testevt.o $(LIBRARIES)
+ $(CC) $(LDFLAGS) -o testevt testevt.o $(LIBS)
clean:
rm -f *.o $(LIBRARIES) $(BINARIES)
Index: services/evt.c
===================================================================
--- services/evt.c (revision 1624)
+++ services/evt.c (working copy)
@@ -60,6 +60,7 @@
#include "../include/saAis.h"
#include "../include/saEvt.h"
#include "../include/ipc_evt.h"
+#include "clm.h"
LOGSYS_DECLARE_SUBSYS ("EVT", LOG_INFO);
/*
@@ -117,6 +118,7 @@
static int evt_lib_init(void *conn);
static int evt_lib_exit(void *conn);
static int evt_exec_init(struct corosync_api_v1 *);
+static int evt_exec_exit(void);
/*
* Recovery sync functions
@@ -131,6 +133,10 @@
struct corosync_api_v1 *api;
+static struct openais_clm_services_api_ver1 *clmapi;
+
+static unsigned int clm_services_api_handle;
+
static struct corosync_lib_handler evt_lib_engine[] = {
{
.lib_handler_fn = lib_evt_open_channel,
@@ -218,6 +224,7 @@
.lib_engine = evt_lib_engine,
.lib_engine_count = sizeof(evt_lib_engine) / sizeof(struct corosync_lib_handler),
.exec_init_fn = evt_exec_init,
+ .exec_exit_fn = evt_exec_exit,
.exec_engine = evt_exec_engine,
.exec_engine_count = sizeof(evt_exec_engine) / sizeof(struct corosync_exec_handler),
.exec_dump_fn = NULL,
@@ -1448,14 +1455,13 @@
struct member_node_data *nd;
SaClmClusterNodeT *cn;
-#ifdef TODO
nd = evt_find_node(nodeid);
if (!nd) {
log_printf(LOG_LEVEL_DEBUG,
"Node ID %s not found for event %llx\n",
api->totem_ifaces_print (evtpkt->led_publisher_node_id),
(unsigned long long)evtpkt->led_event_id);
- cn = main_clm_get_by_nodeid(nodeid);
+ cn = clmapi->nodeid_saf_get(nodeid);
if (!cn) {
log_printf(LOG_LEVEL_DEBUG,
"Cluster Node 0x%s not found for event %llx\n",
@@ -1475,7 +1481,6 @@
nd->mn_last_msg_id = evtpkt->led_msg_id;
return 0;
}
- #endif
return 1;
}
@@ -3119,6 +3124,7 @@
api = corosync_api;
+ clmapi = openais_clm_services_api_reference (api, &clm_services_api_handle);
log_printf(LOG_LEVEL_DEBUG, "Evt exec init request\n");
api->object_find_create (
@@ -3182,6 +3188,12 @@
return 0;
}
+static int evt_exec_exit(void)
+{
+ openais_clm_services_api_release (api, clm_services_api_handle);
+ return (0);
+}
+
static int
try_deliver_event(struct event_data *evt,
struct event_svr_channel_instance *eci)
@@ -3246,8 +3258,7 @@
* See where the message came from so that we can set the
* publishing node id in the message before delivery.
*/
-#ifdef TODO
- cn = main_clm_get_by_nodeid(nodeid);
+ cn = clmapi->nodeid_saf_get(nodeid);
if (!cn) {
/*
* Not sure how this can happen...
@@ -3263,7 +3274,6 @@
evtpkt->led_publisher_node_id = nodeid;
evtpkt->led_nodeid = nodeid;
evtpkt->led_receive_time = clust_time_now();
-#endif
if (evtpkt->led_chan_unlink_id != EVT_CHAN_ACTIVE) {
log_printf(CHAN_UNLINK_DEBUG,
@@ -3681,14 +3691,13 @@
struct member_node_data *mn;
struct event_svr_channel_instance *eci;
-#ifdef TODO
log_printf(REMOTE_OP_DEBUG, "Remote channel operation request\n");
- my_node = main_clm_get_by_nodeid(local_node);
+ my_node = clmapi->nodeid_saf_get(local_node);
log_printf(REMOTE_OP_DEBUG, "my node ID: 0x%x\n", my_node->nodeId);
mn = evt_find_node(nodeid);
if (mn == NULL) {
- cn = main_clm_get_by_nodeid(nodeid);
+ cn = clmapi->nodeid_saf_get(nodeid);
if (cn == NULL) {
log_printf(LOG_LEVEL_WARNING,
"Evt remote channel op: Node data for nodeid %d is NULL\n",
@@ -3699,7 +3708,6 @@
mn = evt_find_node(nodeid);
}
}
-#endif
switch (cpkt->chc_op) {
/*
@@ -4032,15 +4040,13 @@
/*
* Set the base event id
*/
- #ifdef TODO
if (!my_node_id) {
- cn = main_clm_get_by_nodeid(my_node);
+ cn = clmapi->nodeid_saf_get(my_node);
log_printf(RECOVERY_DEBUG, "My node ID %s\n",
api->totem_ifaces_print (cn->nodeId));
my_node_id = cn->nodeId;
set_event_id(my_node_id);
}
-#endif
/*
* account for nodes that left the membership
@@ -4170,8 +4176,7 @@
/*
* Not seen before, add it to our list of nodes.
*/
-#ifdef TODO
- cn = main_clm_get_by_nodeid(*add_list);
+ cn = clmapi->nodeid_saf_get(*add_list);
if (!cn) {
/*
* Error: shouldn't happen
@@ -4183,7 +4188,6 @@
} else {
evt_add_node(*add_list, cn);
}
-#endif
}
add_list++;
Index: services/clm.c
===================================================================
--- services/clm.c (revision 1624)
+++ services/clm.c (working copy)
@@ -68,6 +68,7 @@
#include "../include/saClm.h"
#include "../include/ipc_clm.h"
#include "../include/mar_clm.h"
+#include "clm.h"
LOGSYS_DECLARE_SUBSYS ("CLM", LOG_INFO);
@@ -92,7 +93,7 @@
static DECLARE_LIST_INIT (library_notification_send_listhead);
-SaClmClusterNodeT *clm_get_by_nodeid (unsigned int node_id)
+static SaClmClusterNodeT *clm_services_api_nodeid_saf_get (unsigned int node_id)
{
static SaClmClusterNodeT cluster_node;
int i;
@@ -231,7 +232,11 @@
.corosync_get_service_engine_ver0 = clm_get_service_engine_ver0
};
-static struct lcr_iface openais_clm_ver0[1] = {
+static struct openais_clm_services_api_ver1 clm_services_api_ver1 = {
+ .nodeid_saf_get = clm_services_api_nodeid_saf_get
+};
+
+static struct lcr_iface openais_clm_ver0[2] = {
{
.name = "openais_clm",
.version = 0,
@@ -242,11 +247,22 @@
.constructor = NULL,
.destructor = NULL,
.interfaces = NULL
+ },
+ {
+ .name = "openais_clm_services_api",
+ .version = 0,
+ .versions_replace = 0,
+ .versions_replace_count = 0,
+ .dependencies = 0,
+ .dependency_count = 0,
+ .constructor = NULL,
+ .destructor = NULL,
+ .interfaces = NULL
}
};
static struct lcr_comp clm_comp_ver0 = {
- .iface_count = 1,
+ .iface_count = 2,
.ifaces = openais_clm_ver0
};
@@ -257,6 +273,7 @@
__attribute__ ((constructor)) static void clm_comp_register (void) {
lcr_interfaces_set (&openais_clm_ver0[0], &clm_service_engine_iface);
+ lcr_interfaces_set (&openais_clm_ver0[1], &clm_services_api_ver1);
lcr_component_register (&clm_comp_ver0);
}
Index: services/clm.h
===================================================================
--- services/clm.h (revision 0)
+++ services/clm.h (revision 0)
@@ -0,0 +1,76 @@
+/*
+ * Copyright (c) 2008 Red Hat, Inc.
+ *
+ * All rights reserved.
+ *
+ * Author: Steven Dake ([EMAIL PROTECTED])
+ *
+ * This software licensed under BSD license, the text of which follows:
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * - Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * - Neither the name of the MontaVista Software, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from this
+ * software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "../include/saAis.h"
+#include "../include/saClm.h"
+
+#ifndef CLM_H_DEFINED
+#define CLM_H_DEFINED
+
+struct openais_clm_services_api_ver1 {
+ SaClmClusterNodeT *(*nodeid_saf_get) (unsigned int node_id);
+};
+
+static inline struct openais_clm_services_api_ver1 *
+openais_clm_services_api_reference (
+ struct corosync_api_v1 *coroapi,
+ unsigned int *handle)
+{
+ static void *clm_services_api_p;
+ struct openais_clm_services_api_ver1 *return_api;
+ unsigned int res;
+
+ res = coroapi->plugin_interface_reference (
+ handle,
+ "openais_clm_services_api",
+ 0,
+ &clm_services_api_p,
+ 0);
+ if (res == -1) {
+ return (NULL);
+ }
+ return_api = (struct openais_clm_services_api_ver1 *)clm_services_api_p;
+ return (return_api);
+}
+
+static int inline openais_clm_services_api_release (
+ struct corosync_api_v1 *coroapi,
+ unsigned int handle)
+{
+ unsigned int res;
+
+ res = coroapi->plugin_interface_release (handle);
+ return (res);
+}
+
+#endif /* CLM_H_DEFINED */
_______________________________________________
Openais mailing list
[email protected]
https://lists.linux-foundation.org/mailman/listinfo/openais