Constants
The Clinfo C++ API routines use the constants defined in the clinfo.h file.
| Item | Description |
|---|---|
| CL_MAXNAMELEN | The maximum length of a character string naming a cluster, node, or interface (256). The value of CL_MAXNAMELEN is the same as MAXHOSTNAMELEN, defined in the sys/param.h file. |
| CL_MAX_EN_REQS | The maximum number of event notification requests allowed (10). |
| CL_ERRMSG_LEN | Maximum error message length (128 characters). |
| CLSMUXPD_SVC_PORT | The constants CL_MAXCLUSTERS, CL_MAXNODES, and CL_MAXNETIFS used in previous versions of the software are replaced by macros that provide the current sizes of the various arrays in the data structure. The macros have the same name as the constants they replace. These macros cannot be used as array bounds in declaration statements, as the constants were used. |
| CL_MAXCLUSTERS | Provides current size of space in shared memory for the array holding information about the number of clusters. |
| CL_MAXNODES | Provides current size of space in shared memory for the array holding information about the number of nodes in a cluster. |
| CL_MAXNETIFS | Provides current size of space in shared memory for the array holding information about the number of interfaces attached to a node. |
| CL_MAXGROUPS | Provides current size of space in shared memory for the array holding information about the number of resource groups. |
As an example, the following code fragment illustrates use of the constant CL_MAXNODES to size an array of cluster objects. An example of how to replace this with a call to the routine of the same name follows.
CL_cluster clusters[CL_MAXNODES];
CL_cluster *ret = &clusters[0];
ret = CL_getallinfo(ret, s);
if (s < 0)
cl_errmsg(s);
for (int i=0; i<CL_MAXNODES; i++) {
printf("[%d] cl %d", i, ret[i].clc_clusterid);
printf(" st %d", ret[i].clc_state);
printf(" su %d", ret[i].clc_substate);
printf(" pr %d", ret[i].clc_primary);
printf(" na %s", ret[i].clc_name.name);
}You no longer use the constant CL_MAXNODES.
CL_cluster clusters[8];
CL_cluster *ret = &clusters[0];
int numclus;
numclus = CL_getallinfo(ret, s);
if (s < 0)
cl_perror(s, progname);
printf("number of clusters found: %d", numclus);
for (int i=0; i<numclus; i++) {
printf("[%d] cl %d", i, ret[i].clc_clusterid);
printf(" st %d", ret[i].clc_state);
printf(" su %d", ret[i].clc_substate);
printf(" pr %s", ret[i].clc_primary);
printf(" na %s", ret[i].clc_name.name);
}