Appendix ASource Code Examples
The Foundation Services product provides a set of source code examples
in the SUNWnhcmd developer package. The examples are described
in detail in the following sections:
CMM API Code Examples
The examples
in this section use the functions of the CMM API. These examples are located
in subdirectories of the /opt/SUNWcgha/examples/ directory.
You can compile these examples on your development host and test the programs
on your cluster.
Before running these code examples, create the following Makefile:
Example Makefile
The Makefile given in Example A-1 is provided
with the SUNWcgha package for use with the examples provided
within this appendix.
Example A-1 Sample Makefile
#
# Copyright (c) 2002 by Sun Microsystems, Inc.
# All rights reserved.
#
#
# ident "@(#)Makefile.ex 1.4 02/06/05 SMI"
#
#
############################################################
# Path to the directory where SUNWnhcmd package is installed
############################################################
NHCMMD_PKG_INSTALL_DIR=/opt/SUNWcgha
LDFLAGS= -L"$(NHCMMD_PKG_INSTALL_DIR)/lib" \
-lcgha_cmm \
-R"$(NHCMMD_PKG_INSTALL_DIR)/lib" \
-lpthread
CFLAGS= -I"/usr/local/include" \
-I$(NHCMMD_PKG_INSTALL_DIR)/include/
CC=cc
COMPILE=$(CC) $(CFLAGS) $(LDFLAGS)
BINS= smpl_cmm_node_getid \
smpl_cmm_member_getinfo \
smpl_cmm_master_getinfo \
smpl_cmm_vicemaster_getinfo \
smpl_cmm_member_getcount_all \
smpl_cmm_member_getcount_all_2 \
smpl_cmm_notification \
smpl_cmm_member_setqualif
all:$(BINS)
smpl_cmm_node_getid:smpl_cmm_node_getid.c
@echo "CC smpl_cmm_node_getid.c"
@$(COMPILE) smpl_cmm_node_getid.c -o smpl_cmm_node_getid
smpl_cmm_member_getinfo:smpl_cmm_member_getinfo.c
@echo "CC smpl_cmm_member_getinfo.c"
@$(COMPILE) smpl_cmm_member_getinfo.c -o smpl_cmm_member_getinfo
smpl_cmm_master_getinfo:smpl_cmm_master_getinfo.c
@echo "CC smpl_cmm_master_getinfo.c"
@$(COMPILE) smpl_cmm_master_getinfo.c -o smpl_cmm_master_getinfo
smpl_cmm_vicemaster_getinfo:smpl_cmm_vicemaster_getinfo.c
@echo "CC smpl_cmm_vicemaster_getinfo.c"
@$(COMPILE) smpl_cmm_vicemaster_getinfo.c -o smpl_cmm_vicemaster_getinfo
smpl_cmm_member_getcount_all:smpl_cmm_member_getcount_all.c
@echo "CC smpl_cmm_member_getcount_all.c"
@$(COMPILE) smpl_cmm_member_getcount_all.c
-o smpl_cmm_member_getcount_all
smpl_cmm_member_getcount_all_2:smpl_cmm_member_getcount_all_2.c
@echo "CC smpl_cmm_member_getcount_all_2.c"
@$(COMPILE) smpl_cmm_member_getcount_all_2.c
-o smpl_cmm_member_getcount_all_2
smpl_cmm_notification:smpl_cmm_notification.c
@echo "CC smpl_cmm_notification.c"
@$(COMPILE) smpl_cmm_notification.c -o smpl_cmm_notification
smpl_cmm_member_setqualif:smpl_cmm_member_setqualif.c
@echo "CC smpl_cmm_member_setqualif.c"
@$(COMPILE) smpl_cmm_member_setqualif.c -o smpl_cmm_member_setqualif
clean:
rm -f core *~
cleanall:clean
rm -f $(BINS)
|
|