OpenClovis Logo

API Usage Examples
Component Manager

Code Examples. More...

Code Examples.

SAF API usage

The usage of the SAF APIs exposed by the CPM makes sense only when used in a holistic manner. So let us walk through some sample code to understand the usage of the CPM APIs.

Before you proceed, however we strongly recommend that you refer to the SA forum overview document (SAI-Overview-B.02.01.pdf section 3.1), which contains excellent description of the programmming model used here. While reading the document read the API names as clCpm<api-name> wherever saAmf<api-name> is given.

First we need to register the callbacks that we wish to be invoked with the AMF :

Register these callbacks and get the handle representing the association with the AMF library using this call:

After initializing the client library, next step is to do the application initialization, in the application template starting from this comment block:

and ending in

Now register the component with AMF. By calling this function the component is saying that it is ready to provide service i.e. take work assignments.

The AMF requests the application to gracefully terminate by calling its terminate callback:

The application should do its finalization in this callback and call clCpmComponentUnregister() and clCpmClientFinalize() to end its association with the AMF library. It should also call clCpmResponse() function to indicate whether it was successful in finalizing itself.

Once the application has registered itself with the AMF, it will be assumed by the AMF to be instantiated and ready to provide service. The AMF indicates the work assignment to the component by calling its CSI set callback:

The application is supposed to check with what haState the CSI set callback was called and correspondingly take appropriate actions. For e.g. if the CSI set was called with haState set to ::CL_AMS_HA_STATE_ACTIVE then it should start providing service, if haState is ::CL_AMS_HA_STATE_QUIESCING then it is supposed to stop work associated with the CSI gracefully, not accept any new workloads and respond with the clCpmCSIQuiescingComplete() function whenever it is done serving the pending requests. For more information on the HA states that can be assigned to the component and the expected behavior of the component please refer to the SA forum AMF specification. (SAI-AIS-AMF-B.02.01.pdf section 3.3.1.5)

The AMF removes the work assigned to the component during the ClCpmCSISetCallbackT by invoking its CSI remove callback:

Note that in each of these callbacks the application should respond with the status of executing the AMF request through calling clCpmResponse() call. If the application did not call this function within a specified time limit, then it will be considered as a fault by AMF and appropriate recovery actions are taken.

Note
OpenClovis AMF also supports the invocation of pending callbacks using the SAF programming model. (SAI-Overview-B.02.01.pdf section 3.1). For e.g. the saAmfSelectionObjectGet() call corresponds to the clCpmSelectionObjectGet() API and so on.

Non SAF API usage

See Also
Non SAF APIs and API Reference Pages

Generated on Tue Jan 10 10:29:15 PST 2012 for OpenClovis SDK using Doxygen