Code Overview for Non-GDS Based Agents

This document explains the organization of the non-GDS based Open HA Cluster agents code. If you have downloaded the source tree and are trying to understand the code organization, then this document will help you get started quickly.

Where to Start

Read the following resources to get acquainted with the agent code:

  • If you have downloaded the source tree and want to know how to build the agent binaries, then refer to the document Building Agents, which explains all about building the Open HA Cluster source gate.
  • If you are not already familiar with Open HA Cluster data-service concepts, refer to the Developer's Guide. The Developer's Guide also explains how to write a new agent for Open HA Cluster.
  • If you plan to contribute, refer to the Requested Agents page for applications that do not yet have an Open HA Cluster agent.

Background

Agents for Open HA Cluster are Generic Data Service (GDS) based or can be written from scratch (non-GDS based) providing all the mandatory and non-mandatory resource group manager (RGM) callback methods by defining them in the resource type registration (RTR) file.

The document Code Overview for SUNW.gds Based Agents explains the file and code organization of all the GDS-based agents.

Non-GDS Agent Directory Structure

Each application agent has its own directory and contains the Makefile, RTR file, and the source files for the agent. Most of the non-GDS agents have the following directory structure:

ohacds/usr/src/cmd/ha-services/app-name/

  • Makefile
  • SUNW.app-name RTR file
  • common functions directory
  • Method files, such as start_app.c, stop_app.c, probe_app.c

The Makefile contains all the rules to build the agent binaries and the agent packages. The Makefile utilizes rules from a parent Makefile located under ohacds/usr/src/ and ohacds/usr/src/pkgdefs/ to build binaries for different platforms and Solaris versions. Refer to Building Agents for details on how to build the Open HA Cluster agents gate.

The resource type registration (RTR) file is the interface between the resource group manager (RGM) and the agent methods. This file tells the RGM the resource methods you defined and also lists the various resource types and the resource and extension properties. The default values for several properties are defined in the RTR file. Refer to the Developer's Guide for further information on the RTR file.

The common functions file, usually the largest file in the directory, contains all the functions used by various methods defined in the RTR file. This is the single most important file in the agent directory. Most of the agent algorithms can be found in this file.

Finally, the source code for all the methods defined in the RTR files is in a separate file for each method. Usually the file name contains the name of the method in it. For example, apache_svc_start.c is the file containing the source code for the Apache start method.

Example: Apache Data Service

As an example, the Apache data service is organized as follows:

ohacds/usr/src/cmd/ha-services/apache/

  • Makefile
  • SUNW.apache
  • apache.h: This is the header file.
  • apache_probe.c: The probe daemon code is in this file. The actual probe algorithm is in apache.c.
  • apache_validate.c: This file contains the code which parses all the arguments passed by RGM and then calls the validate function in apache.c.
  • apache_monitor_check.c: This file contains the code which parses all the arguments passed by RGM and then calls the monitor_check function in apache.c.
  • apache_svc_start.c: This file contains the code which parses all the arguments passed by RGM and then calls the Apache start function in apache.c.
  • dsconfig/ (directory): This directory contains code used by the data service configuration wizard. The data service configuration wizard helps you configure the Apache data service easily. Not all agents have a data service configuration wizard.
  • apache_monitor_start.c: This file contains the code which parses all the arguments passed by RGM and then call the monitor start function in apache.c. The monitor start function in turn starts the probe daemon under PMF.
  • apache_svc_stop.c: This file contains the code which parses all the arguments passed by RGM and then calls the Apache stop function in apache.c.
  • apache_monitor_stop.c: This file contains the code which parses all the arguments passed by RGM and then calls the monitor stop function in apache.c.
  • apache_update.c: This file contains the code which parses all the arguments passed by RGM and then calls the update function in apache.c. The update function is called whenever a property is changed. In the Apache agent, the update method just calls the validate functions defined again in apache.c.
  • apache.c: This is the most important file in this directory. All the functions are defined in this file. All the files explained above call the functions defined in this file.
  • ../common/ (directory): There are several utility functions defined in the common directory. The Apache agent uses these utility functions to probe HTTP servers.

Most of the non-GDS agents have the code organized as shown above. Refer to the Developer's Guide to understand the data service concepts and to learn more about agent development using the tools available in Solaris Cluster Express.

last modified by admin on 2009/10/26 12:08
Collectives
Project


© Sun Microsystems Inc. 2009
XWiki Enterprise 1.8.2.19075 - Documentation
Terms Of Use | Privacy | Trademarks | Copyright Policy | Site Guidelines | Site map | Help
Your use of this web site or any of its content or software indicates your agreement to be bound by these Terms of Use.