sun.com | docs.sun.com | How To Buy | My Sun | Worldwide Sites |  |

| Previous Contents Index Next
Chapter 7 # Managing Changes in the Cluster State This chapter describes how to receive and react to notifications about changes in the cluster state, with examples on how to respond to these notifications by modifying the state of the cluster. For more information, see the following topics: Setting a Timeout Value for Calls to the `nhcmmd`Daemon Reloading the Cluster Node Table Receiving and Handling Change Notifications Responding to Cluster Notifications by Modifying the Cluster ## Setting a Timeout Value for Calls to the `nhcmmd` Daemon The timeout parameter is used globally by the CMM API to signify the maximum amount of time a call can block. A different timeout can be set for each client. Using the `cmm_connect()` function, you can: Call the `nhcmmd` daemon. Set the timeout value for subsequent calls to the `nhcmmd` daemon. The default value is five seconds. Note - The `cmm_connect()` function is called implicitly by the first call to the CMM API. You do not need to call the `cmm_connect()` function to create a connection between an application and the `nhcmmd` daemon on a node. If you do not set the timeout, it remains at the default value of five seconds. The new value of the timeout is not used by the call with which you set it. The `cmm_connect()` function can be called from any node, even a node that has been excluded from the cluster for administrative reasons. The `cmm_connect()` function does not use information provided by the CMM API. For further information, see the `cmm_connect`(3CMM) man page. The `cmm_disconnect()` function closes the connection between the current calling process and the `nhcmmd` daemon. For more information about this, see the `nhcmmd`(1M) and `nhfs.conf`(4) man pages. This frees the resources allocated to the client connection. If notifications were registered, they are no longer sent. For information about notifications, see Chapter 6, Understanding Change Notifications. The `cmm_connect()` and `cmm_disconnect()` functions cannot be called within a callback function. The following example demonstrates how to use the `cmm_connect()` function to set a timeout: Example 7-1 Setting a Timeout Using the `cmm_connect()` Function
    #include <cmm.h>
    #include <stdio.h>
    #include <stdlib.h>        /* for exit() */
    #include <strings.h>        /* for strcpy */
    #include "common.h"

    /**************************************************************/
    void main(void)
    {
        cmm_error_t  res;
        timespec_t   time-out = { 1 /*seconds*/, 500000000 /* nanoseconds */};

        /* test connection and set time-out */
        if ((res = cmm_connect(timeout))!= CMM_OK) {
            printf("problem to connect to local CMM: %s -> abort\n",
                cmm_strerror(res));
            exit(1);
        }
        exit(0) ;
    }
## Reloading the Cluster Node Table The `cmm_config_reload()` function can be called from the master node to make the `nhcmmd` daemon reload the cluster node table. Use this function when a node is added to or removed from the cluster node table. The only permitted operations here are addition and removal of a node. For more information about adding and removing a node, see the Netra High Availability Suite Foundation Services 2.1 6/03 Cluster Administration Guide. You cannot use the cluster node table to edit a node's attributes. Use the CMM API to do this. For example, use the `cmm_member_setqualif`(3CMM)function. For more information, see the `cmm_config_reload`(3CMM), `cluster_nodes_table`(4), and `nhcmmd`(1M) man pages. Caution - If you want to add a node make sure it is powered on before you reload the cluster node table. If you want to remove a node make sure it is powered off before you reload the cluster node table. This ensures that you cannot remove the master node from the table. ## Receiving and Handling Change Notifications You can use the CMM API to register and unregister for notifications that indicate a change in the cluster. You can also configure your applications to filter, receive, and dispatch these notifications. This information applies to the CMM API only and is separate from the process of registering for notifications sent by the Node Management Agent (NMA). For more information, see "Registering to Receive Notifications" in the Netra High Availability Suite Foundation Services 2.1 6/03 NMA Programming Guide. You can manage the handling of notifications in general by using the following functions: `cmm_cmc_register()` `cmm_cmc_unregister()` `cmm_cmc_filter()` `cmm_notify_getfd()` `cmm_notify_dispatch()` This section contains the following topics: Registering to Receive Notifications. Filtering Notifications. Receiving and Dispatching Notifications. Retrieving Change Notifications.
Previous Contents Index Next

Copyright 1994-2004 Sun Microsystems