![]() |
|||
![]() |
![]() ![]() |
![]() |
![]() ![]() |
![]() |
![]() ![]() |
![]() |
| |||
Chapter 4Building CMM ApplicationsFor information about how to build applications that use the CMM API, see the following sections: Installing Applications on a ClusterIf your application is to be run on a master-eligible node, install the application binary files on the node. If your application is to be run on a diskless node, install the binaries from the master node in: /export/root/diskless_node_name/path where diskless_node_name is the name of the diskless node and path is the path to the application. For example, if the binaries are installed in the /opt/mySvc/bin/myapp directory, the application binaries are installed in the /export/root/NetraDiskless1/opt/mySvc/bin/myapp directory for the NetraDiskless1 diskless node. For definitions of the terms diskfull, diskless, and dataless nodes, see "Cluster Model" in the Netra High Availability Suite Foundation Services 2.1 6/03 Overview. Installing Libraries and Header FilesEnsure that the library contents and header files of the Foundation Services are available in the runtime environment of your development host. This includes the CMM header (.h) files and library (.so and .a) files. These files are delivered in the SUNWnhcmd developer package. In this way these files can be installed on your development host without having to install a running Foundation Services CMM. The SUNWnhcmd developer package requires that the SUNWnhcdt trace package is present. You can write your applications on your development host using the CMM API libraries and header files, but you cannot successfully run your applications on your development host. For highly available cluster-based applications, run your applications on a cluster that is running the Foundation Services.
|
# pkgadd -d /software-distribution-dir/Packages/ SUNWnhcmd SUNWnhcdt |
Where software-distribution-dir is the location of the software distribution.
After installing the packages, the libcgha_cmm library is available in the /opt/SUNWcgha/lib/ directory, and the header files are available in the /opt/SUNWcgha/include/ directory.
Note - The code examples provided in this guide require you to install the library and header files in these default locations.
The CMM API is provided by the libcgha_cmm.so library. The libcgha_cmm library communicates with the nhcmmd daemon, which is monitored by the Daemon Monitor, nhpmd. For further information on the nhcmmd daemon, see the nhcmmd(1M) man page. For more information on the Daemon Monitor, see the nhpmd(1M) man page.
You must link the libcgha_cmm library to your application. To do this, set the LD_LIBRARY_PATH variable to the /opt/SUNWcgha/lib/ directory.
The services that these libraries use are only available when you run your applications on the fully installed cluster running the Foundation Services. For more information see Setting up a Foundation Services Cluster.
To enable the compiler and linker to locate the required header files and libraries, specify the following entries in your Makefile:
CFLAGS += -I/opt/SUNWcgha/include LDFLAGS += -L/opt/SUNWcgha/lib \ -R/opt/SUNWcgha/lib |
Note - These entries apply only if the developer package header files and libraries are installed in their default locations. For information on installing the header files and libraries required by developers, see Installing Libraries and Header Files.
For an example Makefile that uses a specified code example, see Example 4-4. An example Makefile is provided within the developer package of the Foundation Services, and is shown in Example Makefile.
The applications you develop using the CMM API can be compiled using the Sun Forte Developer 6 Software Suite compiler. For more information, refer to the documentation that is supplied with Sun Forte Developer software.
Applications that are to run on a deployed Foundation Services cluster can be started automatically when the node is booted. For this, you can supply a startup script for the application. The startup script should be located in the /etc/init.d/ directory. Link the script to an entry in either the /etc/rc2.d/ directory or the /etc/rc3.d/ directory, and the script will be executed when the node boots. For more information, see the init(1M) Solaris man page.
If you require fast performance from a program, ensure that shared objects linked with the program are locked in memory at runtime. To lock shared objects in memory at runtime, set the LD_BIND_NOW environment variable. For more information on this variable, see the Solaris documentation on "Runtime Linker" in the Linker and Libraries Guide.
For better performance from programs running on diskless nodes in a test cluster, you can set the mlockall() function within your program to lock address space. For more information, see the mlockall(3C) Solaris man page.
Applications that you develop on your development host can be tested on a cluster. For information about supported cluster configurations and how to connect your development host to a cluster, see the Netra High Availability Suite Foundation Services 2.1 6/03 Hardware Guide.
To transfer applications from your development host to a cluster, use one of the following commands:
The code fragment shown in Example 4-1 enables the API to display peer node membership. This code fragment should be included when you run the CMM API examples provided in this guide. This code fragment includes cmm_member_is() functions, which are explained in Chapter 5, Retrieving Node Information Using the CMM API.
Example 4-1 Mandatory Code Fragment: common.c
void print_member( cmm_member_t const *P_Member) { char L_strRole[16]; char L_strQualif[16]; if (cmm_member_ismaster(P_Member)) strcpy(L_strRole, "MASTER"); else if (cmm_member_isvicemaster(P_Member)) strcpy(L_strRole, "VICE-MASTER"); else if (cmm_member_isoutofcluster(P_Member)) strcpy(L_strRole, "OUT"); else strcpy(L_strRole, "IN"); puts("------------------------------") ; printf("node_id = %d\n", P_Member->nodeid) ; printf("domain_id = %d\n", P_Member->domainid) ; printf("name = %s\n", P_Member->name) ; printf("role = %s\n", L_strRole) ; printf("disqualified = %s\n", (cmm_member_isdisqualified(P_Member))?"NO":"YES") ; printf("synchro. = %s\n", (cmm_member_isdesynchronized(P_Member))?"NEEDED !!!":"READY") ; printf("frozen = %s\n", (cmm_member_isfrozen(P_Member))?"YES":"NO") ; printf("excluded = %s\n", (cmm_member_isexcluded(P_Member))?"YES":"NO") ; printf("eligible = %s\n", (cmm_member_iseligible(P_Member))?"YES":"NO") ; printf("incarn. = %d\n", P_Member->incarnation_number) ; printf("swload_id = %s\n", P_Member->software_load_id) ; printf("CGTP @ = %s\n", P_Member->addr) ; puts("------------------------------") ; } |
![]() ![]() |