static void message_handler_req_lib_cpg_trackstop (void *conn, void *message);
+static void message_handler_req_lib_cpg_local_get (void *conn, void *message);
+
static int cpg_node_joinleave_send (struct group_info *gi, struct process_info *pi, int fn, int reason);
static int cpg_exec_send_joinlist(void);
.response_size = sizeof (struct res_lib_cpg_trackstart),
.response_id = MESSAGE_RES_CPG_TRACKSTOP,
.flow_control = OPENAIS_FLOW_CONTROL_NOT_REQUIRED
+ },
+ { /* 6 */
+ .lib_handler_fn = message_handler_req_lib_cpg_local_get,
+ .response_size = sizeof (struct res_lib_cpg_local_get),
+ .response_id = MESSAGE_RES_CPG_LOCAL_GET,
+ .flow_control = OPENAIS_FLOW_CONTROL_NOT_REQUIRED
}
};
res_lib_cpg_trackstop.header.error = SA_AIS_OK;
openais_conn_send_response(conn, &res_lib_cpg_trackstop.header, sizeof(res_lib_cpg_trackstop));
}
+
+static void message_handler_req_lib_cpg_local_get (void *conn, void *message)
+{
+ struct res_lib_cpg_local_get res_lib_cpg_local_get;
+
+ res_lib_cpg_local_get.header.size = sizeof(res_lib_cpg_local_get);
+ res_lib_cpg_local_get.header.id = MESSAGE_RES_CPG_LOCAL_GET;
+ res_lib_cpg_local_get.header.error = SA_AIS_OK;
+ res_lib_cpg_local_get.local_nodeid = totempg_my_nodeid_get ();
+
+ openais_conn_send_response(conn, &res_lib_cpg_local_get,
+ sizeof(res_lib_cpg_local_get));
+}
struct cpg_address *member_list,
int *member_list_entries);
+cpg_error_t cpg_local_get (
+ cpg_handle_t handle,
+ unsigned int *local_nodeid);
+
cpg_error_t cpg_flow_control_state_get (
cpg_handle_t handle,
cpg_flow_control_state_t *flow_control_enabled);
MESSAGE_REQ_CPG_MCAST = 2,
MESSAGE_REQ_CPG_MEMBERSHIP = 3,
MESSAGE_REQ_CPG_TRACKSTART = 4,
- MESSAGE_REQ_CPG_TRACKSTOP = 5
+ MESSAGE_REQ_CPG_TRACKSTOP = 5,
+ MESSAGE_REQ_CPG_LOCAL_GET = 6
};
enum res_cpg_types {
MESSAGE_RES_CPG_DELIVER_CALLBACK = 5,
MESSAGE_RES_CPG_TRACKSTART = 6,
MESSAGE_RES_CPG_TRACKSTOP = 7,
- MESSAGE_RES_CPG_FLOW_CONTROL_STATE_SET = 8
+ MESSAGE_RES_CPG_FLOW_CONTROL_STATE_SET = 8,
+ MESSAGE_RES_CPG_LOCAL_GET = 9
};
enum lib_cpg_confchg_reason {
mar_res_header_t header __attribute__((aligned(8)));
};
+struct req_lib_cpg_local_get {
+ mar_req_header_t header __attribute__((aligned(8)));
+};
+
+struct res_lib_cpg_local_get {
+ mar_res_header_t header __attribute__((aligned(8)));
+ mar_uint32_t local_nodeid __attribute__((aligned(8)));
+};
+
struct req_lib_cpg_mcast {
mar_res_header_t header __attribute__((aligned(8)));
mar_uint32_t guarantee __attribute__((aligned(8)));
return (error);
}
+cpg_error_t cpg_local_get (
+ cpg_handle_t handle,
+ unsigned int *local_nodeid)
+{
+ cpg_error_t error;
+ struct cpg_inst *cpg_inst;
+ struct iovec iov;
+ struct req_lib_cpg_local_get req_lib_cpg_local_get;
+ struct res_lib_cpg_local_get res_lib_cpg_local_get;
+
+ error = saHandleInstanceGet (&cpg_handle_t_db, handle, (void *)&cpg_inst);
+ if (error != SA_AIS_OK) {
+ return (error);
+ }
+
+ req_lib_cpg_local_get.header.size = sizeof (mar_req_header_t);
+ req_lib_cpg_local_get.header.id = MESSAGE_REQ_CPG_LOCAL_GET;
+
+ iov.iov_base = &req_lib_cpg_local_get;
+ iov.iov_len = sizeof (struct req_lib_cpg_local_get);
+
+ pthread_mutex_lock (&cpg_inst->response_mutex);
+
+ error = saSendMsgReceiveReply (cpg_inst->response_fd, &iov, 1,
+ &res_lib_cpg_local_get, sizeof (res_lib_cpg_local_get));
+
+ pthread_mutex_unlock (&cpg_inst->response_mutex);
+
+ if (error != SA_AIS_OK) {
+ goto error_exit;
+ }
+
+ error = res_lib_cpg_local_get.header.error;
+
+ *local_nodeid = res_lib_cpg_local_get.local_nodeid;
+
+error_exit:
+ saHandleInstancePut (&cpg_handle_t_db, handle);
+
+ return (error);
+}
+
cpg_error_t cpg_flow_control_state_get (
cpg_handle_t handle,
cpg_flow_control_state_t *flow_control_state)
groff -mandoc -Thtml cpg_membership_get.3 > html/cpg_membership_get.html
groff -mandoc -Thtml cpg_context_get.3 > html/cpg_context_get.html
groff -mandoc -Thtml cpg_context_set.3 > html/cpg_context_set.html
+ groff -mandoc -Thtml cpg_local_get.3 > html/cpg_local_get.html
cp index.html html
--- /dev/null
+.\"/*
+.\" * Copyright (c) 2007 Red Hat, Inc.
+.\" *
+.\" * All rights reserved.
+.\" *
+.\" * Author: Steven Dake <sdake@redhat.com>
+.\" *
+.\" * 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.
+.\" */
+.TH CPG_LOCAL_GET 3 2007-06-12 "openais Man Page" "Openais Programmer's Manual"
+.SH NAME
+cpg_local_get \- Returns the local processor id
+.SH SYNOPSIS
+.B #include <openais/cpg.h>
+.sp
+.BI "int cpg_local_get(cpg_handle_t " handle ", unsigned int *" local_nodeid ");
+.SH DESCRIPTION
+The
+.B cpg_local_get
+function is used to determine the local processor's identifier.
+.BR
+The argument
+.I handle
+is used to reference the cpg instantiation.
+The argument
+.I local_nodeid
+will return the 32 bit node id.
+.PP
+.SH ERRORS
+The errors are undocumented.
+.SH "SEE ALSO"
+.BR cpg_overview (8),
+.BR cpg_initialize (3),
+.BR cpg_finalize (3),
+.BR cpg_fd_get (3),
+.BR cpg_dispatch (3),
+.BR cpg_leave (3),
+.BR cpg_mcast_joined (3),
+.BR cpg_membership_get (3)
+.PP
<A HREF="cpg_mcast_joined.html">cpg_mcast_joined(3)</A>: Description of the cpg_mcast_joined interface.
<BR>
<A HREF="cpg_membership_get.html">cpg_membership_get(3)</A>: Description of the cpg_membership_get interface.
+<BR>
+<A HREF="cpg_local_get.html">cpg_local_get(3)</A>: Description of the cpg_local_get interface.
</body>
testckpt ckptstress ckptbench \
ckptbenchth ckpt-rd ckpt-wr testevt testevs \
evsbench subscription publish evtbench unlink testclm2 testlck \
- testmsg testcpg cpgbench openais-cfgtool
+ testmsg testcpg testcpg2 cpgbench openais-cfgtool
testtimer: testtimer.o $(LIBRARIES)
$(CC) $(LDFLAGS) -o testtimer testtimer.o ../exec/timer.o
testcpg: testcpg.o $(LIBRARIES)
$(CC) $(LDFLAGS) -o testcpg testcpg.o $(LIBS)
+testcpg2: testcpg2.o $(LIBRARIES)
+ $(CC) $(LDFLAGS) -o testcpg2 testcpg2.o $(LIBS)
+
cpgbench: cpgbench.o $(LIBRARIES)
$(CC) $(LDFLAGS) -o cpgbench cpgbench.o $(LIBS)
/*
- * Copyright (c) 2006 Red Hat Inc
+ * Copyright (c) 2006-2007 Red Hat Inc
*
* All rights reserved.
*
int i;
struct in_addr saddr;
- printf("\nConfchgCallback: group '"); print_cpgname(groupName); printf("'\n");
+ printf("\nConfchgCallback: group '");
+ print_cpgname(groupName);
+ printf("'\n");
for (i=0; i<joined_list_entries; i++) {
if (show_ip) {
saddr.s_addr = joined_list[i].nodeid;
int result;
const char *options = "i";
int opt;
+ unsigned int nodeid;
while ( (opt = getopt(argc, argv, options)) != -1 ) {
switch (opt) {
printf ("Could not initialize Cluster Process Group API instance error %d\n", result);
exit (1);
}
+ result = cpg_local_get (handle, &nodeid);
+ if (result != SA_AIS_OK) {
+ printf ("Could not get local node id\n");
+ exit (1);
+ }
+
+ printf ("Local node id is %x\n", nodeid);
result = cpg_join(handle, &group_name);
if (result != SA_AIS_OK) {
printf ("Could not join process group, error %d\n", result);