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

| Previous Contents Index Next
## Identifying the Properties of a Node The eligibility of a node to become master is determined by properties such as its master-eligibility, qualification level, and synchronization state. The qualification level of a node, relevant only for master-eligible nodes, determines if the node can participate in a master or vice-master election. For information about qualification levels that a node can have, see Qualification Levels. The following functions retrieve information about the eligibility and qualification level of a node: `cmm_member_iseligible()` `cmm_member_isdesynchronized()` `cmm_potential_getinfo()` `cmm_member_isqualified()` `cmm_member_isdisqualified()` If a node is disqualified, it cannot become master or vice-master until it is requalified. Further information can be found in the relevant man pages, such as `cmm_member_iseligible`(3CMM). For an example that demonstrates how to requalify a node, see Example 7-4. The function `cmm_member_isdesynchronized()` tests if the master and vice-master nodes are synchronized. If the master and vice-master nodes are not synchronized, the vice-master node cannot become the master if the master fails. Similarly, at cluster startup, a desynchronized node cannot be elected master even if it is master-eligible and qualified. For more information about synchronization, see the definition of `CMM_FLAG_SYNCHRO_NEEDED` in Administrative Attributes. For more information about the `cmm_member_isdesynchronized()` function, see the `cmm_member_isdesynchronized`(3CMM) man page. The `cmm_member_getinfo()` function returns information for any peer node that is master, vice-master, or in the cluster. The `cmm_potential_getinfo()` function returns information for all peer nodes, even if the node has the `CMM_OUT_OF_CLUSTER` role and might not yet have entered the cluster. The `cmm_member_getinfo()` and `cmm_potential_getinfo()` functions retrieve information about a node identified by nodeid. To find the nodeid, see Example 5-1. Both functions retrieve this information from the `cmm_member_t` structure. For information about these functions, see the `cmm_member_getinfo`(3CMM) and `cmm_potential_getinfo`(3CMM) man pages. Example 5-7 demonstrates how to obtain information about the eligibility of the current node to become master. This example uses the following functions: `cmm_potential_getinfo()` `cmm_member_isdesynchronized()` `cmm_member_iseligible()` `cmm_member_isdisqualified()` Example 5-7 Determining Whether a Node Can Become Master
    #include <cmm.h>
    #include <stdio.h>
    #include <stdlib.h>         /* for exit() */
    #include "common.h"

    /**************************************************************/
    void main(void)
    {
        cmm_error_t  res;
        cmm_nodeid_t currnode;
        cmm_member_t currnode_info;

        /* get the current node id */
        if ((res = cmm_node_getid(&currnode))==CMM_OK)
            printf("Current node id is: %d\n", currnode);
        else {
            printf("Error getting info on local node: %s\n",
                cmm_strerror(res));
            exit(1);
        }
        /* Get the  node info */
        if ((res = cmm_potential_getinfo(currnode, &currnode_info))!=CMM_OK) {
            printf("Failed to get info on current node -> abort") ;
            exit(1);
        }

        if (!cmm_member_iseligible(&currnode_info)) {
            puts("Local node cannot be master (it is not eligible)");
            exit(0) ;
        }

        if (cmm_member_isdisqualified(&currnode_info)) {
            puts("Local node cannot be master (it is not qualified)");
            exit(0) ;
        }

        if (!cmm_member_isdesynchronized(&currnode_info)) {
            puts("Local node can be master");
            exit(0) ;
        }

        /* Here we know the current node is eligible, not disqualified,
         * desynchronized */
        if (!cmm_member_ismaster(&currnode_info))
            puts("Local node can be Vice-master only");
        else
            puts("Local node can be master (and it is)");

    }
## Using the `cmm_member_t` Structure for Information About Member Nodes The `cmm_member_t` structure, contained within the CMM API, is an important source of information about member nodes. This structure contains the following fields:
nodeid | The unique identifier of a node.
name | The user-visible string that identifies a node and is used to format display messages.
addr | Stores the dotted-decimal notation of the node Carrier Grade Transport Protocol (CGTP) address in a string that can be used as a parameter on any architecture. The size of this string is sufficient for IPv4 and IPv6 addresses.
incarnation_number | The instant of the last reboot expressed as the number of seconds elapsed since 00:00:00 UTC, January 1, 1970. The incarnation_number is computed locally by every node and sent to the master node, which dispatches it. Nodes use this field to detect whether another node has rebooted within an interval of time.
sflag | State information about the node. This is a concatenation of the administrative attributes, membership role, and qualification levels. For more detailed information about the `sflag` field, see Using the `sflag` Field of the `cmm_member_t` Structure.
domainid | The unique ID of the cluster that the node can join or has joined. All peer nodes in a cluster have the same domainid. A node can belong to only one cluster and the ID of this cluster is the cluster domainid of the current node.
software_load_id | This field is set at `1`.
Previous Contents Index Next

Copyright 1994-2004 Sun Microsystems