Sample DSDL Resource Type Implementation
This chapter describes a sample resource type, SUNW.xfnts, implemented with the DSDL. The data service is written in C. The underlying application is the X Font Server, a TCP/IP-based service.
The information in this chapter includes.
X Font Server
The X Font Server is a simple TCP/IP-based service that serves font files to its clients. Clients connect to the server to request a font set, and the server reads the font files off the disk and serves them to the clients. The X Font Server daemon consists of a server binary /usr/openwin/bin/xfs. The daemon is normally started from inetd, however, for the current sample, assume that the appropriate entry in the /etc/inetd.conf file has been disabled (for example, by the fsadmin -d command) so the daemon is under sole control of Sun Cluster.
X Font Server Configuration File
By default, the X Font Server reads its configuration information from the file /usr/openwin/lib/X11/fontserver.cfg. The catalog entry in this file contains a list of font directories available to the daemon for serving. The cluster administrator can locate the font directories on the global file system (to optimize the use of the X Font Server on Sun Cluster by maintaining a single copy of the font's database on the system). If so, the administrator must edit fontserver.cfg to reflect the new paths for the font directories.
For ease of configuration, the administrator can also place the configuration file itself on the global file system. The xfs daemon provides command line arguments to override the default, built-in location of this file. The SUNW.xfnts resource type uses the following command to start the daemon under control of Sun Cluster.
/usr/openwin/bin/xfs -config <location_of_cfg_file>/fontserver.cfg \ -port <portnumber> |
In the SUNW.xfnts resource type implementation, you can use the Confdir_list property to manage the location of the fontserver.cfg configuration file.
TCP Port Number
The TCP port number on which the xfs server daemon listens is normally the "fs" port (typically defined as 7100 in the /etc/services file). However, the -port option on the xfs command line enables the system administrator to override the default setting. You can use the Port_list property in the SUNW.xfnts resource type to set the default value and to support the use of the -port option on the xfs command line. You define the default value of this property as 7100/tcp in the RTR file. In the SUNW.xfnts Start method, you pass Port_list to the -port option on the xfs command line. Consequently, a user of this resource type isn't required to specify a port number--the port defaults to 7100/tcp--but does have the option of specifying a different port if they wish when configuring the resource type, by specifying a different value for the Port_list property.
Naming Conventions
You can identify the various pieces of the sample code by keeping the following conventions in mind.
RMAPI functions begin with scha_.
DSDL functions begin with scds_.
Callback methods begin with xfnts_.
User-written functions begin with svc_.
SUNW.xfnts RTR File
This section describes several key properties in the SUNW.xfnts RTR file. It does not describe the purpose of each property in the file. For such a description, see Setting Resource and Resource Type Properties.
The Confdir_list extension property identifies the configuration directory (or a list of directories), as follows.
{
PROPERTY = Confdir_list;
EXTENSION;
STRINGARRAY;
TUNABLE = AT_CREATION;
DESCRIPTION = "The Configuration Directory Path(s)";
}
|
The Confdir_list property does not specify a default value. The cluster administrator must specify a directory at the time of resource creation. This value cannot be changed later because tunability is limited to AT_CREATION.
The Port_list property identifies the port on which the server daemon listens, as follows.
{
PROPERTY = Port_list;
DEFAULT = 7100/tcp;
TUNABLE = AT_CREATION;
}
|
Because the property declares a default value, the cluster administrator has a choice of specifying a new value or accepting the default at the time of resource creation. This value cannot be changed later because tunability is limited to AT_CREATION.
scds_initialize() Function
The DSDL requires that each callback method call the scds_initialize(3HA) function at the beginning of the method. This function performs the following operations:
Checks and processes the command line arguments (argc and argv) that the framework passes to the data service method. The method does not have to do any additional processing of the command-line arguments.
Sets up internal data structures for use by the other functions in the DSDL.
Initializes the logging environment.
Validates fault monitor probe settings.
Use the scds_close() function to reclaim the resources allocated by scds_initialize().



