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

| Previous Contents Index Next
### The `cmm_member_getall()` Function The code provided by Example A-4 gets information about all nodes in the cluster by using the `cmm_member_get_all()` function. Example A-4 The `smpl_cmm_member_get_all.c` Program
    /***************************************************************
    * Copyright (c) 2002 by Sun Microsystems, Inc.
    * All rights reserved.
    *
    *
    * ident  "@(#)smpl_cmm_member_getcount_all_2.c 1.2     02/06/05 SMI"
    *
    ****************************************************************/

    #include <stdio.h>
    #include <stdlib.h>
    #include <cmm.h>

    #define MAX_NODE_IN_CLUSTER 256

    int main(int argc , char ** argv) {
      cmm_error_t   cmm_diag;
      uint32_t      nbNodeInCluster;
      cmm_member_t *NodeTable = NULL;
      int           i;

      /*allocate space for the maximum number of nodes*/
    NodeTable =
      (cmm_member_t *)malloc(MAX_NODE_IN_CLUSTER*sizeof(cmm_member_t));
      if (NodeTable == NULL) {
        fprintf(stderr,"Memory allocation error\n");
        exit(1);
      }

      /*Getting information on all nodes in cluster*/

    cmm_diag =
      cmm_member_getall(MAX_NODE_IN_CLUSTER,NodeTable,&nbNodeInCluster);

      if (cmm_diag != CMM_OK) {
        fprintf(stderr,"An error occured during
        cmm_member_getall() call CR=%d\n",cmm_diag);
        fprintf(stderr,"Details: %s\n",cmm_strerror(cmm_diag));
        free(NodeTable);
        exit(1);
      }

      /*free useless space*/
    NodeTable =
    (cmm_member_t *)realloc(NodeTable,nbNodeInCluster*sizeof(cmm_member_t));
      if (NodeTable == NULL) {
        fprintf(stderr,"Memory allocation error\n");
        exit(1);
      }

      printf("Information on cluster:\n");
      for (i = 0 ; i < nbNodeInCluster ; i++) {
        printf("Infornation on node:  %d\n",NodeTable[i].nodeid);
        printf("\tName:               %s\n",NodeTable[i].name);
        printf("\tAdress:             %s\n",NodeTable[i].addr);
        printf("\tDomain Id:          %d\n",NodeTable[i].domainid);
        printf("\tIncarnation number: %d\n",NodeTable[i].incarnation_number);
        printf("\tSoftwareLoad id:    %s\n",NodeTable[i].software_load_id);
        printf("\tRole:               ");
        if      (cmm_member_ismaster(&NodeTable[i]))     printf("MASTER\n");
        else if (cmm_member_isvicemaster(&NodeTable[i]))
        printf("VICE-MASTER\n");
        else printf("IN CLUSTER\n");

        printf("\tQualification:      ");
        if      (cmm_member_isqualified(&NodeTable[i]))
        printf("QUALIFIED\n");
        else if (cmm_member_isdisqualified(&NodeTable[i]))
        printf("DISQUALIFIED\n");

      }

      free(NodeTable);

      exit(0);
    }
### The `cmm_member_getinfo()` Function The code provided by Example A-5 gets information about a named node, in this case `node 10`, by using the `cmm_member__getinfo()` function. Example A-5 The `smpl_cmm_member_getinfo.c` Program
    /**********************************************************
    * Copyright (c) 2002 by Sun Microsystems, Inc.
    * All rights reserved.
    *
    *
    * ident  "@(#)smpl_cmm_member_getinfo.c 1.2     02/06/05 SMI"
    *
    *************************************************************************/

    #include <stdio.h>
    #include <cmm.h>

    int main(int argc , char **argv) {
      cmm_error_t  cmm_diag;
      cmm_nodeid_t node;
      cmm_member_t nodeInfo;

      node = 10;

      /*getting info for node 10*/

      cmm_diag = cmm_member_getinfo(node,&nodeInfo);

      if (cmm_diag != CMM_OK) {
      fprintf(stderr,"An error occured during
      cmm_member_getinfo call, CR=%d: %s\n",cmm_diag,cmm_strerror(cmm_diag));
        exit(1);
      }

      printf("Infornation on node:  %d\n",node);
      printf("\tName:               %s\n",nodeInfo.name);
      printf("\tAdress:             %s\n",nodeInfo.addr);
      printf("\tDomain Id:          %d\n",nodeInfo.domainid);
      printf("\tIncarnation number: %d\n",nodeInfo.incarnation_number);
      printf("\tSoftwareLoad id:    %s\n",nodeInfo.software_load_id);
      printf("\tRole:               ");
      if      (cmm_member_ismaster(&nodeInfo))     printf("MASTER\n");
      else if (cmm_member_isvicemaster(&nodeInfo)) printf("VICE-MASTER\n");
      else                                         printf("IN CLUSTER\n");

      printf("\tQualification:      ");
      if      (cmm_member_isqualified(&nodeInfo))    printf("QUALIFIED\n");
      else if (cmm_member_isdisqualified(&nodeInfo)) printf("DISQUALIFIED\n");

      exit(0);
    }
Previous Contents Index Next

Copyright 1994-2004 Sun Microsystems