<?xml version="1.0"?>
<?xml-stylesheet type="text/css" href="https://help.openclovis.com/skins/common/feed.css?303"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>https://help.openclovis.com/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Madhu</id>
		<title>OpenClovis Product Documentation - User contributions [en]</title>
		<link rel="self" type="application/atom+xml" href="https://help.openclovis.com/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Madhu"/>
		<link rel="alternate" type="text/html" href="https://help.openclovis.com/index.php/Special:Contributions/Madhu"/>
		<updated>2026-08-07T02:02:56Z</updated>
		<subtitle>User contributions</subtitle>
		<generator>MediaWiki 1.20.2</generator>

	<entry>
		<id>https://help.openclovis.com/index.php/Doc:latest/evalguide/csa213</id>
		<title>Doc:latest/evalguide/csa213</title>
		<link rel="alternate" type="text/html" href="https://help.openclovis.com/index.php/Doc:latest/evalguide/csa213"/>
				<updated>2010-10-14T07:18:01Z</updated>
		
		<summary type="html">&lt;p&gt;Madhu: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==csa213 Event Publication==&lt;br /&gt;
&lt;br /&gt;
===Objective===&lt;br /&gt;
&lt;br /&gt;
The objective is to learn how to write an event publishing application using Clovis' Event Manager API.&lt;br /&gt;
&lt;br /&gt;
===What You Will Learn===&lt;br /&gt;
&lt;br /&gt;
*You will learn how to publish events using Clovis' Event Manager API.&lt;br /&gt;
&lt;br /&gt;
===Code===&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffccaa;&amp;quot; align=&amp;quot;center&amp;quot;| clCompAppMain.c&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
    int&lt;br /&gt;
    main(int argc, Char *argv[])&lt;br /&gt;
    {&lt;br /&gt;
        SaNameT             appName = {0};&lt;br /&gt;
        SaAmfCallbacksT     callbacks;&lt;br /&gt;
        SaVersionT          version;&lt;br /&gt;
        clIocPortT          iocPort;&lt;br /&gt;
        SaAisErrorT         rc = SA_AIS_OK;&lt;br /&gt;
        SaEvtChannelHandleT evtChannelHandle = 0&lt;br /&gt;
&lt;br /&gt;
        SaSelectionObjectT dispatch_fd;&lt;br /&gt;
        fd_set read_fds;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
        /*&lt;br /&gt;
         * ---BEGIN_APPLICATION_CODE---&lt;br /&gt;
         */&lt;br /&gt;
        &lt;br /&gt;
        SaEvtCallbacksT   evtCallbacks = { NULL, NULL };&lt;br /&gt;
&lt;br /&gt;
        /*&lt;br /&gt;
         * ---END_APPLICATION_CODE---&lt;br /&gt;
         */&lt;br /&gt;
        ...&lt;br /&gt;
&lt;br /&gt;
        if ( (rc = saAmfInitialize(&amp;amp;amfHandle, &amp;amp;callbacks, &amp;amp;version)) != SA_AIS_OK) &lt;br /&gt;
            goto errorexit;&lt;br /&gt;
&lt;br /&gt;
        ....&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
In the &amp;lt;code&amp;gt;main&amp;lt;/code&amp;gt; function of this example we again see a call to &amp;lt;code&amp;gt;saEvtInitialize&amp;lt;/code&amp;gt;.  Most everything else in the appInitialize function is the same as before in csa212, except that both callback function pointers are specified as &amp;lt;code&amp;gt;NULL&amp;lt;/code&amp;gt;.  This is because we neither open the event channel asynchronously, or subscribe to any events in this application. So there is no need to specify a callback to receive an event.&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffccaa;&amp;quot; align=&amp;quot;center&amp;quot;| clCompAppMain.c&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
    int&lt;br /&gt;
    main(int argc, Char *argv[])&lt;br /&gt;
    {&lt;br /&gt;
&lt;br /&gt;
        ...&lt;br /&gt;
&lt;br /&gt;
        // Open an event chanel so that we can subscribe to events on that channel&lt;br /&gt;
        rc = saEvtChannelOpen(gTestInfo.evtInitHandle,&lt;br /&gt;
                               &amp;amp;gTestInfo.evtChannelName,&lt;br /&gt;
                              (SA_EVT_CHANNEL_PUBLISHER |&lt;br /&gt;
                               SA_EVT_CHANNEL_CREATE),&lt;br /&gt;
                              (ClTimeT)SA_TIME_END,&lt;br /&gt;
                              &amp;amp;evtChannelHandle);&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
Here we open the event channel.  This is the same as in csa212 except that rather than opening as a SUBSCRIBER, we open as a &amp;lt;code&amp;gt;PUBLISHER&amp;lt;/code&amp;gt; (by specifying &amp;lt;code&amp;gt;SA_EVT_CHANNEL_PUBLISHER&amp;lt;/code&amp;gt; flag)&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffccaa;&amp;quot; align=&amp;quot;center&amp;quot;| clCompAppMain.c&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
    int&lt;br /&gt;
    main(int argc, Char *argv[])&lt;br /&gt;
    {&lt;br /&gt;
&lt;br /&gt;
        ...&lt;br /&gt;
&lt;br /&gt;
        rc = saEvtEventAllocate(evtChannelHandle,  &amp;amp;gTestInfo.eventHandle);&lt;br /&gt;
        if (rc != SA_AIS_OK)&lt;br /&gt;
        {&lt;br /&gt;
            logrc(CL_LOG_LOG_ERROR, &amp;quot;Failed to allocate event [0x%x]&amp;quot;,&lt;br /&gt;
                    rc);&lt;br /&gt;
            return rc;&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        rc = saEvtEventAttributesSet(gTestInfo.eventHandle,&lt;br /&gt;
                NULL,&lt;br /&gt;
                1,&lt;br /&gt;
                0,&lt;br /&gt;
                &amp;amp;gTestInfo.publisherName);&lt;br /&gt;
        if (rc != SA_AIS_OK)&lt;br /&gt;
        {&lt;br /&gt;
            logrc(CL_LOG_ERROR, &amp;quot;Failed to set event attributes [0x%x]&amp;quot;,&lt;br /&gt;
                    rc);&lt;br /&gt;
            return rc;&lt;br /&gt;
        }&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
The call to &amp;lt;code&amp;gt;saEvtEventAllocate&amp;lt;/code&amp;gt; allocates an event header.  This header is identified by the event handle passed back to &amp;lt;code&amp;gt;gTestInfo.eventHandle&amp;lt;/code&amp;gt;.  The handle should be used any time the event header is to be used to manipulate the header, either by using &amp;lt;code&amp;gt;saEvtEventAttributesSet&amp;lt;/code&amp;gt; (right below), or to send an event using the header as in &amp;lt;code&amp;gt;saEvtEventPublish&amp;lt;/code&amp;gt;.  The call to &amp;lt;code&amp;gt;saEvtEventAttributesSet&amp;lt;/code&amp;gt; defines the &amp;lt;code&amp;gt;EVENT_TYPE&amp;lt;/code&amp;gt; which is defined as 5432 in &amp;lt;code&amp;gt;common/common.h&amp;lt;/code&amp;gt; and is used in the event subscriber.  It also defines the priority to be 1 which is just below the highest priority of &amp;lt;code&amp;gt;CL_EVENT_HIGHEST_PRIORITY&amp;lt;/code&amp;gt; which is defined as 0 where &amp;lt;code&amp;gt;CL_EVENT_LOWEST_PRIORITY&amp;lt;/code&amp;gt; is defined as 3.  The retention time is specified as 0 since we don't want the event to be kept around if there is no subscriber to pick it up.  Finally the &amp;lt;code&amp;gt;publisherName&amp;lt;/code&amp;gt; is specified because it's required.  Our subscriber doesn't care who publishes the events it receives.&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffccaa;&amp;quot; align=&amp;quot;center&amp;quot;| clCompAppMain.c&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
    int&lt;br /&gt;
    main(int argc, Char *argv[])&lt;br /&gt;
    {&lt;br /&gt;
&lt;br /&gt;
        ...&lt;br /&gt;
&lt;br /&gt;
        while (!gTestInfo.exiting)&lt;br /&gt;
        {&lt;br /&gt;
            if (gTestInfo.running &amp;amp;&amp;amp; gTestInfo.ha_state == CL_AMS_HA_STATE_ACTIVE)&lt;br /&gt;
            {&lt;br /&gt;
                csa213Comp_PublishEvent();&lt;br /&gt;
            }&lt;br /&gt;
            sleep(1);&lt;br /&gt;
        }&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
Here is the main loop.  As long as the application is running and active we make a call to &amp;lt;code&amp;gt;csa213Comp_PublishEvent&amp;lt;/code&amp;gt;.  The work of the application takes place in &amp;lt;code&amp;gt;csa213Comp_PublishEvent&amp;lt;/code&amp;gt;, which is presented below.&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffccaa;&amp;quot; align=&amp;quot;center&amp;quot;| clCompAppMain.c&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
    static ClRcT&lt;br /&gt;
    csa213Comp_PublishEvent()&lt;br /&gt;
    {&lt;br /&gt;
        SaAisErrorT     rc              = SA_AIS_OK;&lt;br /&gt;
        ClEventIdT      eventId         = 0;&lt;br /&gt;
        static int      index           = 0;&lt;br /&gt;
        SASizeT         data_len        = 0;&lt;br /&gt;
        char            *data           = 0;&lt;br /&gt;
        typedef void (*Generator)(char **, ClSizeT*);&lt;br /&gt;
    &lt;br /&gt;
        //&lt;br /&gt;
        // Note: to add a new generator, just define it above and then include&lt;br /&gt;
        // the new functions name in the generators list.&lt;br /&gt;
        // Next, maybe something that gets disk free info by way of getfsent&lt;br /&gt;
        // and statfs?&lt;br /&gt;
        static Generator generators[]   =&lt;br /&gt;
        { &lt;br /&gt;
            generate_time_of_day,&lt;br /&gt;
            generate_load_average&lt;br /&gt;
        };&lt;br /&gt;
&lt;br /&gt;
        //&lt;br /&gt;
        // every time through increment index and then set index to&lt;br /&gt;
        // it's value modulo the number of entries in the generators&lt;br /&gt;
        // array.  This will cause us to cycle through the list of&lt;br /&gt;
        // generators as we're called to publish events.&lt;br /&gt;
        (*generators[index++])(&amp;amp;data, &amp;amp;data_len);&lt;br /&gt;
        index %= (int)(sizeof generators / sizeof generators[0]);&lt;br /&gt;
        if (data == 0 || data_len == 0)&lt;br /&gt;
        {&lt;br /&gt;
            logmsg(CL_LOG_ERROR, &amp;quot;no event data generated&amp;quot;);&lt;br /&gt;
            return CL_ERR_NO_MEMORY;&lt;br /&gt;
        }&lt;br /&gt;
        clprintf(CL_LOG_SEV_INFO,&amp;quot;Publishing Event: %.*s&amp;quot;, (int)data_len, data);&lt;br /&gt;
        rc = saEvtEventPublish(gTestInfo.eventHandle, (void*)data, data_len, &amp;amp;eventId);&lt;br /&gt;
        clHeapFree(data);&lt;br /&gt;
&lt;br /&gt;
        return CL_OK;&lt;br /&gt;
    }&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
There's code to call one of a list of generator functions.  The functions on the list, return a pointer and a length which are used to pass to &amp;lt;code&amp;gt;saEvtEventPublish&amp;lt;/code&amp;gt;.  We pass the eventHandle  prepared earlier with &amp;lt;code&amp;gt;saEvtEventAllocate&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;saEvtEventAttributesSet&amp;lt;/code&amp;gt;.  Pass the pointer and the length that we get back from the generator function.  Those are used to package up the event data and send it to any subscribers.  We also pass the address of the &amp;lt;code&amp;gt;eventId&amp;lt;/code&amp;gt; local variable.  This is required so that the &amp;lt;code&amp;gt;saEvtEventPublish&amp;lt;/code&amp;gt; function can return the event ID.  We don't need it, so we promptly drop it in the bit bucket.  Finally, we free the data that was allocated in the generator function and passed back as we no longer need it.&lt;br /&gt;
&lt;br /&gt;
===csa213 SA Forum Compliant Event Publication===&lt;br /&gt;
&lt;br /&gt;
This sample application demonstrates the usage of SA Forum Event Service. As mentioned previously, this sample application does not deviate functionally with csa213. The code differences are due to using SA Forum data types (structures) and APIs , as presented in the following two tables. (Note we have not repeated data types and APIs covered previously.)&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|+align=&amp;quot;bottom&amp;quot;| '''SA Forum Data Types with the SAFplus Platform equivalent'''&lt;br /&gt;
|- style=&amp;quot;color:black;background-color:#ffffaa;&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
!SA Forum Data Types   &lt;br /&gt;
!OpenClovis Data Types&lt;br /&gt;
|-&lt;br /&gt;
|SaEvtHandleT&lt;br /&gt;
|ClEventHandleT&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|+align=&amp;quot;bottom&amp;quot;| '''SA Forum APIs with the SAFplus Platform equivalent'''&lt;br /&gt;
|- style=&amp;quot;color:black;background-color:#ffffaa;&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
!SA Forum APIs&lt;br /&gt;
!OpenClovis APIs&lt;br /&gt;
|-&lt;br /&gt;
|SaEvtEventAllocate&lt;br /&gt;
|ClEventAllocate&lt;br /&gt;
|-&lt;br /&gt;
|saEvtEventAttributesSet&lt;br /&gt;
|clEventExtAttributesSet&lt;br /&gt;
|-&lt;br /&gt;
|saEvtEventPublish&lt;br /&gt;
|clEventPublish&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===How to Run csa213 and What to Observe===&lt;br /&gt;
&lt;br /&gt;
In csa213 you will be observing an event publishing application. This will be far more interesting if you observe an event subscription application at the same time. For this we will use the example from csa212.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;First you should start up csa212 and put it in a LockAssignment state so that it can receive events.&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
 # cd /root/asp/bin&lt;br /&gt;
 # ./asp_console&lt;br /&gt;
&lt;br /&gt;
cli[Test]-&amp;gt; setc 1&lt;br /&gt;
cli[Test:SCNodeI0]-&amp;gt; setc cpm&lt;br /&gt;
cli[Test:SCNodeI0:CPM]-&amp;gt; amsLockAssignment sg csa212SGI0&lt;br /&gt;
cli[Test:SCNodeI0:CPM]-&amp;gt; amsUnlock sg csa212SGI0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the csa212 application log you should see:&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffffaa;&amp;quot; align=&amp;quot;center&amp;quot;| $ /root/asp/var/log/csa212CompI3Log.latest &lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
Thu Oct 14 13:25:49.418 2010 (PayloadNodeI1.4003 : csa212CompEO.---.---.00001 :   INFO) Component [csa212CompI3] : PID [4003]. Initializing&lt;br /&gt;
&lt;br /&gt;
Thu Oct 14 13:25:49.418 2010 (PayloadNodeI1.4003 : csa212CompEO.---.---.00002 :   INFO)    IOC Address             : 0x4&lt;br /&gt;
&lt;br /&gt;
Thu Oct 14 13:25:49.419 2010 (PayloadNodeI1.4003 : csa212CompEO.---.---.00003 :   INFO)    IOC Port                : 0x80&lt;br /&gt;
&lt;br /&gt;
Thu Oct 14 13:26:01.942 2010 (PayloadNodeI1.4003 : csa212CompEO.---.---.00004 :   INFO) Component [csa212CompI3] : PID [4003]. CSI Set Received&lt;br /&gt;
&lt;br /&gt;
Thu Oct 14 13:26:01.942 2010 (PayloadNodeI1.4003 : csa212CompEO.---.---.00005 :   INFO) CSI Flags : [Add One]&lt;br /&gt;
Thu Oct 14 13:26:01.942 2010 (PayloadNodeI1.4003 : csa212CompEO.---.---.00006 :   INFO) CSI Name : [csa212CSII0]&lt;br /&gt;
Thu Oct 14 13:26:01.942 2010 (PayloadNodeI1.4003 : csa212CompEO.---.---.00007 :   INFO) Name value pairs :&lt;br /&gt;
Thu Oct 14 13:26:01.942 2010 (PayloadNodeI1.4003 : csa212CompEO.---.---.00008 :   INFO) HA state : [Active]&lt;br /&gt;
Thu Oct 14 13:26:01.942 2010 (PayloadNodeI1.4003 : csa212CompEO.---.---.00009 :   INFO) Active Descriptor :&lt;br /&gt;
Thu Oct 14 13:26:01.942 2010 (PayloadNodeI1.4003 : csa212CompEO.---.---.00010 :   INFO) Transition Descriptor : [1]&lt;br /&gt;
Thu Oct 14 13:26:01.942 2010 (PayloadNodeI1.4003 : csa212CompEO.---.---.00011 :   INFO) Active Component : [csa212CompI3]&lt;br /&gt;
Thu Oct 14 13:26:01.942 2010 (PayloadNodeI1.4003 : csa212CompEO.---.---.00012 :   INFO) csa212: ACTIVE state requested; activating service&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;Now you can start up the event publishing application and put it in a LockAssignment state.&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
cli[Test:SCNodeI0:CPM]-&amp;gt; amsLockAssignment sg csa213SGI0&lt;br /&gt;
cli[Test:SCNodeI0:CPM]-&amp;gt; amsUnlock sg csa213SGI0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Putting csa213 into a LockAssignment state caused it to begin publishing events. Using &amp;lt;code&amp;gt;tail -f /root/asp/var/log/csa213CompI3Log.latest&amp;lt;/code&amp;gt; on the csa213 application log you can see the events being published.&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffffaa;&amp;quot; align=&amp;quot;center&amp;quot;| $ /root/asp/var/log/csa213CompI3Log.latest &lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
Thu Oct 14 13:28:58.503 2010 (PayloadNodeI1.4422 : csa213CompEO.---.---.00001 :   INFO) csa213: Initializing and registering with CPM...&lt;br /&gt;
&lt;br /&gt;
Thu Oct 14 13:28:58.503 2010 (PayloadNodeI1.4422 : csa213CompEO.---.---.00002 :   INFO) Component [csa213CompI3] : PID [4422]. Initializing&lt;br /&gt;
&lt;br /&gt;
Thu Oct 14 13:28:58.503 2010 (PayloadNodeI1.4422 : csa213CompEO.---.---.00003 :   INFO)    IOC Address             : 0x4&lt;br /&gt;
&lt;br /&gt;
Thu Oct 14 13:28:58.503 2010 (PayloadNodeI1.4422 : csa213CompEO.---.---.00004 :   INFO)    IOC Port                : 0x81&lt;br /&gt;
&lt;br /&gt;
Thu Oct 14 13:28:58.504 2010 (PayloadNodeI1.4422 : csa213CompEO.---.---.00005 :   INFO) csa213CompI3: Waiting for CSI assignment...&lt;br /&gt;
&lt;br /&gt;
Thu Oct 14 13:29:09.593 2010 (PayloadNodeI1.4422 : csa213CompEO.---.---.00006 :   INFO) Component [csa213CompI3] : PID [4422]. CSI Set Received&lt;br /&gt;
&lt;br /&gt;
Thu Oct 14 13:29:09.593 2010 (PayloadNodeI1.4422 : csa213CompEO.---.---.00007 :   INFO) CSI Flags : [Add One]&lt;br /&gt;
Thu Oct 14 13:29:09.593 2010 (PayloadNodeI1.4422 : csa213CompEO.---.---.00008 :   INFO) CSI Name : [csa213CSII0]&lt;br /&gt;
Thu Oct 14 13:29:09.593 2010 (PayloadNodeI1.4422 : csa213CompEO.---.---.00009 :   INFO) Name value pairs :&lt;br /&gt;
Thu Oct 14 13:29:09.593 2010 (PayloadNodeI1.4422 : csa213CompEO.---.---.00010 :   INFO) HA state : [Active]&lt;br /&gt;
Thu Oct 14 13:29:09.593 2010 (PayloadNodeI1.4422 : csa213CompEO.---.---.00011 :   INFO) Active Descriptor :&lt;br /&gt;
Thu Oct 14 13:29:09.593 2010 (PayloadNodeI1.4422 : csa213CompEO.---.---.00012 :   INFO) Transition Descriptor : [1]&lt;br /&gt;
Thu Oct 14 13:29:09.593 2010 (PayloadNodeI1.4422 : csa213CompEO.---.---.00013 :   INFO) Active Component : [csa213CompI3]&lt;br /&gt;
Thu Oct 14 13:29:09.593 2010 (PayloadNodeI1.4422 : csa213CompEO.---.---.00014 :   INFO) csa213: ACTIVE state request: activating service&lt;br /&gt;
Thu Oct 14 13:29:10.511 2010 (PayloadNodeI1.4422 : csa213CompEO.---.---.00015 :   INFO) csa213CompI3: Publishing Event: Thu Oct 14 13:29:10 2010&lt;br /&gt;
&lt;br /&gt;
Thu Oct 14 13:29:11.516 2010 (PayloadNodeI1.4422 : csa213CompEO.---.---.00016 :   INFO) csa213CompI3: Publishing Event: 0.29 0.42 0.25&lt;br /&gt;
&lt;br /&gt;
Thu Oct 14 13:29:12.521 2010 (PayloadNodeI1.4422 : csa213CompEO.---.---.00017 :   INFO) csa213CompI3: Publishing Event: Thu Oct 14 13:29:12 2010&lt;br /&gt;
&lt;br /&gt;
Thu Oct 14 13:29:13.526 2010 (PayloadNodeI1.4422 : csa213CompEO.---.---.00018 :   INFO) csa213CompI3: Publishing Event: 0.66 0.50 0.27&lt;br /&gt;
&lt;br /&gt;
Thu Oct 14 13:29:14.530 2010 (PayloadNodeI1.4422 : csa213CompEO.---.---.00019 :   INFO) csa213CompI3: Publishing Event: Thu Oct 14 13:29:14 2010&lt;br /&gt;
&lt;br /&gt;
Thu Oct 14 13:29:15.537 2010 (PayloadNodeI1.4422 : csa213CompEO.---.---.00020 :   INFO) csa213CompI3: Publishing Event: 0.66 0.50 0.27&lt;br /&gt;
&lt;br /&gt;
Thu Oct 14 13:29:16.538 2010 (PayloadNodeI1.4422 : csa213CompEO.---.---.00021 :   INFO) csa213CompI3: Publishing Event: Thu Oct 14 13:29:16 2010&lt;br /&gt;
&lt;br /&gt;
Thu Oct 14 13:29:17.541 2010 (PayloadNodeI1.4422 : csa213CompEO.---.---.00022 :   INFO) csa213CompI3: Publishing Event: 1.01 0.57 0.30&lt;br /&gt;
&lt;br /&gt;
Thu Oct 14 13:29:18.545 2010 (PayloadNodeI1.4422 : csa213CompEO.---.---.00023 :   INFO) csa213CompI3: Publishing Event: Thu Oct 14 13:29:18 2010&lt;br /&gt;
&lt;br /&gt;
Thu Oct 14 13:29:19.548 2010 (PayloadNodeI1.4422 : csa213CompEO.---.---.00024 :   INFO) csa213CompI3: Publishing Event: 1.01 0.57 0.30&lt;br /&gt;
&lt;br /&gt;
Thu Oct 14 13:29:20.549 2010 (PayloadNodeI1.4422 : csa213CompEO.---.---.00025 :   INFO) csa213CompI3: Publishing Event: Thu Oct 14 13:29:20 2010&lt;br /&gt;
&lt;br /&gt;
Thu Oct 14 13:29:21.554 2010 (PayloadNodeI1.4422 : csa213CompEO.---.---.00026 :   INFO) csa213CompI3: Publishing Event: 1.01 0.57 0.30&lt;br /&gt;
&lt;br /&gt;
Thu Oct 14 13:29:22.557 2010 (PayloadNodeI1.4422 : csa213CompEO.---.---.00027 :   INFO) csa213CompI3: Publishing Event: Thu Oct 14 13:29:22 2010&lt;br /&gt;
&lt;br /&gt;
Thu Oct 14 13:29:23.562 2010 (PayloadNodeI1.4422 : csa213CompEO.---.---.00028 :   INFO) csa213CompI3: Publishing Event: 1.17 0.61 0.31&lt;br /&gt;
&lt;br /&gt;
Thu Oct 14 13:29:24.563 2010 (PayloadNodeI1.4422 : csa213CompEO.---.---.00029 :   INFO) csa213CompI3: Publishing Event: Thu Oct 14 13:29:24 2010&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
Since the event subscriber application is also running you can see the events that it is receiving in the csa212 application log file. Again using &amp;lt;code&amp;gt;tail -f /rootasp//var/log/csa212CompI3Log.latest&amp;lt;/code&amp;gt; you can see the following:&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffffaa;&amp;quot; align=&amp;quot;center&amp;quot;| /root/asp/var/log/csa212CompI3Log.latest&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
Thu Oct 14 13:25:49.418 2010 (PayloadNodeI1.4003 : csa212CompEO.---.---.00001 :   INFO) Component [csa212CompI3] : PID [4003]. Initializing&lt;br /&gt;
&lt;br /&gt;
Thu Oct 14 13:25:49.418 2010 (PayloadNodeI1.4003 : csa212CompEO.---.---.00002 :   INFO)    IOC Address             : 0x4&lt;br /&gt;
&lt;br /&gt;
Thu Oct 14 13:25:49.419 2010 (PayloadNodeI1.4003 : csa212CompEO.---.---.00003 :   INFO)    IOC Port                : 0x80&lt;br /&gt;
&lt;br /&gt;
Thu Oct 14 13:26:01.942 2010 (PayloadNodeI1.4003 : csa212CompEO.---.---.00004 :   INFO) Component [csa212CompI3] : PID [4003]. CSI Set Received&lt;br /&gt;
&lt;br /&gt;
Thu Oct 14 13:26:01.942 2010 (PayloadNodeI1.4003 : csa212CompEO.---.---.00005 :   INFO) CSI Flags : [Add One]&lt;br /&gt;
Thu Oct 14 13:26:01.942 2010 (PayloadNodeI1.4003 : csa212CompEO.---.---.00006 :   INFO) CSI Name : [csa212CSII0]&lt;br /&gt;
Thu Oct 14 13:26:01.942 2010 (PayloadNodeI1.4003 : csa212CompEO.---.---.00007 :   INFO) Name value pairs :&lt;br /&gt;
Thu Oct 14 13:26:01.942 2010 (PayloadNodeI1.4003 : csa212CompEO.---.---.00008 :   INFO) HA state : [Active]&lt;br /&gt;
Thu Oct 14 13:26:01.942 2010 (PayloadNodeI1.4003 : csa212CompEO.---.---.00009 :   INFO) Active Descriptor :&lt;br /&gt;
Thu Oct 14 13:26:01.942 2010 (PayloadNodeI1.4003 : csa212CompEO.---.---.00010 :   INFO) Transition Descriptor : [1]&lt;br /&gt;
Thu Oct 14 13:26:01.942 2010 (PayloadNodeI1.4003 : csa212CompEO.---.---.00011 :   INFO) Active Component : [csa212CompI3]&lt;br /&gt;
Thu Oct 14 13:26:01.942 2010 (PayloadNodeI1.4003 : csa212CompEO.---.---.00012 :   INFO) csa212: ACTIVE state requested; activating service&lt;br /&gt;
Thu Oct 14 13:29:10.516 2010 (PayloadNodeI1.4003 : csa212CompEO.---.---.00013 :   INFO) We've got an event to receive&lt;br /&gt;
&lt;br /&gt;
Thu Oct 14 13:29:10.516 2010 (PayloadNodeI1.4003 : csa212CompEO.---.---.00014 :   INFO) received event: Thu Oct 14 13:29:10 2010&lt;br /&gt;
&lt;br /&gt;
Thu Oct 14 13:29:11.518 2010 (PayloadNodeI1.4003 : csa212CompEO.---.---.00015 :   INFO) We've got an event to receive&lt;br /&gt;
&lt;br /&gt;
Thu Oct 14 13:29:11.518 2010 (PayloadNodeI1.4003 : csa212CompEO.---.---.00016 :   INFO) received event: 0.29 0.42 0.25&lt;br /&gt;
&lt;br /&gt;
Thu Oct 14 13:29:12.525 2010 (PayloadNodeI1.4003 : csa212CompEO.---.---.00017 :   INFO) We've got an event to receive&lt;br /&gt;
&lt;br /&gt;
Thu Oct 14 13:29:12.525 2010 (PayloadNodeI1.4003 : csa212CompEO.---.---.00018 :   INFO) received event: Thu Oct 14 13:29:12 2010&lt;br /&gt;
&lt;br /&gt;
Thu Oct 14 13:29:13.529 2010 (PayloadNodeI1.4003 : csa212CompEO.---.---.00019 :   INFO) We've got an event to receive&lt;br /&gt;
&lt;br /&gt;
Thu Oct 14 13:29:13.529 2010 (PayloadNodeI1.4003 : csa212CompEO.---.---.00020 :   INFO) received event: 0.66 0.50 0.27&lt;br /&gt;
&lt;br /&gt;
Thu Oct 14 13:29:14.533 2010 (PayloadNodeI1.4003 : csa212CompEO.---.---.00021 :   INFO) We've got an event to receive&lt;br /&gt;
&lt;br /&gt;
Thu Oct 14 13:29:14.533 2010 (PayloadNodeI1.4003 : csa212CompEO.---.---.00022 :   INFO) received event: Thu Oct 14 13:29:14 2010&lt;br /&gt;
&lt;br /&gt;
Thu Oct 14 13:29:15.540 2010 (PayloadNodeI1.4003 : csa212CompEO.---.---.00023 :   INFO) We've got an event to receive&lt;br /&gt;
&lt;br /&gt;
Thu Oct 14 13:29:15.541 2010 (PayloadNodeI1.4003 : csa212CompEO.---.---.00024 :   INFO) received event: 0.66 0.50 0.27&lt;br /&gt;
&lt;br /&gt;
Thu Oct 14 13:29:16.540 2010 (PayloadNodeI1.4003 : csa212CompEO.---.---.00025 :   INFO) We've got an event to receive&lt;br /&gt;
&lt;br /&gt;
Thu Oct 14 13:29:16.540 2010 (PayloadNodeI1.4003 : csa212CompEO.---.---.00026 :   INFO) received event: Thu Oct 14 13:29:16 2010&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;Now you can shut everything down in the usual manner. Note that you will be shutting down two service groups.&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
cli[Test:SCNodeI0:CPM]-&amp;gt; amsLockAssignment sg csa213SGI0&lt;br /&gt;
cli[Test:SCNodeI0:CPM]-&amp;gt; amsLockAssignment sg csa212SGI0&lt;br /&gt;
cli[Test:SCNodeI0:CPM]-&amp;gt; amsLockInstantiation sg csa213SGI0&lt;br /&gt;
cli[Test:SCNodeI0:CPM]-&amp;gt; amsLockInstantiation sg csa212SGI0&lt;br /&gt;
cli[Test:SCNodeI0:CPM]-&amp;gt; end&lt;br /&gt;
cli[Test:SCNodeI0]-&amp;gt; end&lt;br /&gt;
cli[Test]-&amp;gt; bye&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Summary and References===&lt;br /&gt;
&lt;br /&gt;
We've seen how to initialize the event manager subsystem as an event publisher.  We've seen:&lt;br /&gt;
*events flow from the event publisher to the subscriber.  &lt;br /&gt;
*how to format events and send them through the event manager subsystem&lt;br /&gt;
*For further reading, check the same sources as listed under the csa212 section.&lt;/div&gt;</summary>
		<author><name>Madhu</name></author>	</entry>

	<entry>
		<id>https://help.openclovis.com/index.php/Doc:latest/evalguide/csa213</id>
		<title>Doc:latest/evalguide/csa213</title>
		<link rel="alternate" type="text/html" href="https://help.openclovis.com/index.php/Doc:latest/evalguide/csa213"/>
				<updated>2010-10-14T07:14:24Z</updated>
		
		<summary type="html">&lt;p&gt;Madhu: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==csa213 Event Publication==&lt;br /&gt;
&lt;br /&gt;
===Objective===&lt;br /&gt;
&lt;br /&gt;
The objective is to learn how to write an event publishing application using Clovis' Event Manager API.&lt;br /&gt;
&lt;br /&gt;
===What You Will Learn===&lt;br /&gt;
&lt;br /&gt;
*You will learn how to publish events using Clovis' Event Manager API.&lt;br /&gt;
&lt;br /&gt;
===Code===&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffccaa;&amp;quot; align=&amp;quot;center&amp;quot;| clCompAppMain.c&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
    int&lt;br /&gt;
    main(int argc, Char *argv[])&lt;br /&gt;
    {&lt;br /&gt;
        SaNameT             appName = {0};&lt;br /&gt;
        SaAmfCallbacksT     callbacks;&lt;br /&gt;
        SaVersionT          version;&lt;br /&gt;
        clIocPortT          iocPort;&lt;br /&gt;
        SaAisErrorT         rc = SA_AIS_OK;&lt;br /&gt;
        SaEvtChannelHandleT evtChannelHandle = 0&lt;br /&gt;
&lt;br /&gt;
        SaSelectionObjectT dispatch_fd;&lt;br /&gt;
        fd_set read_fds;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
        /*&lt;br /&gt;
         * ---BEGIN_APPLICATION_CODE---&lt;br /&gt;
         */&lt;br /&gt;
        &lt;br /&gt;
        SaEvtCallbacksT   evtCallbacks = { NULL, NULL };&lt;br /&gt;
&lt;br /&gt;
        /*&lt;br /&gt;
         * ---END_APPLICATION_CODE---&lt;br /&gt;
         */&lt;br /&gt;
        ...&lt;br /&gt;
&lt;br /&gt;
        if ( (rc = saAmfInitialize(&amp;amp;amfHandle, &amp;amp;callbacks, &amp;amp;version)) != SA_AIS_OK) &lt;br /&gt;
            goto errorexit;&lt;br /&gt;
&lt;br /&gt;
        ....&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
In the &amp;lt;code&amp;gt;main&amp;lt;/code&amp;gt; function of this example we again see a call to &amp;lt;code&amp;gt;saEvtInitialize&amp;lt;/code&amp;gt;.  Most everything else in the appInitialize function is the same as before in csa212, except that both callback function pointers are specified as &amp;lt;code&amp;gt;NULL&amp;lt;/code&amp;gt;.  This is because we neither open the event channel asynchronously, or subscribe to any events in this application. So there is no need to specify a callback to receive an event.&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffccaa;&amp;quot; align=&amp;quot;center&amp;quot;| clCompAppMain.c&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
    int&lt;br /&gt;
    main(int argc, Char *argv[])&lt;br /&gt;
    {&lt;br /&gt;
&lt;br /&gt;
        ...&lt;br /&gt;
&lt;br /&gt;
        // Open an event chanel so that we can subscribe to events on that channel&lt;br /&gt;
        rc = saEvtChannelOpen(gTestInfo.evtInitHandle,&lt;br /&gt;
                               &amp;amp;gTestInfo.evtChannelName,&lt;br /&gt;
                              (SA_EVT_CHANNEL_PUBLISHER |&lt;br /&gt;
                               SA_EVT_CHANNEL_CREATE),&lt;br /&gt;
                              (ClTimeT)SA_TIME_END,&lt;br /&gt;
                              &amp;amp;evtChannelHandle);&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
Here we open the event channel.  This is the same as in csa212 except that rather than opening as a SUBSCRIBER, we open as a &amp;lt;code&amp;gt;PUBLISHER&amp;lt;/code&amp;gt; (by specifying &amp;lt;code&amp;gt;SA_EVT_CHANNEL_PUBLISHER&amp;lt;/code&amp;gt; flag)&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffccaa;&amp;quot; align=&amp;quot;center&amp;quot;| clCompAppMain.c&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
    int&lt;br /&gt;
    main(int argc, Char *argv[])&lt;br /&gt;
    {&lt;br /&gt;
&lt;br /&gt;
        ...&lt;br /&gt;
&lt;br /&gt;
        rc = saEvtEventAllocate(evtChannelHandle,  &amp;amp;gTestInfo.eventHandle);&lt;br /&gt;
        if (rc != SA_AIS_OK)&lt;br /&gt;
        {&lt;br /&gt;
            logrc(CL_LOG_LOG_ERROR, &amp;quot;Failed to allocate event [0x%x]&amp;quot;,&lt;br /&gt;
                    rc);&lt;br /&gt;
            return rc;&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        rc = saEvtEventAttributesSet(gTestInfo.eventHandle,&lt;br /&gt;
                NULL,&lt;br /&gt;
                1,&lt;br /&gt;
                0,&lt;br /&gt;
                &amp;amp;gTestInfo.publisherName);&lt;br /&gt;
        if (rc != SA_AIS_OK)&lt;br /&gt;
        {&lt;br /&gt;
            logrc(CL_LOG_ERROR, &amp;quot;Failed to set event attributes [0x%x]&amp;quot;,&lt;br /&gt;
                    rc);&lt;br /&gt;
            return rc;&lt;br /&gt;
        }&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
The call to &amp;lt;code&amp;gt;saEvtEventAllocate&amp;lt;/code&amp;gt; allocates an event header.  This header is identified by the event handle passed back to &amp;lt;code&amp;gt;gTestInfo.eventHandle&amp;lt;/code&amp;gt;.  The handle should be used any time the event header is to be used to manipulate the header, either by using &amp;lt;code&amp;gt;saEvtEventAttributesSet&amp;lt;/code&amp;gt; (right below), or to send an event using the header as in &amp;lt;code&amp;gt;saEvtEventPublish&amp;lt;/code&amp;gt;.  The call to &amp;lt;code&amp;gt;saEvtEventAttributesSet&amp;lt;/code&amp;gt; defines the &amp;lt;code&amp;gt;EVENT_TYPE&amp;lt;/code&amp;gt; which is defined as 5432 in &amp;lt;code&amp;gt;common/common.h&amp;lt;/code&amp;gt; and is used in the event subscriber.  It also defines the priority to be 1 which is just below the highest priority of &amp;lt;code&amp;gt;CL_EVENT_HIGHEST_PRIORITY&amp;lt;/code&amp;gt; which is defined as 0 where &amp;lt;code&amp;gt;CL_EVENT_LOWEST_PRIORITY&amp;lt;/code&amp;gt; is defined as 3.  The retention time is specified as 0 since we don't want the event to be kept around if there is no subscriber to pick it up.  Finally the &amp;lt;code&amp;gt;publisherName&amp;lt;/code&amp;gt; is specified because it's required.  Our subscriber doesn't care who publishes the events it receives.&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffccaa;&amp;quot; align=&amp;quot;center&amp;quot;| clCompAppMain.c&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
    int&lt;br /&gt;
    main(int argc, Char *argv[])&lt;br /&gt;
    {&lt;br /&gt;
&lt;br /&gt;
        ...&lt;br /&gt;
&lt;br /&gt;
        while (!gTestInfo.exiting)&lt;br /&gt;
        {&lt;br /&gt;
            if (gTestInfo.running &amp;amp;&amp;amp; gTestInfo.ha_state == CL_AMS_HA_STATE_ACTIVE)&lt;br /&gt;
            {&lt;br /&gt;
                csa213Comp_PublishEvent();&lt;br /&gt;
            }&lt;br /&gt;
            sleep(1);&lt;br /&gt;
        }&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
Here is the main loop.  As long as the application is running and active we make a call to &amp;lt;code&amp;gt;csa213Comp_PublishEvent&amp;lt;/code&amp;gt;.  The work of the application takes place in &amp;lt;code&amp;gt;csa213Comp_PublishEvent&amp;lt;/code&amp;gt;, which is presented below.&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffccaa;&amp;quot; align=&amp;quot;center&amp;quot;| clCompAppMain.c&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
    static ClRcT&lt;br /&gt;
    csa213Comp_PublishEvent()&lt;br /&gt;
    {&lt;br /&gt;
        SaAisErrorT     rc              = SA_AIS_OK;&lt;br /&gt;
        ClEventIdT      eventId         = 0;&lt;br /&gt;
        static int      index           = 0;&lt;br /&gt;
        SASizeT         data_len        = 0;&lt;br /&gt;
        char            *data           = 0;&lt;br /&gt;
        typedef void (*Generator)(char **, ClSizeT*);&lt;br /&gt;
    &lt;br /&gt;
        //&lt;br /&gt;
        // Note: to add a new generator, just define it above and then include&lt;br /&gt;
        // the new functions name in the generators list.&lt;br /&gt;
        // Next, maybe something that gets disk free info by way of getfsent&lt;br /&gt;
        // and statfs?&lt;br /&gt;
        static Generator generators[]   =&lt;br /&gt;
        { &lt;br /&gt;
            generate_time_of_day,&lt;br /&gt;
            generate_load_average&lt;br /&gt;
        };&lt;br /&gt;
&lt;br /&gt;
        //&lt;br /&gt;
        // every time through increment index and then set index to&lt;br /&gt;
        // it's value modulo the number of entries in the generators&lt;br /&gt;
        // array.  This will cause us to cycle through the list of&lt;br /&gt;
        // generators as we're called to publish events.&lt;br /&gt;
        (*generators[index++])(&amp;amp;data, &amp;amp;data_len);&lt;br /&gt;
        index %= (int)(sizeof generators / sizeof generators[0]);&lt;br /&gt;
        if (data == 0 || data_len == 0)&lt;br /&gt;
        {&lt;br /&gt;
            logmsg(CL_LOG_ERROR, &amp;quot;no event data generated&amp;quot;);&lt;br /&gt;
            return CL_ERR_NO_MEMORY;&lt;br /&gt;
        }&lt;br /&gt;
        clprintf(CL_LOG_SEV_INFO,&amp;quot;Publishing Event: %.*s&amp;quot;, (int)data_len, data);&lt;br /&gt;
        rc = saEvtEventPublish(gTestInfo.eventHandle, (void*)data, data_len, &amp;amp;eventId);&lt;br /&gt;
        clHeapFree(data);&lt;br /&gt;
&lt;br /&gt;
        return CL_OK;&lt;br /&gt;
    }&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
There's code to call one of a list of generator functions.  The functions on the list, return a pointer and a length which are used to pass to &amp;lt;code&amp;gt;saEvtEventPublish&amp;lt;/code&amp;gt;.  We pass the eventHandle  prepared earlier with &amp;lt;code&amp;gt;saEvtEventAllocate&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;saEvtEventAttributesSet&amp;lt;/code&amp;gt;.  Pass the pointer and the length that we get back from the generator function.  Those are used to package up the event data and send it to any subscribers.  We also pass the address of the &amp;lt;code&amp;gt;eventId&amp;lt;/code&amp;gt; local variable.  This is required so that the &amp;lt;code&amp;gt;saEvtEventPublish&amp;lt;/code&amp;gt; function can return the event ID.  We don't need it, so we promptly drop it in the bit bucket.  Finally, we free the data that was allocated in the generator function and passed back as we no longer need it.&lt;br /&gt;
&lt;br /&gt;
===csa213 SA Forum Compliant Event Publication===&lt;br /&gt;
&lt;br /&gt;
This sample application demonstrates the usage of SA Forum Event Service. As mentioned previously, this sample application does not deviate functionally with csa213. The code differences are due to using SA Forum data types (structures) and APIs , as presented in the following two tables. (Note we have not repeated data types and APIs covered previously.)&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|+align=&amp;quot;bottom&amp;quot;| '''SA Forum Data Types with the SAFplus Platform equivalent'''&lt;br /&gt;
|- style=&amp;quot;color:black;background-color:#ffffaa;&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
!SA Forum Data Types   &lt;br /&gt;
!OpenClovis Data Types&lt;br /&gt;
|-&lt;br /&gt;
|SaEvtHandleT&lt;br /&gt;
|ClEventHandleT&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|+align=&amp;quot;bottom&amp;quot;| '''SA Forum APIs with the SAFplus Platform equivalent'''&lt;br /&gt;
|- style=&amp;quot;color:black;background-color:#ffffaa;&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
!SA Forum APIs&lt;br /&gt;
!OpenClovis APIs&lt;br /&gt;
|-&lt;br /&gt;
|SaEvtEventAllocate&lt;br /&gt;
|ClEventAllocate&lt;br /&gt;
|-&lt;br /&gt;
|saEvtEventAttributesSet&lt;br /&gt;
|clEventExtAttributesSet&lt;br /&gt;
|-&lt;br /&gt;
|saEvtEventPublish&lt;br /&gt;
|clEventPublish&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===How to Run csa213 and What to Observe===&lt;br /&gt;
&lt;br /&gt;
In csa213 you will be observing an event publishing application. This will be far more interesting if you observe an event subscription application at the same time. For this we will use the example from csa212.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;First you should start up csa212 and put it in a LockAssignment state so that it can receive events.&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
 # cd /root/asp/bin&lt;br /&gt;
 # ./asp_console&lt;br /&gt;
&lt;br /&gt;
cli[Test]-&amp;gt; setc 1&lt;br /&gt;
cli[Test:SCNodeI0]-&amp;gt; setc cpm&lt;br /&gt;
cli[Test:SCNodeI0:CPM]-&amp;gt; amsLockAssignment sg csa212SGI0&lt;br /&gt;
cli[Test:SCNodeI0:CPM]-&amp;gt; amsUnlock sg csa212SGI0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the csa212 application log you should see:&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffffaa;&amp;quot; align=&amp;quot;center&amp;quot;| $ /root/asp/var/log/csa212CompI3Log.latest &lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
Thu Oct 14 13:25:49.418 2010 (PayloadNodeI1.4003 : csa212CompEO.---.---.00001 :   INFO) Component [csa212CompI3] : PID [4003]. Initializing&lt;br /&gt;
&lt;br /&gt;
Thu Oct 14 13:25:49.418 2010 (PayloadNodeI1.4003 : csa212CompEO.---.---.00002 :   INFO)    IOC Address             : 0x4&lt;br /&gt;
&lt;br /&gt;
Thu Oct 14 13:25:49.419 2010 (PayloadNodeI1.4003 : csa212CompEO.---.---.00003 :   INFO)    IOC Port                : 0x80&lt;br /&gt;
&lt;br /&gt;
Thu Oct 14 13:26:01.942 2010 (PayloadNodeI1.4003 : csa212CompEO.---.---.00004 :   INFO) Component [csa212CompI3] : PID [4003]. CSI Set Received&lt;br /&gt;
&lt;br /&gt;
Thu Oct 14 13:26:01.942 2010 (PayloadNodeI1.4003 : csa212CompEO.---.---.00005 :   INFO) CSI Flags : [Add One]&lt;br /&gt;
Thu Oct 14 13:26:01.942 2010 (PayloadNodeI1.4003 : csa212CompEO.---.---.00006 :   INFO) CSI Name : [csa212CSII0]&lt;br /&gt;
Thu Oct 14 13:26:01.942 2010 (PayloadNodeI1.4003 : csa212CompEO.---.---.00007 :   INFO) Name value pairs :&lt;br /&gt;
Thu Oct 14 13:26:01.942 2010 (PayloadNodeI1.4003 : csa212CompEO.---.---.00008 :   INFO) HA state : [Active]&lt;br /&gt;
Thu Oct 14 13:26:01.942 2010 (PayloadNodeI1.4003 : csa212CompEO.---.---.00009 :   INFO) Active Descriptor :&lt;br /&gt;
Thu Oct 14 13:26:01.942 2010 (PayloadNodeI1.4003 : csa212CompEO.---.---.00010 :   INFO) Transition Descriptor : [1]&lt;br /&gt;
Thu Oct 14 13:26:01.942 2010 (PayloadNodeI1.4003 : csa212CompEO.---.---.00011 :   INFO) Active Component : [csa212CompI3]&lt;br /&gt;
Thu Oct 14 13:26:01.942 2010 (PayloadNodeI1.4003 : csa212CompEO.---.---.00012 :   INFO) csa212: ACTIVE state requested; activating service&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;Now you can start up the event publishing application and put it in a LockAssignment state.&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
cli[Test:SCNodeI0:CPM]-&amp;gt; amsLockAssignment sg csa213SGI0&lt;br /&gt;
cli[Test:SCNodeI0:CPM]-&amp;gt; amsUnlock sg csa213SGI0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Putting csa213 into a LockAssignment state caused it to begin publishing events. Using &amp;lt;code&amp;gt;tail -f /root/asp/var/log/csa213CompI3Log.latest&amp;lt;/code&amp;gt; on the csa213 application log you can see the events being published.&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffffaa;&amp;quot; align=&amp;quot;center&amp;quot;| $ /root/asp/var/log/csa213CompI3Log.latest &lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
Thu Oct 14 13:28:58.503 2010 (PayloadNodeI1.4422 : csa213CompEO.---.---.00001 :   INFO) csa213: Initializing and registering with CPM...&lt;br /&gt;
&lt;br /&gt;
Thu Oct 14 13:28:58.503 2010 (PayloadNodeI1.4422 : csa213CompEO.---.---.00002 :   INFO) Component [csa213CompI3] : PID [4422]. Initializing&lt;br /&gt;
&lt;br /&gt;
Thu Oct 14 13:28:58.503 2010 (PayloadNodeI1.4422 : csa213CompEO.---.---.00003 :   INFO)    IOC Address             : 0x4&lt;br /&gt;
&lt;br /&gt;
Thu Oct 14 13:28:58.503 2010 (PayloadNodeI1.4422 : csa213CompEO.---.---.00004 :   INFO)    IOC Port                : 0x81&lt;br /&gt;
&lt;br /&gt;
Thu Oct 14 13:28:58.504 2010 (PayloadNodeI1.4422 : csa213CompEO.---.---.00005 :   INFO) csa213CompI3: Waiting for CSI assignment...&lt;br /&gt;
&lt;br /&gt;
Thu Oct 14 13:29:09.593 2010 (PayloadNodeI1.4422 : csa213CompEO.---.---.00006 :   INFO) Component [csa213CompI3] : PID [4422]. CSI Set Received&lt;br /&gt;
&lt;br /&gt;
Thu Oct 14 13:29:09.593 2010 (PayloadNodeI1.4422 : csa213CompEO.---.---.00007 :   INFO) CSI Flags : [Add One]&lt;br /&gt;
Thu Oct 14 13:29:09.593 2010 (PayloadNodeI1.4422 : csa213CompEO.---.---.00008 :   INFO) CSI Name : [csa213CSII0]&lt;br /&gt;
Thu Oct 14 13:29:09.593 2010 (PayloadNodeI1.4422 : csa213CompEO.---.---.00009 :   INFO) Name value pairs :&lt;br /&gt;
Thu Oct 14 13:29:09.593 2010 (PayloadNodeI1.4422 : csa213CompEO.---.---.00010 :   INFO) HA state : [Active]&lt;br /&gt;
Thu Oct 14 13:29:09.593 2010 (PayloadNodeI1.4422 : csa213CompEO.---.---.00011 :   INFO) Active Descriptor :&lt;br /&gt;
Thu Oct 14 13:29:09.593 2010 (PayloadNodeI1.4422 : csa213CompEO.---.---.00012 :   INFO) Transition Descriptor : [1]&lt;br /&gt;
Thu Oct 14 13:29:09.593 2010 (PayloadNodeI1.4422 : csa213CompEO.---.---.00013 :   INFO) Active Component : [csa213CompI3]&lt;br /&gt;
Thu Oct 14 13:29:09.593 2010 (PayloadNodeI1.4422 : csa213CompEO.---.---.00014 :   INFO) csa213: ACTIVE state request: activating service&lt;br /&gt;
Thu Oct 14 13:29:10.511 2010 (PayloadNodeI1.4422 : csa213CompEO.---.---.00015 :   INFO) csa213CompI3: Publishing Event: Thu Oct 14 13:29:10 2010&lt;br /&gt;
&lt;br /&gt;
Thu Oct 14 13:29:11.516 2010 (PayloadNodeI1.4422 : csa213CompEO.---.---.00016 :   INFO) csa213CompI3: Publishing Event: 0.29 0.42 0.25&lt;br /&gt;
&lt;br /&gt;
Thu Oct 14 13:29:12.521 2010 (PayloadNodeI1.4422 : csa213CompEO.---.---.00017 :   INFO) csa213CompI3: Publishing Event: Thu Oct 14 13:29:12 2010&lt;br /&gt;
&lt;br /&gt;
Thu Oct 14 13:29:13.526 2010 (PayloadNodeI1.4422 : csa213CompEO.---.---.00018 :   INFO) csa213CompI3: Publishing Event: 0.66 0.50 0.27&lt;br /&gt;
&lt;br /&gt;
Thu Oct 14 13:29:14.530 2010 (PayloadNodeI1.4422 : csa213CompEO.---.---.00019 :   INFO) csa213CompI3: Publishing Event: Thu Oct 14 13:29:14 2010&lt;br /&gt;
&lt;br /&gt;
Thu Oct 14 13:29:15.537 2010 (PayloadNodeI1.4422 : csa213CompEO.---.---.00020 :   INFO) csa213CompI3: Publishing Event: 0.66 0.50 0.27&lt;br /&gt;
&lt;br /&gt;
Thu Oct 14 13:29:16.538 2010 (PayloadNodeI1.4422 : csa213CompEO.---.---.00021 :   INFO) csa213CompI3: Publishing Event: Thu Oct 14 13:29:16 2010&lt;br /&gt;
&lt;br /&gt;
Thu Oct 14 13:29:17.541 2010 (PayloadNodeI1.4422 : csa213CompEO.---.---.00022 :   INFO) csa213CompI3: Publishing Event: 1.01 0.57 0.30&lt;br /&gt;
&lt;br /&gt;
Thu Oct 14 13:29:18.545 2010 (PayloadNodeI1.4422 : csa213CompEO.---.---.00023 :   INFO) csa213CompI3: Publishing Event: Thu Oct 14 13:29:18 2010&lt;br /&gt;
&lt;br /&gt;
Thu Oct 14 13:29:19.548 2010 (PayloadNodeI1.4422 : csa213CompEO.---.---.00024 :   INFO) csa213CompI3: Publishing Event: 1.01 0.57 0.30&lt;br /&gt;
&lt;br /&gt;
Thu Oct 14 13:29:20.549 2010 (PayloadNodeI1.4422 : csa213CompEO.---.---.00025 :   INFO) csa213CompI3: Publishing Event: Thu Oct 14 13:29:20 2010&lt;br /&gt;
&lt;br /&gt;
Thu Oct 14 13:29:21.554 2010 (PayloadNodeI1.4422 : csa213CompEO.---.---.00026 :   INFO) csa213CompI3: Publishing Event: 1.01 0.57 0.30&lt;br /&gt;
&lt;br /&gt;
Thu Oct 14 13:29:22.557 2010 (PayloadNodeI1.4422 : csa213CompEO.---.---.00027 :   INFO) csa213CompI3: Publishing Event: Thu Oct 14 13:29:22 2010&lt;br /&gt;
&lt;br /&gt;
Thu Oct 14 13:29:23.562 2010 (PayloadNodeI1.4422 : csa213CompEO.---.---.00028 :   INFO) csa213CompI3: Publishing Event: 1.17 0.61 0.31&lt;br /&gt;
&lt;br /&gt;
Thu Oct 14 13:29:24.563 2010 (PayloadNodeI1.4422 : csa213CompEO.---.---.00029 :   INFO) csa213CompI3: Publishing Event: Thu Oct 14 13:29:24 2010&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
Since the event subscriber application is also running you can see the events that it is receiving in the csa112 application log file. Again using &amp;lt;code&amp;gt;tail -f /rootasp//var/log/csa212CompI0Log.latest&amp;lt;/code&amp;gt; you can see the following:&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffffaa;&amp;quot; align=&amp;quot;center&amp;quot;| /root/asp/var/log/csa112CompI3Log.latest&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
Thu Oct 14 13:25:49.418 2010 (PayloadNodeI1.4003 : csa212CompEO.---.---.00001 :   INFO) Component [csa212CompI3] : PID [4003]. Initializing&lt;br /&gt;
&lt;br /&gt;
Thu Oct 14 13:25:49.418 2010 (PayloadNodeI1.4003 : csa212CompEO.---.---.00002 :   INFO)    IOC Address             : 0x4&lt;br /&gt;
&lt;br /&gt;
Thu Oct 14 13:25:49.419 2010 (PayloadNodeI1.4003 : csa212CompEO.---.---.00003 :   INFO)    IOC Port                : 0x80&lt;br /&gt;
&lt;br /&gt;
Thu Oct 14 13:26:01.942 2010 (PayloadNodeI1.4003 : csa212CompEO.---.---.00004 :   INFO) Component [csa212CompI3] : PID [4003]. CSI Set Received&lt;br /&gt;
&lt;br /&gt;
Thu Oct 14 13:26:01.942 2010 (PayloadNodeI1.4003 : csa212CompEO.---.---.00005 :   INFO) CSI Flags : [Add One]&lt;br /&gt;
Thu Oct 14 13:26:01.942 2010 (PayloadNodeI1.4003 : csa212CompEO.---.---.00006 :   INFO) CSI Name : [csa212CSII0]&lt;br /&gt;
Thu Oct 14 13:26:01.942 2010 (PayloadNodeI1.4003 : csa212CompEO.---.---.00007 :   INFO) Name value pairs :&lt;br /&gt;
Thu Oct 14 13:26:01.942 2010 (PayloadNodeI1.4003 : csa212CompEO.---.---.00008 :   INFO) HA state : [Active]&lt;br /&gt;
Thu Oct 14 13:26:01.942 2010 (PayloadNodeI1.4003 : csa212CompEO.---.---.00009 :   INFO) Active Descriptor :&lt;br /&gt;
Thu Oct 14 13:26:01.942 2010 (PayloadNodeI1.4003 : csa212CompEO.---.---.00010 :   INFO) Transition Descriptor : [1]&lt;br /&gt;
Thu Oct 14 13:26:01.942 2010 (PayloadNodeI1.4003 : csa212CompEO.---.---.00011 :   INFO) Active Component : [csa212CompI3]&lt;br /&gt;
Thu Oct 14 13:26:01.942 2010 (PayloadNodeI1.4003 : csa212CompEO.---.---.00012 :   INFO) csa212: ACTIVE state requested; activating service&lt;br /&gt;
Thu Oct 14 13:29:10.516 2010 (PayloadNodeI1.4003 : csa212CompEO.---.---.00013 :   INFO) We've got an event to receive&lt;br /&gt;
&lt;br /&gt;
Thu Oct 14 13:29:10.516 2010 (PayloadNodeI1.4003 : csa212CompEO.---.---.00014 :   INFO) received event: Thu Oct 14 13:29:10 2010&lt;br /&gt;
&lt;br /&gt;
Thu Oct 14 13:29:11.518 2010 (PayloadNodeI1.4003 : csa212CompEO.---.---.00015 :   INFO) We've got an event to receive&lt;br /&gt;
&lt;br /&gt;
Thu Oct 14 13:29:11.518 2010 (PayloadNodeI1.4003 : csa212CompEO.---.---.00016 :   INFO) received event: 0.29 0.42 0.25&lt;br /&gt;
&lt;br /&gt;
Thu Oct 14 13:29:12.525 2010 (PayloadNodeI1.4003 : csa212CompEO.---.---.00017 :   INFO) We've got an event to receive&lt;br /&gt;
&lt;br /&gt;
Thu Oct 14 13:29:12.525 2010 (PayloadNodeI1.4003 : csa212CompEO.---.---.00018 :   INFO) received event: Thu Oct 14 13:29:12 2010&lt;br /&gt;
&lt;br /&gt;
Thu Oct 14 13:29:13.529 2010 (PayloadNodeI1.4003 : csa212CompEO.---.---.00019 :   INFO) We've got an event to receive&lt;br /&gt;
&lt;br /&gt;
Thu Oct 14 13:29:13.529 2010 (PayloadNodeI1.4003 : csa212CompEO.---.---.00020 :   INFO) received event: 0.66 0.50 0.27&lt;br /&gt;
&lt;br /&gt;
Thu Oct 14 13:29:14.533 2010 (PayloadNodeI1.4003 : csa212CompEO.---.---.00021 :   INFO) We've got an event to receive&lt;br /&gt;
&lt;br /&gt;
Thu Oct 14 13:29:14.533 2010 (PayloadNodeI1.4003 : csa212CompEO.---.---.00022 :   INFO) received event: Thu Oct 14 13:29:14 2010&lt;br /&gt;
&lt;br /&gt;
Thu Oct 14 13:29:15.540 2010 (PayloadNodeI1.4003 : csa212CompEO.---.---.00023 :   INFO) We've got an event to receive&lt;br /&gt;
&lt;br /&gt;
Thu Oct 14 13:29:15.541 2010 (PayloadNodeI1.4003 : csa212CompEO.---.---.00024 :   INFO) received event: 0.66 0.50 0.27&lt;br /&gt;
&lt;br /&gt;
Thu Oct 14 13:29:16.540 2010 (PayloadNodeI1.4003 : csa212CompEO.---.---.00025 :   INFO) We've got an event to receive&lt;br /&gt;
&lt;br /&gt;
Thu Oct 14 13:29:16.540 2010 (PayloadNodeI1.4003 : csa212CompEO.---.---.00026 :   INFO) received event: Thu Oct 14 13:29:16 2010&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;Now you can shut everything down in the usual manner. Note that you will be shutting down two service groups.&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
cli[Test:SCNodeI0:CPM]-&amp;gt; amsLockAssignment sg csa213SGI0&lt;br /&gt;
cli[Test:SCNodeI0:CPM]-&amp;gt; amsLockAssignment sg csa212SGI0&lt;br /&gt;
cli[Test:SCNodeI0:CPM]-&amp;gt; amsLockInstantiation sg csa213SGI0&lt;br /&gt;
cli[Test:SCNodeI0:CPM]-&amp;gt; amsLockInstantiation sg csa212SGI0&lt;br /&gt;
cli[Test:SCNodeI0:CPM]-&amp;gt; end&lt;br /&gt;
cli[Test:SCNodeI0]-&amp;gt; end&lt;br /&gt;
cli[Test]-&amp;gt; bye&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Summary and References===&lt;br /&gt;
&lt;br /&gt;
We've seen how to initialize the event manager subsystem as an event publisher.  We've seen:&lt;br /&gt;
*events flow from the event publisher to the subscriber.  &lt;br /&gt;
*how to format events and send them through the event manager subsystem&lt;br /&gt;
*For further reading, check the same sources as listed under the csa212 section.&lt;/div&gt;</summary>
		<author><name>Madhu</name></author>	</entry>

	<entry>
		<id>https://help.openclovis.com/index.php/Doc:latest/evalguide/csa213</id>
		<title>Doc:latest/evalguide/csa213</title>
		<link rel="alternate" type="text/html" href="https://help.openclovis.com/index.php/Doc:latest/evalguide/csa213"/>
				<updated>2010-10-14T06:54:03Z</updated>
		
		<summary type="html">&lt;p&gt;Madhu: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==csa213 Event Publication==&lt;br /&gt;
&lt;br /&gt;
===Objective===&lt;br /&gt;
&lt;br /&gt;
The objective is to learn how to write an event publishing application using Clovis' Event Manager API.&lt;br /&gt;
&lt;br /&gt;
===What You Will Learn===&lt;br /&gt;
&lt;br /&gt;
*You will learn how to publish events using Clovis' Event Manager API.&lt;br /&gt;
&lt;br /&gt;
===Code===&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffccaa;&amp;quot; align=&amp;quot;center&amp;quot;| clCompAppMain.c&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
    int&lt;br /&gt;
    main(int argc, Char *argv[])&lt;br /&gt;
    {&lt;br /&gt;
        SaNameT             appName = {0};&lt;br /&gt;
        SaAmfCallbacksT     callbacks;&lt;br /&gt;
        SaVersionT          version;&lt;br /&gt;
        clIocPortT          iocPort;&lt;br /&gt;
        SaAisErrorT         rc = SA_AIS_OK;&lt;br /&gt;
        SaEvtChannelHandleT evtChannelHandle = 0&lt;br /&gt;
&lt;br /&gt;
        SaSelectionObjectT dispatch_fd;&lt;br /&gt;
        fd_set read_fds;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
        /*&lt;br /&gt;
         * ---BEGIN_APPLICATION_CODE---&lt;br /&gt;
         */&lt;br /&gt;
        &lt;br /&gt;
        SaEvtCallbacksT   evtCallbacks = { NULL, NULL };&lt;br /&gt;
&lt;br /&gt;
        /*&lt;br /&gt;
         * ---END_APPLICATION_CODE---&lt;br /&gt;
         */&lt;br /&gt;
        ...&lt;br /&gt;
&lt;br /&gt;
        if ( (rc = saAmfInitialize(&amp;amp;amfHandle, &amp;amp;callbacks, &amp;amp;version)) != SA_AIS_OK) &lt;br /&gt;
            goto errorexit;&lt;br /&gt;
&lt;br /&gt;
        ....&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
In the &amp;lt;code&amp;gt;main&amp;lt;/code&amp;gt; function of this example we again see a call to &amp;lt;code&amp;gt;saEvtInitialize&amp;lt;/code&amp;gt;.  Most everything else in the appInitialize function is the same as before in csa212, except that both callback function pointers are specified as &amp;lt;code&amp;gt;NULL&amp;lt;/code&amp;gt;.  This is because we neither open the event channel asynchronously, or subscribe to any events in this application. So there is no need to specify a callback to receive an event.&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffccaa;&amp;quot; align=&amp;quot;center&amp;quot;| clCompAppMain.c&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
    int&lt;br /&gt;
    main(int argc, Char *argv[])&lt;br /&gt;
    {&lt;br /&gt;
&lt;br /&gt;
        ...&lt;br /&gt;
&lt;br /&gt;
        // Open an event chanel so that we can subscribe to events on that channel&lt;br /&gt;
        rc = saEvtChannelOpen(gTestInfo.evtInitHandle,&lt;br /&gt;
                               &amp;amp;gTestInfo.evtChannelName,&lt;br /&gt;
                              (SA_EVT_CHANNEL_PUBLISHER |&lt;br /&gt;
                               SA_EVT_CHANNEL_CREATE),&lt;br /&gt;
                              (ClTimeT)SA_TIME_END,&lt;br /&gt;
                              &amp;amp;evtChannelHandle);&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
Here we open the event channel.  This is the same as in csa212 except that rather than opening as a SUBSCRIBER, we open as a &amp;lt;code&amp;gt;PUBLISHER&amp;lt;/code&amp;gt; (by specifying &amp;lt;code&amp;gt;SA_EVT_CHANNEL_PUBLISHER&amp;lt;/code&amp;gt; flag)&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffccaa;&amp;quot; align=&amp;quot;center&amp;quot;| clCompAppMain.c&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
    int&lt;br /&gt;
    main(int argc, Char *argv[])&lt;br /&gt;
    {&lt;br /&gt;
&lt;br /&gt;
        ...&lt;br /&gt;
&lt;br /&gt;
        rc = saEvtEventAllocate(evtChannelHandle,  &amp;amp;gTestInfo.eventHandle);&lt;br /&gt;
        if (rc != SA_AIS_OK)&lt;br /&gt;
        {&lt;br /&gt;
            logrc(CL_LOG_LOG_ERROR, &amp;quot;Failed to allocate event [0x%x]&amp;quot;,&lt;br /&gt;
                    rc);&lt;br /&gt;
            return rc;&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        rc = saEvtEventAttributesSet(gTestInfo.eventHandle,&lt;br /&gt;
                NULL,&lt;br /&gt;
                1,&lt;br /&gt;
                0,&lt;br /&gt;
                &amp;amp;gTestInfo.publisherName);&lt;br /&gt;
        if (rc != SA_AIS_OK)&lt;br /&gt;
        {&lt;br /&gt;
            logrc(CL_LOG_ERROR, &amp;quot;Failed to set event attributes [0x%x]&amp;quot;,&lt;br /&gt;
                    rc);&lt;br /&gt;
            return rc;&lt;br /&gt;
        }&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
The call to &amp;lt;code&amp;gt;saEvtEventAllocate&amp;lt;/code&amp;gt; allocates an event header.  This header is identified by the event handle passed back to &amp;lt;code&amp;gt;gTestInfo.eventHandle&amp;lt;/code&amp;gt;.  The handle should be used any time the event header is to be used to manipulate the header, either by using &amp;lt;code&amp;gt;saEvtEventAttributesSet&amp;lt;/code&amp;gt; (right below), or to send an event using the header as in &amp;lt;code&amp;gt;saEvtEventPublish&amp;lt;/code&amp;gt;.  The call to &amp;lt;code&amp;gt;saEvtEventAttributesSet&amp;lt;/code&amp;gt; defines the &amp;lt;code&amp;gt;EVENT_TYPE&amp;lt;/code&amp;gt; which is defined as 5432 in &amp;lt;code&amp;gt;common/common.h&amp;lt;/code&amp;gt; and is used in the event subscriber.  It also defines the priority to be 1 which is just below the highest priority of &amp;lt;code&amp;gt;CL_EVENT_HIGHEST_PRIORITY&amp;lt;/code&amp;gt; which is defined as 0 where &amp;lt;code&amp;gt;CL_EVENT_LOWEST_PRIORITY&amp;lt;/code&amp;gt; is defined as 3.  The retention time is specified as 0 since we don't want the event to be kept around if there is no subscriber to pick it up.  Finally the &amp;lt;code&amp;gt;publisherName&amp;lt;/code&amp;gt; is specified because it's required.  Our subscriber doesn't care who publishes the events it receives.&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffccaa;&amp;quot; align=&amp;quot;center&amp;quot;| clCompAppMain.c&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
    int&lt;br /&gt;
    main(int argc, Char *argv[])&lt;br /&gt;
    {&lt;br /&gt;
&lt;br /&gt;
        ...&lt;br /&gt;
&lt;br /&gt;
        while (!gTestInfo.exiting)&lt;br /&gt;
        {&lt;br /&gt;
            if (gTestInfo.running &amp;amp;&amp;amp; gTestInfo.ha_state == CL_AMS_HA_STATE_ACTIVE)&lt;br /&gt;
            {&lt;br /&gt;
                csa213Comp_PublishEvent();&lt;br /&gt;
            }&lt;br /&gt;
            sleep(1);&lt;br /&gt;
        }&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
Here is the main loop.  As long as the application is running and active we make a call to &amp;lt;code&amp;gt;csa213Comp_PublishEvent&amp;lt;/code&amp;gt;.  The work of the application takes place in &amp;lt;code&amp;gt;csa213Comp_PublishEvent&amp;lt;/code&amp;gt;, which is presented below.&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffccaa;&amp;quot; align=&amp;quot;center&amp;quot;| clCompAppMain.c&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
    static ClRcT&lt;br /&gt;
    csa213Comp_PublishEvent()&lt;br /&gt;
    {&lt;br /&gt;
        SaAisErrorT     rc              = SA_AIS_OK;&lt;br /&gt;
        ClEventIdT      eventId         = 0;&lt;br /&gt;
        static int      index           = 0;&lt;br /&gt;
        SASizeT         data_len        = 0;&lt;br /&gt;
        char            *data           = 0;&lt;br /&gt;
        typedef void (*Generator)(char **, ClSizeT*);&lt;br /&gt;
    &lt;br /&gt;
        //&lt;br /&gt;
        // Note: to add a new generator, just define it above and then include&lt;br /&gt;
        // the new functions name in the generators list.&lt;br /&gt;
        // Next, maybe something that gets disk free info by way of getfsent&lt;br /&gt;
        // and statfs?&lt;br /&gt;
        static Generator generators[]   =&lt;br /&gt;
        { &lt;br /&gt;
            generate_time_of_day,&lt;br /&gt;
            generate_load_average&lt;br /&gt;
        };&lt;br /&gt;
&lt;br /&gt;
        //&lt;br /&gt;
        // every time through increment index and then set index to&lt;br /&gt;
        // it's value modulo the number of entries in the generators&lt;br /&gt;
        // array.  This will cause us to cycle through the list of&lt;br /&gt;
        // generators as we're called to publish events.&lt;br /&gt;
        (*generators[index++])(&amp;amp;data, &amp;amp;data_len);&lt;br /&gt;
        index %= (int)(sizeof generators / sizeof generators[0]);&lt;br /&gt;
        if (data == 0 || data_len == 0)&lt;br /&gt;
        {&lt;br /&gt;
            logmsg(CL_LOG_ERROR, &amp;quot;no event data generated&amp;quot;);&lt;br /&gt;
            return CL_ERR_NO_MEMORY;&lt;br /&gt;
        }&lt;br /&gt;
        clprintf(CL_LOG_SEV_INFO,&amp;quot;Publishing Event: %.*s&amp;quot;, (int)data_len, data);&lt;br /&gt;
        rc = saEvtEventPublish(gTestInfo.eventHandle, (void*)data, data_len, &amp;amp;eventId);&lt;br /&gt;
        clHeapFree(data);&lt;br /&gt;
&lt;br /&gt;
        return CL_OK;&lt;br /&gt;
    }&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
There's code to call one of a list of generator functions.  The functions on the list, return a pointer and a length which are used to pass to &amp;lt;code&amp;gt;saEvtEventPublish&amp;lt;/code&amp;gt;.  We pass the eventHandle  prepared earlier with &amp;lt;code&amp;gt;saEvtEventAllocate&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;saEvtEventAttributesSet&amp;lt;/code&amp;gt;.  Pass the pointer and the length that we get back from the generator function.  Those are used to package up the event data and send it to any subscribers.  We also pass the address of the &amp;lt;code&amp;gt;eventId&amp;lt;/code&amp;gt; local variable.  This is required so that the &amp;lt;code&amp;gt;saEvtEventPublish&amp;lt;/code&amp;gt; function can return the event ID.  We don't need it, so we promptly drop it in the bit bucket.  Finally, we free the data that was allocated in the generator function and passed back as we no longer need it.&lt;br /&gt;
&lt;br /&gt;
===csa213 SA Forum Compliant Event Publication===&lt;br /&gt;
&lt;br /&gt;
This sample application demonstrates the usage of SA Forum Event Service. As mentioned previously, this sample application does not deviate functionally with csa213. The code differences are due to using SA Forum data types (structures) and APIs , as presented in the following two tables. (Note we have not repeated data types and APIs covered previously.)&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|+align=&amp;quot;bottom&amp;quot;| '''SA Forum Data Types with the SAFplus Platform equivalent'''&lt;br /&gt;
|- style=&amp;quot;color:black;background-color:#ffffaa;&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
!SA Forum Data Types   &lt;br /&gt;
!OpenClovis Data Types&lt;br /&gt;
|-&lt;br /&gt;
|SaEvtHandleT&lt;br /&gt;
|ClEventHandleT&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|+align=&amp;quot;bottom&amp;quot;| '''SA Forum APIs with the SAFplus Platform equivalent'''&lt;br /&gt;
|- style=&amp;quot;color:black;background-color:#ffffaa;&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
!SA Forum APIs&lt;br /&gt;
!OpenClovis APIs&lt;br /&gt;
|-&lt;br /&gt;
|SaEvtEventAllocate&lt;br /&gt;
|ClEventAllocate&lt;br /&gt;
|-&lt;br /&gt;
|saEvtEventAttributesSet&lt;br /&gt;
|clEventExtAttributesSet&lt;br /&gt;
|-&lt;br /&gt;
|saEvtEventPublish&lt;br /&gt;
|clEventPublish&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===How to Run csa213 and What to Observe===&lt;br /&gt;
&lt;br /&gt;
In csa213 you will be observing an event publishing application. This will be far more interesting if you observe an event subscription application at the same time. For this we will use the example from csa212.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;First you should start up csa212 and put it in a LockAssignment state so that it can receive events.&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
 # cd /root/asp/bin&lt;br /&gt;
 # ./asp_console&lt;br /&gt;
&lt;br /&gt;
cli[Test]-&amp;gt; setc 1&lt;br /&gt;
cli[Test:SCNodeI0]-&amp;gt; setc cpm&lt;br /&gt;
cli[Test:SCNodeI0:CPM]-&amp;gt; amsLockAssignment sg csa212SGI0&lt;br /&gt;
cli[Test:SCNodeI0:CPM]-&amp;gt; amsUnlock sg csa212SGI0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the csa212 application log you should see:&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffffaa;&amp;quot; align=&amp;quot;center&amp;quot;| $ /root/asp/var/log/csa112CompI0Log.latest &lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
Mon Jul 14 22:50:34 2008   (SCNodeI0.24830 : csa112CompEO.---.---.00037 :   INFO)&lt;br /&gt;
 csa112: Instantiated as component instance csa112CompI0.&lt;br /&gt;
Mon Jul 14 22:50:34 2008   (SCNodeI0.24830 : csa112CompEO.---.---.00038 :   INFO)&lt;br /&gt;
 csa112CompI0: Waiting for CSI assignment...&lt;br /&gt;
Mon Jul 14 22:51:20 2008   (SCNodeI0.24830 : csa112CompEO.---.---.00041 :   INFO)&lt;br /&gt;
 Component [csa112CompI0] : PID [24830]. CSI Set Received&lt;br /&gt;
Mon Jul 14 22:51:20 2008   (SCNodeI0.24830 : csa112CompEO.---.---.00042 :   INFO)&lt;br /&gt;
    CSI Flags               : [Add One]&lt;br /&gt;
Mon Jul 14 22:51:20 2008   (SCNodeI0.24830 : csa112CompEO.---.---.00043 :   INFO)&lt;br /&gt;
    CSI Name                : [csa112CSII0]&lt;br /&gt;
Mon Jul 14 22:51:20 2008   (SCNodeI0.24830 : csa112CompEO.---.---.00044 :   INFO)&lt;br /&gt;
    Name Value Pairs        :&lt;br /&gt;
Mon Jul 14 22:51:20 2008   (SCNodeI0.24830 : csa112CompEO.---.---.00045 :   INFO)&lt;br /&gt;
    HA State                : [Active]&lt;br /&gt;
Mon Jul 14 22:51:20 2008   (SCNodeI0.24830 : csa112CompEO.---.---.00046 :   INFO)&lt;br /&gt;
    Active Descriptor       :&lt;br /&gt;
Mon Jul 14 22:51:20 2008   (SCNodeI0.24830 : csa112CompEO.---.---.00047 :   INFO)&lt;br /&gt;
      Transition Descriptor : [1]&lt;br /&gt;
Mon Jul 14 22:51:20 2008   (SCNodeI0.24830 : csa112CompEO.---.---.00048 :   INFO)&lt;br /&gt;
        Active Component    : [csa112CompI0]&lt;br /&gt;
Mon Jul 14 22:51:20 2008   (SCNodeI0.24830 : csa112CompEO.---.---.00049 :   INFO)&lt;br /&gt;
 csa112: ACTIVE state requested; activating service&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
[[File:OpenClovis_Note.png]]When running model csa212 you will see the output described above for the the amsLockAssignment and amsUnlock commands. Unlock csa212SGI0 instead of csa112SGI0.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;Now you can start up the event publishing application and put it in a LockAssignment state.&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
cli[Test:SCNodeI0:CPM]-&amp;gt; amsLockAssignment sg csa213SGI0&lt;br /&gt;
cli[Test:SCNodeI0:CPM]-&amp;gt; amsUnlock sg csa213SGI0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Putting csa213 into a LockAssignment state caused it to begin publishing events. Using &amp;lt;code&amp;gt;tail -f /root/asp/var/log/csa213CompI0Log.latest&amp;lt;/code&amp;gt; on the csa213 application log you can see the events being published.&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffffaa;&amp;quot; align=&amp;quot;center&amp;quot;| $ /root/asp/var/log/csa113CompI0Log.latest &lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
Mon Jul 14 22:53:54 2008   (SCNodeI0.24890 : csa113CompEO.---.---.00028 :   INFO)&lt;br /&gt;
 Component [csa113CompI0] : PID [24890]. Initializing&lt;br /&gt;
Mon Jul 14 22:53:54 2008   (SCNodeI0.24890 : csa113CompEO.---.---.00029 :   INFO)&lt;br /&gt;
    IOC Address             : 0x1&lt;br /&gt;
Mon Jul 14 22:53:54 2008   (SCNodeI0.24890 : csa113CompEO.---.---.00030 :   INFO)&lt;br /&gt;
    IOC Port                : 0x81&lt;br /&gt;
Mon Jul 14 22:53:54 2008   (SCNodeI0.24890 : csa113CompEO.---.---.00037 :   INFO)&lt;br /&gt;
 Instantiated as component instance csa113CompI0.&lt;br /&gt;
Mon Jul 14 22:53:54 2008   (SCNodeI0.24890 : csa113CompEO.---.---.00038 :   INFO)&lt;br /&gt;
 csa113CompI0: Waiting for CSI assignment...&lt;br /&gt;
Mon Jul 14 22:53:59 2008   (SCNodeI0.24890 : csa113CompEO.---.---.00041 :   INFO)&lt;br /&gt;
 Component [csa113CompI0] : PID [24890]. CSI Set Received&lt;br /&gt;
Mon Jul 14 22:53:59 2008   (SCNodeI0.24890 : csa113CompEO.---.---.00042 :   INFO)&lt;br /&gt;
    CSI Flags               : [Add One]&lt;br /&gt;
Mon Jul 14 22:53:59 2008   (SCNodeI0.24890 : csa113CompEO.---.---.00043 :   INFO)&lt;br /&gt;
    CSI Name                : [csa113CSII0]&lt;br /&gt;
Mon Jul 14 22:53:59 2008   (SCNodeI0.24890 : csa113CompEO.---.---.00044 :   INFO)&lt;br /&gt;
    Name Value Pairs        :&lt;br /&gt;
Mon Jul 14 22:53:59 2008   (SCNodeI0.24890 : csa113CompEO.---.---.00045 :   INFO)&lt;br /&gt;
    HA State                : [Active]&lt;br /&gt;
Mon Jul 14 22:53:59 2008   (SCNodeI0.24890 : csa113CompEO.---.---.00046 :   INFO)&lt;br /&gt;
    Active Descriptor       :&lt;br /&gt;
Mon Jul 14 22:53:59 2008   (SCNodeI0.24890 : csa113CompEO.---.---.00047 :   INFO)&lt;br /&gt;
      Transition Descriptor : [1]&lt;br /&gt;
Mon Jul 14 22:53:59 2008   (SCNodeI0.24890 : csa113CompEO.---.---.00048 :   INFO)&lt;br /&gt;
        Active Component    : [csa113CompI0]&lt;br /&gt;
Mon Jul 14 22:53:59 2008   (SCNodeI0.24890 : csa113CompEO.---.---.00049 :   INFO)&lt;br /&gt;
 csa113: ACTIVE state requested; activating service&lt;br /&gt;
Mon Jul 14 22:53:59 2008   (SCNodeI0.24890 : csa113CompEO.---.---.00050 : NOTICE)&lt;br /&gt;
 Publishing Event: Mon Jul 14 22:53:59 2008&lt;br /&gt;
Mon Jul 14 22:54:00 2008   (SCNodeI0.24890 : csa113CompEO.---.---.00052 : NOTICE)&lt;br /&gt;
 Publishing Event: 0.05 0.07 0.03&lt;br /&gt;
Mon Jul 14 22:54:01 2008   (SCNodeI0.24890 : csa113CompEO.---.---.00054 : NOTICE)&lt;br /&gt;
 Publishing Event: Mon Jul 14 22:54:01 2008&lt;br /&gt;
Mon Jul 14 22:54:02 2008   (SCNodeI0.24890 : csa113CompEO.---.---.00056 : NOTICE)&lt;br /&gt;
 Publishing Event: 0.05 0.07 0.03&lt;br /&gt;
Mon Jul 14 22:54:03 2008   (SCNodeI0.24890 : csa113CompEO.---.---.00058 : NOTICE)&lt;br /&gt;
 Publishing Event: Mon Jul 14 22:54:03 2008&lt;br /&gt;
Mon Jul 14 22:54:04 2008   (SCNodeI0.24890 : csa113CompEO.---.---.00060 : NOTICE)&lt;br /&gt;
 Publishing Event: 0.05 0.07 0.03&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
Since the event subscriber application is also running you can see the events that it is receiving in the csa112 application log file. Again using &amp;lt;code&amp;gt;tail -f /rootasp//var/log/csa212CompI0Log.latest&amp;lt;/code&amp;gt; you can see the following:&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffffaa;&amp;quot; align=&amp;quot;center&amp;quot;| /root/asp/var/log/csa112CompI0Log.latest&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
Mon Jul 14 22:53:59 2008   (SCNodeI0.24830 : csa112CompEO.---.---.00052 : NOTICE)&lt;br /&gt;
 We've got an event to receive&lt;br /&gt;
Mon Jul 14 22:53:59 2008   (SCNodeI0.24830 : csa112CompEO.---.---.00054 : NOTICE)&lt;br /&gt;
 received event: Mon Jul 14 22:53:59 2008&lt;br /&gt;
Mon Jul 14 22:54:00 2008   (SCNodeI0.24830 : csa112CompEO.---.---.00058 : NOTICE)&lt;br /&gt;
 We've got an event to receive&lt;br /&gt;
Mon Jul 14 22:54:00 2008   (SCNodeI0.24830 : csa112CompEO.---.---.00060 : NOTICE)&lt;br /&gt;
 received event: 0.05 0.07 0.03&lt;br /&gt;
Mon Jul 14 22:54:01 2008   (SCNodeI0.24830 : csa112CompEO.---.---.00064 : NOTICE)&lt;br /&gt;
 We've got an event to receive&lt;br /&gt;
Mon Jul 14 22:54:01 2008   (SCNodeI0.24830 : csa112CompEO.---.---.00066 : NOTICE)&lt;br /&gt;
 received event: Mon Jul 14 22:54:01 2008&lt;br /&gt;
Mon Jul 14 22:54:02 2008   (SCNodeI0.24830 : csa112CompEO.---.---.00070 : NOTICE)&lt;br /&gt;
 We've got an event to receive&lt;br /&gt;
Mon Jul 14 22:54:02 2008   (SCNodeI0.24830 : csa112CompEO.---.---.00072 : NOTICE)&lt;br /&gt;
 received event: 0.05 0.07 0.03&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;Now you can shut everything down in the usual manner. Note that you will be shutting down two service groups.&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
cli[Test:SCNodeI0:CPM]-&amp;gt; amsLockAssignment sg csa213SGI0&lt;br /&gt;
cli[Test:SCNodeI0:CPM]-&amp;gt; amsLockAssignment sg csa212SGI0&lt;br /&gt;
cli[Test:SCNodeI0:CPM]-&amp;gt; amsLockInstantiation sg csa213SGI0&lt;br /&gt;
cli[Test:SCNodeI0:CPM]-&amp;gt; amsLockInstantiation sg csa212SGI0&lt;br /&gt;
cli[Test:SCNodeI0:CPM]-&amp;gt; end&lt;br /&gt;
cli[Test:SCNodeI0]-&amp;gt; end&lt;br /&gt;
cli[Test]-&amp;gt; bye&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Summary and References===&lt;br /&gt;
&lt;br /&gt;
We've seen how to initialize the event manager subsystem as an event publisher.  We've seen:&lt;br /&gt;
*events flow from the event publisher to the subscriber.  &lt;br /&gt;
*how to format events and send them through the event manager subsystem&lt;br /&gt;
*For further reading, check the same sources as listed under the csa212 section.&lt;/div&gt;</summary>
		<author><name>Madhu</name></author>	</entry>

	<entry>
		<id>https://help.openclovis.com/index.php/Doc:latest/evalguide/csa213</id>
		<title>Doc:latest/evalguide/csa213</title>
		<link rel="alternate" type="text/html" href="https://help.openclovis.com/index.php/Doc:latest/evalguide/csa213"/>
				<updated>2010-10-13T09:19:40Z</updated>
		
		<summary type="html">&lt;p&gt;Madhu: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==csa213 Event Publication==&lt;br /&gt;
&lt;br /&gt;
===Objective===&lt;br /&gt;
&lt;br /&gt;
The objective is to learn how to write an event publishing application using Clovis' Event Manager API.&lt;br /&gt;
&lt;br /&gt;
===What You Will Learn===&lt;br /&gt;
&lt;br /&gt;
*You will learn how to publish events using Clovis' Event Manager API.&lt;br /&gt;
&lt;br /&gt;
===Code===&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffccaa;&amp;quot; align=&amp;quot;center&amp;quot;| clCompAppMain.c&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
    ClRcT&lt;br /&gt;
    clCompAppInitialize(&lt;br /&gt;
        ClUint32T argc,&lt;br /&gt;
        ClCharT *argv[])&lt;br /&gt;
    {&lt;br /&gt;
        ClNameT             appName;&lt;br /&gt;
        ClCpmCallbacksT     callbacks;&lt;br /&gt;
        ClVersionT          version;&lt;br /&gt;
        ClIocPortT          iocPort;&lt;br /&gt;
        ClRcT               rc = CL_OK;&lt;br /&gt;
&lt;br /&gt;
        /*&lt;br /&gt;
         * ---BEGIN_APPLICATION_CODE---&lt;br /&gt;
         */&lt;br /&gt;
        ClVersionT          evtVersion = CL_EVENT_VERSION;&lt;br /&gt;
        ClEventCallbacksT   evtCallbacks = { NULL, NULL };&lt;br /&gt;
&lt;br /&gt;
        /*&lt;br /&gt;
         * ---END_APPLICATION_CODE---&lt;br /&gt;
         */&lt;br /&gt;
        ...&lt;br /&gt;
&lt;br /&gt;
        if ( (rc = clCpmClientInitialize(&amp;amp;cpmHandle, &amp;amp;callbacks, &amp;amp;version)) ) &lt;br /&gt;
            goto errorexit;&lt;br /&gt;
&lt;br /&gt;
        ....&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
In the &amp;lt;code&amp;gt;clCompAppInitialize&amp;lt;/code&amp;gt; function of this example we again see a call to &amp;lt;code&amp;gt;clEventInitialize&amp;lt;/code&amp;gt;.  Most everything else in the appInitialize function is the same as before in csa112, except that both callback function pointers are specified as &amp;lt;code&amp;gt;NULL&amp;lt;/code&amp;gt;.  This is because we neither open the event channel asynchronously, or subscribe to any events in this application. So there is no need to specify a callback to receive an event.&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffccaa;&amp;quot; align=&amp;quot;center&amp;quot;| clCompAppMain.c&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
    ClRcT&lt;br /&gt;
    clCompAppInitialize(&lt;br /&gt;
        ClUint32T argc,&lt;br /&gt;
        ClCharT *argv[])&lt;br /&gt;
    {&lt;br /&gt;
&lt;br /&gt;
        ...&lt;br /&gt;
&lt;br /&gt;
        // Open an event chanel so that we can subscribe to events on that channel&lt;br /&gt;
        rc = clEventChannelOpen(evtHandle,&lt;br /&gt;
                &amp;amp;evtChannelName,&lt;br /&gt;
                (CL_EVENT_CHANNEL_PUBLISHER |&lt;br /&gt;
                 CL_EVENT_GLOBAL_CHANNEL |&lt;br /&gt;
                 CL_EVENT_CHANNEL_CREATE),&lt;br /&gt;
                (ClTimeT)CL_RMD_TIMEOUT_FOREVER,&lt;br /&gt;
                &amp;amp;evtChannelHandle);&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
Here we open the event channel.  This is the same as in csa112 except that rather than opening as a SUBSCRIBER, we open as a &amp;lt;code&amp;gt;PUBLISHER&amp;lt;/code&amp;gt; (by specifying &amp;lt;code&amp;gt;CL_EVENT_CHANNEL_PUBLISHER&amp;lt;/code&amp;gt; flag)&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffccaa;&amp;quot; align=&amp;quot;center&amp;quot;| clCompAppMain.c&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
    ClRcT&lt;br /&gt;
    clCompAppInitialize(&lt;br /&gt;
        ClUint32T argc,&lt;br /&gt;
        ClCharT *argv[])&lt;br /&gt;
    {&lt;br /&gt;
&lt;br /&gt;
        ...&lt;br /&gt;
&lt;br /&gt;
        rc = clEventAllocate(evtChannelHandle, &amp;amp;eventHandle);&lt;br /&gt;
        if (rc != CL_OK)&lt;br /&gt;
        {&lt;br /&gt;
            clprintf(CL_LOG_SEV_ERROR, &amp;quot;Failed to allocate event [0x%x]&amp;quot;,&lt;br /&gt;
                    rc);&lt;br /&gt;
            return rc;&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        rc = clEventExtAttributesSet(eventHandle,&lt;br /&gt;
                EVENT_TYPE,&lt;br /&gt;
                1,&lt;br /&gt;
                0,&lt;br /&gt;
                &amp;amp;publisherName);&lt;br /&gt;
        if (rc != CL_OK)&lt;br /&gt;
        {&lt;br /&gt;
            clprintf(CL_LOG_SEV_ERROR, &amp;quot;Failed to set event attributes [0x%x]&amp;quot;,&lt;br /&gt;
                    rc);&lt;br /&gt;
            return rc;&lt;br /&gt;
        }&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
The call to &amp;lt;code&amp;gt;clEventAllocate&amp;lt;/code&amp;gt; allocates an event header.  This header is identified by the event handle passed back to &amp;lt;code&amp;gt;gTestInfo.eventHandle&amp;lt;/code&amp;gt;.  The handle should be used any time the event header is to be used to manipulate the header, either by using &amp;lt;code&amp;gt;clEventExtAttributesSet&amp;lt;/code&amp;gt; (right below), or to send an event using the header as in &amp;lt;code&amp;gt;clEventPublish&amp;lt;/code&amp;gt;.  The call to &amp;lt;code&amp;gt;clEventExtAttributesSet&amp;lt;/code&amp;gt; defines the &amp;lt;code&amp;gt;EVENT_TYPE&amp;lt;/code&amp;gt; which is defined as 5432 in &amp;lt;code&amp;gt;common/common.h&amp;lt;/code&amp;gt; and is used in the event subscriber.  It also defines the priority to be 1 which is just below the highest priority of &amp;lt;code&amp;gt;CL_EVENT_HIGHEST_PRIORITY&amp;lt;/code&amp;gt; which is defined as 0 where &amp;lt;code&amp;gt;CL_EVENT_LOWEST_PRIORITY&amp;lt;/code&amp;gt; is defined as 3.  The retention time is specified as 0 since we don't want the event to be kept around if there is no subscriber to pick it up.  Finally the &amp;lt;code&amp;gt;publisherName&amp;lt;/code&amp;gt; is specified because it's required.  Our subscriber doesn't care who publishes the events it receives.&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffccaa;&amp;quot; align=&amp;quot;center&amp;quot;| clCompAppMain.c&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
    ClRcT&lt;br /&gt;
    clCompAppInitialize(&lt;br /&gt;
        ClUint32T argc,&lt;br /&gt;
        ClCharT *argv[])&lt;br /&gt;
    {&lt;br /&gt;
&lt;br /&gt;
        ...&lt;br /&gt;
&lt;br /&gt;
        while (!exiting)&lt;br /&gt;
        {&lt;br /&gt;
            if (running &amp;amp;&amp;amp; ha_state == CL_AMS_HA_STATE_ACTIVE)&lt;br /&gt;
            {&lt;br /&gt;
                csa113Comp_PublishEvent();&lt;br /&gt;
            }&lt;br /&gt;
            sleep(1);&lt;br /&gt;
        }&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
Here is the main loop.  As long as the application is running and active we make a call to &amp;lt;code&amp;gt;csa113Comp_PublishEvent&amp;lt;/code&amp;gt;.  The work of the application takes place in &amp;lt;code&amp;gt;csa113Comp_PublishEvent&amp;lt;/code&amp;gt;, which is presented below.&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffccaa;&amp;quot; align=&amp;quot;center&amp;quot;| clCompAppMain.c&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
    static ClRcT&lt;br /&gt;
    csa113Comp_PublishEvent()&lt;br /&gt;
    {&lt;br /&gt;
        ClRcT           rc              = CL_OK;&lt;br /&gt;
        ClEventIdT      eventId         = 0;&lt;br /&gt;
        static int      index           = 0;&lt;br /&gt;
        ClSizeT         data_len        = 0;&lt;br /&gt;
        char            *data           = 0;&lt;br /&gt;
        typedef void (*Generator)(char **, ClSizeT*);&lt;br /&gt;
    &lt;br /&gt;
        //&lt;br /&gt;
        // Note: to add a new generator, just define it above and then include&lt;br /&gt;
        // the new functions name in the generators list.&lt;br /&gt;
        // Next, maybe something that gets disk free info by way of getfsent&lt;br /&gt;
        // and statfs?&lt;br /&gt;
        static Generator generators[]   =&lt;br /&gt;
        { &lt;br /&gt;
            generate_time_of_day,&lt;br /&gt;
            generate_load_average&lt;br /&gt;
        };&lt;br /&gt;
&lt;br /&gt;
        //&lt;br /&gt;
        // every time through increment index and then set index to&lt;br /&gt;
        // it's value modulo the number of entries in the generators&lt;br /&gt;
        // array.  This will cause us to cycle through the list of&lt;br /&gt;
        // generators as we're called to publish events.&lt;br /&gt;
        (*generators[index++])(&amp;amp;data, &amp;amp;data_len);&lt;br /&gt;
        index %= (int)(sizeof generators / sizeof generators[0]);&lt;br /&gt;
        if (data == 0 || data_len == 0)&lt;br /&gt;
        {&lt;br /&gt;
            clprintf(CL_LOG_SEV_ERROR, &amp;quot;no event data generated&amp;quot;);&lt;br /&gt;
            return CL_ERR_NO_MEMORY;&lt;br /&gt;
        }&lt;br /&gt;
        clprintf(CL_LOG_SEV_NOTICE,&amp;quot;Publishing Event: %.*s&amp;quot;, (int)data_len, data);&lt;br /&gt;
        rc = clEventPublish(eventHandle, data, data_len, &amp;amp;eventId);&lt;br /&gt;
        clHeapFree(data);&lt;br /&gt;
&lt;br /&gt;
        return CL_OK;&lt;br /&gt;
    }&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
There's code to call one of a list of generator functions.  The functions on the list, return a pointer and a length which are used to pass to &amp;lt;code&amp;gt;clEventPublish&amp;lt;/code&amp;gt;.  We pass the eventHandle  prepared earlier with &amp;lt;code&amp;gt;clEventAllocate&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;clEventExtAttributesSet&amp;lt;/code&amp;gt;.  Pass the pointer and the length that we get back from the generator function.  Those are used to package up the event data and send it to any subscribers.  We also pass the address of the &amp;lt;code&amp;gt;eventId&amp;lt;/code&amp;gt; local variable.  This is required so that the &amp;lt;code&amp;gt;clEventPublish&amp;lt;/code&amp;gt; function can return the event ID.  We don't need it, so we promptly drop it in the bit bucket.  Finally, we free the data that was allocated in the generator function and passed back as we no longer need it.&lt;br /&gt;
&lt;br /&gt;
===csa213 SA Forum Compliant Event Publication===&lt;br /&gt;
&lt;br /&gt;
This sample application demonstrates the usage of SA Forum Event Service. As mentioned previously, this sample application does not deviate functionally with csa113. The code differences are due to using SA Forum data types (structures) and APIs , as presented in the following two tables. (Note we have not repeated data types and APIs covered previously.)&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|+align=&amp;quot;bottom&amp;quot;| '''SA Forum Data Types with the SAFplus Platform equivalent'''&lt;br /&gt;
|- style=&amp;quot;color:black;background-color:#ffffaa;&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
!SA Forum Data Types   &lt;br /&gt;
!OpenClovis Data Types&lt;br /&gt;
|-&lt;br /&gt;
|SaEvtHandleT&lt;br /&gt;
|ClEventHandleT&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|+align=&amp;quot;bottom&amp;quot;| '''SA Forum APIs with the SAFplus Platform equivalent'''&lt;br /&gt;
|- style=&amp;quot;color:black;background-color:#ffffaa;&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
!SA Forum APIs&lt;br /&gt;
!OpenClovis APIs&lt;br /&gt;
|-&lt;br /&gt;
|SaEvtEventAllocate&lt;br /&gt;
|ClEventAllocate&lt;br /&gt;
|-&lt;br /&gt;
|saEvtEventAttributesSet&lt;br /&gt;
|clEventExtAttributesSet&lt;br /&gt;
|-&lt;br /&gt;
|saEvtEventPublish&lt;br /&gt;
|clEventPublish&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===How to Run csa113 and What to Observe===&lt;br /&gt;
&lt;br /&gt;
In csa113 you will be observing an event publishing application. This will be far more interesting if you observe an event subscription application at the same time. For this we will use the example from csa112.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;First you should start up csa112 and put it in a LockAssignment state so that it can receive events.(Unlock csa212SGI0 instead of csa112SGI0 to run csa213).&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
 # cd /root/asp/bin&lt;br /&gt;
 # ./asp_console&lt;br /&gt;
&lt;br /&gt;
cli[Test]-&amp;gt; setc 1&lt;br /&gt;
cli[Test:SCNodeI0]-&amp;gt; setc cpm&lt;br /&gt;
cli[Test:SCNodeI0:CPM]-&amp;gt; amsLockAssignment sg csa112SGI0&lt;br /&gt;
cli[Test:SCNodeI0:CPM]-&amp;gt; amsUnlock sg csa112SGI0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the csa112 application log you should see:&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffffaa;&amp;quot; align=&amp;quot;center&amp;quot;| $ /root/asp/var/log/csa112CompI0Log.latest &lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
Mon Jul 14 22:50:34 2008   (SCNodeI0.24830 : csa112CompEO.---.---.00037 :   INFO)&lt;br /&gt;
 csa112: Instantiated as component instance csa112CompI0.&lt;br /&gt;
Mon Jul 14 22:50:34 2008   (SCNodeI0.24830 : csa112CompEO.---.---.00038 :   INFO)&lt;br /&gt;
 csa112CompI0: Waiting for CSI assignment...&lt;br /&gt;
Mon Jul 14 22:51:20 2008   (SCNodeI0.24830 : csa112CompEO.---.---.00041 :   INFO)&lt;br /&gt;
 Component [csa112CompI0] : PID [24830]. CSI Set Received&lt;br /&gt;
Mon Jul 14 22:51:20 2008   (SCNodeI0.24830 : csa112CompEO.---.---.00042 :   INFO)&lt;br /&gt;
    CSI Flags               : [Add One]&lt;br /&gt;
Mon Jul 14 22:51:20 2008   (SCNodeI0.24830 : csa112CompEO.---.---.00043 :   INFO)&lt;br /&gt;
    CSI Name                : [csa112CSII0]&lt;br /&gt;
Mon Jul 14 22:51:20 2008   (SCNodeI0.24830 : csa112CompEO.---.---.00044 :   INFO)&lt;br /&gt;
    Name Value Pairs        :&lt;br /&gt;
Mon Jul 14 22:51:20 2008   (SCNodeI0.24830 : csa112CompEO.---.---.00045 :   INFO)&lt;br /&gt;
    HA State                : [Active]&lt;br /&gt;
Mon Jul 14 22:51:20 2008   (SCNodeI0.24830 : csa112CompEO.---.---.00046 :   INFO)&lt;br /&gt;
    Active Descriptor       :&lt;br /&gt;
Mon Jul 14 22:51:20 2008   (SCNodeI0.24830 : csa112CompEO.---.---.00047 :   INFO)&lt;br /&gt;
      Transition Descriptor : [1]&lt;br /&gt;
Mon Jul 14 22:51:20 2008   (SCNodeI0.24830 : csa112CompEO.---.---.00048 :   INFO)&lt;br /&gt;
        Active Component    : [csa112CompI0]&lt;br /&gt;
Mon Jul 14 22:51:20 2008   (SCNodeI0.24830 : csa112CompEO.---.---.00049 :   INFO)&lt;br /&gt;
 csa112: ACTIVE state requested; activating service&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
[[File:OpenClovis_Note.png]]When running model csa212 you will not see the output described above for the the amsLockAssignment and amsUnlock commands. Unlock csa212SGI0 instead of csa112SGI0.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;Now you can start up the event publishing application and put it in a LockAssignment state. (Unlock csa213SGI0 instead of csa113SGI0 to run csa213).&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
cli[Test:SCNodeI0:CPM]-&amp;gt; amsLockAssignment sg csa113SGI0&lt;br /&gt;
cli[Test:SCNodeI0:CPM]-&amp;gt; amsUnlock sg csa113SGI0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Putting csa113 into a LockAssignment state caused it to begin publishing events. Using &amp;lt;code&amp;gt;tail -f /root/asp/var/log/csa113CompI0Log.latest&amp;lt;/code&amp;gt; on the csa113 application log you can see the events being published.(Unlock csa213SGI0 instead of csa113SGI0 to run SAF version).&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffffaa;&amp;quot; align=&amp;quot;center&amp;quot;| $ /root/asp/var/log/csa113CompI0Log.latest &lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
Mon Jul 14 22:53:54 2008   (SCNodeI0.24890 : csa113CompEO.---.---.00028 :   INFO)&lt;br /&gt;
 Component [csa113CompI0] : PID [24890]. Initializing&lt;br /&gt;
Mon Jul 14 22:53:54 2008   (SCNodeI0.24890 : csa113CompEO.---.---.00029 :   INFO)&lt;br /&gt;
    IOC Address             : 0x1&lt;br /&gt;
Mon Jul 14 22:53:54 2008   (SCNodeI0.24890 : csa113CompEO.---.---.00030 :   INFO)&lt;br /&gt;
    IOC Port                : 0x81&lt;br /&gt;
Mon Jul 14 22:53:54 2008   (SCNodeI0.24890 : csa113CompEO.---.---.00037 :   INFO)&lt;br /&gt;
 Instantiated as component instance csa113CompI0.&lt;br /&gt;
Mon Jul 14 22:53:54 2008   (SCNodeI0.24890 : csa113CompEO.---.---.00038 :   INFO)&lt;br /&gt;
 csa113CompI0: Waiting for CSI assignment...&lt;br /&gt;
Mon Jul 14 22:53:59 2008   (SCNodeI0.24890 : csa113CompEO.---.---.00041 :   INFO)&lt;br /&gt;
 Component [csa113CompI0] : PID [24890]. CSI Set Received&lt;br /&gt;
Mon Jul 14 22:53:59 2008   (SCNodeI0.24890 : csa113CompEO.---.---.00042 :   INFO)&lt;br /&gt;
    CSI Flags               : [Add One]&lt;br /&gt;
Mon Jul 14 22:53:59 2008   (SCNodeI0.24890 : csa113CompEO.---.---.00043 :   INFO)&lt;br /&gt;
    CSI Name                : [csa113CSII0]&lt;br /&gt;
Mon Jul 14 22:53:59 2008   (SCNodeI0.24890 : csa113CompEO.---.---.00044 :   INFO)&lt;br /&gt;
    Name Value Pairs        :&lt;br /&gt;
Mon Jul 14 22:53:59 2008   (SCNodeI0.24890 : csa113CompEO.---.---.00045 :   INFO)&lt;br /&gt;
    HA State                : [Active]&lt;br /&gt;
Mon Jul 14 22:53:59 2008   (SCNodeI0.24890 : csa113CompEO.---.---.00046 :   INFO)&lt;br /&gt;
    Active Descriptor       :&lt;br /&gt;
Mon Jul 14 22:53:59 2008   (SCNodeI0.24890 : csa113CompEO.---.---.00047 :   INFO)&lt;br /&gt;
      Transition Descriptor : [1]&lt;br /&gt;
Mon Jul 14 22:53:59 2008   (SCNodeI0.24890 : csa113CompEO.---.---.00048 :   INFO)&lt;br /&gt;
        Active Component    : [csa113CompI0]&lt;br /&gt;
Mon Jul 14 22:53:59 2008   (SCNodeI0.24890 : csa113CompEO.---.---.00049 :   INFO)&lt;br /&gt;
 csa113: ACTIVE state requested; activating service&lt;br /&gt;
Mon Jul 14 22:53:59 2008   (SCNodeI0.24890 : csa113CompEO.---.---.00050 : NOTICE)&lt;br /&gt;
 Publishing Event: Mon Jul 14 22:53:59 2008&lt;br /&gt;
Mon Jul 14 22:54:00 2008   (SCNodeI0.24890 : csa113CompEO.---.---.00052 : NOTICE)&lt;br /&gt;
 Publishing Event: 0.05 0.07 0.03&lt;br /&gt;
Mon Jul 14 22:54:01 2008   (SCNodeI0.24890 : csa113CompEO.---.---.00054 : NOTICE)&lt;br /&gt;
 Publishing Event: Mon Jul 14 22:54:01 2008&lt;br /&gt;
Mon Jul 14 22:54:02 2008   (SCNodeI0.24890 : csa113CompEO.---.---.00056 : NOTICE)&lt;br /&gt;
 Publishing Event: 0.05 0.07 0.03&lt;br /&gt;
Mon Jul 14 22:54:03 2008   (SCNodeI0.24890 : csa113CompEO.---.---.00058 : NOTICE)&lt;br /&gt;
 Publishing Event: Mon Jul 14 22:54:03 2008&lt;br /&gt;
Mon Jul 14 22:54:04 2008   (SCNodeI0.24890 : csa113CompEO.---.---.00060 : NOTICE)&lt;br /&gt;
 Publishing Event: 0.05 0.07 0.03&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
Since the event subscriber application is also running you can see the events that it is receiving in the csa112 application log file. Again using &amp;lt;code&amp;gt;tail -f /rootasp//var/log/csa112CompI0Log.latest&amp;lt;/code&amp;gt; you can see the following:&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffffaa;&amp;quot; align=&amp;quot;center&amp;quot;| /root/asp/var/log/csa112CompI0Log.latest&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
Mon Jul 14 22:53:59 2008   (SCNodeI0.24830 : csa112CompEO.---.---.00052 : NOTICE)&lt;br /&gt;
 We've got an event to receive&lt;br /&gt;
Mon Jul 14 22:53:59 2008   (SCNodeI0.24830 : csa112CompEO.---.---.00054 : NOTICE)&lt;br /&gt;
 received event: Mon Jul 14 22:53:59 2008&lt;br /&gt;
Mon Jul 14 22:54:00 2008   (SCNodeI0.24830 : csa112CompEO.---.---.00058 : NOTICE)&lt;br /&gt;
 We've got an event to receive&lt;br /&gt;
Mon Jul 14 22:54:00 2008   (SCNodeI0.24830 : csa112CompEO.---.---.00060 : NOTICE)&lt;br /&gt;
 received event: 0.05 0.07 0.03&lt;br /&gt;
Mon Jul 14 22:54:01 2008   (SCNodeI0.24830 : csa112CompEO.---.---.00064 : NOTICE)&lt;br /&gt;
 We've got an event to receive&lt;br /&gt;
Mon Jul 14 22:54:01 2008   (SCNodeI0.24830 : csa112CompEO.---.---.00066 : NOTICE)&lt;br /&gt;
 received event: Mon Jul 14 22:54:01 2008&lt;br /&gt;
Mon Jul 14 22:54:02 2008   (SCNodeI0.24830 : csa112CompEO.---.---.00070 : NOTICE)&lt;br /&gt;
 We've got an event to receive&lt;br /&gt;
Mon Jul 14 22:54:02 2008   (SCNodeI0.24830 : csa112CompEO.---.---.00072 : NOTICE)&lt;br /&gt;
 received event: 0.05 0.07 0.03&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;Now you can shut everything down in the usual manner. Note that you will be shutting down two service groups.&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
cli[Test:SCNodeI0:CPM]-&amp;gt; amsLockAssignment sg csa113SGI0&lt;br /&gt;
cli[Test:SCNodeI0:CPM]-&amp;gt; amsLockAssignment sg csa112SGI0&lt;br /&gt;
cli[Test:SCNodeI0:CPM]-&amp;gt; amsLockInstantiation sg csa113SGI0&lt;br /&gt;
cli[Test:SCNodeI0:CPM]-&amp;gt; amsLockInstantiation sg csa112SGI0&lt;br /&gt;
cli[Test:SCNodeI0:CPM]-&amp;gt; end&lt;br /&gt;
cli[Test:SCNodeI0]-&amp;gt; end&lt;br /&gt;
cli[Test]-&amp;gt; bye&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Summary and References===&lt;br /&gt;
&lt;br /&gt;
We've seen how to initialize the event manager subsystem as an event publisher.  We've seen:&lt;br /&gt;
*events flow from the event publisher to the subscriber.  &lt;br /&gt;
*how to format events and send them through the event manager subsystem&lt;br /&gt;
*For further reading, check the same sources as listed under the csa112 section.&lt;/div&gt;</summary>
		<author><name>Madhu</name></author>	</entry>

	<entry>
		<id>https://help.openclovis.com/index.php/Doc:latest/evalguide/csa213</id>
		<title>Doc:latest/evalguide/csa213</title>
		<link rel="alternate" type="text/html" href="https://help.openclovis.com/index.php/Doc:latest/evalguide/csa213"/>
				<updated>2010-10-13T07:29:59Z</updated>
		
		<summary type="html">&lt;p&gt;Madhu: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==csa113 Event Publication==&lt;br /&gt;
&lt;br /&gt;
===Objective===&lt;br /&gt;
&lt;br /&gt;
The objective is to learn how to write an event publishing application using Clovis' Event Manager API.&lt;br /&gt;
&lt;br /&gt;
===What You Will Learn===&lt;br /&gt;
&lt;br /&gt;
*You will learn how to publish events using Clovis' Event Manager API.&lt;br /&gt;
&lt;br /&gt;
===Code===&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffccaa;&amp;quot; align=&amp;quot;center&amp;quot;| clCompAppMain.c&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
    ClRcT&lt;br /&gt;
    clCompAppInitialize(&lt;br /&gt;
        ClUint32T argc,&lt;br /&gt;
        ClCharT *argv[])&lt;br /&gt;
    {&lt;br /&gt;
        ClNameT             appName;&lt;br /&gt;
        ClCpmCallbacksT     callbacks;&lt;br /&gt;
        ClVersionT          version;&lt;br /&gt;
        ClIocPortT          iocPort;&lt;br /&gt;
        ClRcT               rc = CL_OK;&lt;br /&gt;
&lt;br /&gt;
        /*&lt;br /&gt;
         * ---BEGIN_APPLICATION_CODE---&lt;br /&gt;
         */&lt;br /&gt;
        ClVersionT          evtVersion = CL_EVENT_VERSION;&lt;br /&gt;
        ClEventCallbacksT   evtCallbacks = { NULL, NULL };&lt;br /&gt;
&lt;br /&gt;
        /*&lt;br /&gt;
         * ---END_APPLICATION_CODE---&lt;br /&gt;
         */&lt;br /&gt;
        ...&lt;br /&gt;
&lt;br /&gt;
        if ( (rc = clCpmClientInitialize(&amp;amp;cpmHandle, &amp;amp;callbacks, &amp;amp;version)) ) &lt;br /&gt;
            goto errorexit;&lt;br /&gt;
&lt;br /&gt;
        ....&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
In the &amp;lt;code&amp;gt;clCompAppInitialize&amp;lt;/code&amp;gt; function of this example we again see a call to &amp;lt;code&amp;gt;clEventInitialize&amp;lt;/code&amp;gt;.  Most everything else in the appInitialize function is the same as before in csa112, except that both callback function pointers are specified as &amp;lt;code&amp;gt;NULL&amp;lt;/code&amp;gt;.  This is because we neither open the event channel asynchronously, or subscribe to any events in this application. So there is no need to specify a callback to receive an event.&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffccaa;&amp;quot; align=&amp;quot;center&amp;quot;| clCompAppMain.c&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
    ClRcT&lt;br /&gt;
    clCompAppInitialize(&lt;br /&gt;
        ClUint32T argc,&lt;br /&gt;
        ClCharT *argv[])&lt;br /&gt;
    {&lt;br /&gt;
&lt;br /&gt;
        ...&lt;br /&gt;
&lt;br /&gt;
        // Open an event chanel so that we can subscribe to events on that channel&lt;br /&gt;
        rc = clEventChannelOpen(evtHandle,&lt;br /&gt;
                &amp;amp;evtChannelName,&lt;br /&gt;
                (CL_EVENT_CHANNEL_PUBLISHER |&lt;br /&gt;
                 CL_EVENT_GLOBAL_CHANNEL |&lt;br /&gt;
                 CL_EVENT_CHANNEL_CREATE),&lt;br /&gt;
                (ClTimeT)CL_RMD_TIMEOUT_FOREVER,&lt;br /&gt;
                &amp;amp;evtChannelHandle);&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
Here we open the event channel.  This is the same as in csa112 except that rather than opening as a SUBSCRIBER, we open as a &amp;lt;code&amp;gt;PUBLISHER&amp;lt;/code&amp;gt; (by specifying &amp;lt;code&amp;gt;CL_EVENT_CHANNEL_PUBLISHER&amp;lt;/code&amp;gt; flag)&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffccaa;&amp;quot; align=&amp;quot;center&amp;quot;| clCompAppMain.c&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
    ClRcT&lt;br /&gt;
    clCompAppInitialize(&lt;br /&gt;
        ClUint32T argc,&lt;br /&gt;
        ClCharT *argv[])&lt;br /&gt;
    {&lt;br /&gt;
&lt;br /&gt;
        ...&lt;br /&gt;
&lt;br /&gt;
        rc = clEventAllocate(evtChannelHandle, &amp;amp;eventHandle);&lt;br /&gt;
        if (rc != CL_OK)&lt;br /&gt;
        {&lt;br /&gt;
            clprintf(CL_LOG_SEV_ERROR, &amp;quot;Failed to allocate event [0x%x]&amp;quot;,&lt;br /&gt;
                    rc);&lt;br /&gt;
            return rc;&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        rc = clEventExtAttributesSet(eventHandle,&lt;br /&gt;
                EVENT_TYPE,&lt;br /&gt;
                1,&lt;br /&gt;
                0,&lt;br /&gt;
                &amp;amp;publisherName);&lt;br /&gt;
        if (rc != CL_OK)&lt;br /&gt;
        {&lt;br /&gt;
            clprintf(CL_LOG_SEV_ERROR, &amp;quot;Failed to set event attributes [0x%x]&amp;quot;,&lt;br /&gt;
                    rc);&lt;br /&gt;
            return rc;&lt;br /&gt;
        }&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
The call to &amp;lt;code&amp;gt;clEventAllocate&amp;lt;/code&amp;gt; allocates an event header.  This header is identified by the event handle passed back to &amp;lt;code&amp;gt;gTestInfo.eventHandle&amp;lt;/code&amp;gt;.  The handle should be used any time the event header is to be used to manipulate the header, either by using &amp;lt;code&amp;gt;clEventExtAttributesSet&amp;lt;/code&amp;gt; (right below), or to send an event using the header as in &amp;lt;code&amp;gt;clEventPublish&amp;lt;/code&amp;gt;.  The call to &amp;lt;code&amp;gt;clEventExtAttributesSet&amp;lt;/code&amp;gt; defines the &amp;lt;code&amp;gt;EVENT_TYPE&amp;lt;/code&amp;gt; which is defined as 5432 in &amp;lt;code&amp;gt;common/common.h&amp;lt;/code&amp;gt; and is used in the event subscriber.  It also defines the priority to be 1 which is just below the highest priority of &amp;lt;code&amp;gt;CL_EVENT_HIGHEST_PRIORITY&amp;lt;/code&amp;gt; which is defined as 0 where &amp;lt;code&amp;gt;CL_EVENT_LOWEST_PRIORITY&amp;lt;/code&amp;gt; is defined as 3.  The retention time is specified as 0 since we don't want the event to be kept around if there is no subscriber to pick it up.  Finally the &amp;lt;code&amp;gt;publisherName&amp;lt;/code&amp;gt; is specified because it's required.  Our subscriber doesn't care who publishes the events it receives.&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffccaa;&amp;quot; align=&amp;quot;center&amp;quot;| clCompAppMain.c&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
    ClRcT&lt;br /&gt;
    clCompAppInitialize(&lt;br /&gt;
        ClUint32T argc,&lt;br /&gt;
        ClCharT *argv[])&lt;br /&gt;
    {&lt;br /&gt;
&lt;br /&gt;
        ...&lt;br /&gt;
&lt;br /&gt;
        while (!exiting)&lt;br /&gt;
        {&lt;br /&gt;
            if (running &amp;amp;&amp;amp; ha_state == CL_AMS_HA_STATE_ACTIVE)&lt;br /&gt;
            {&lt;br /&gt;
                csa113Comp_PublishEvent();&lt;br /&gt;
            }&lt;br /&gt;
            sleep(1);&lt;br /&gt;
        }&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
Here is the main loop.  As long as the application is running and active we make a call to &amp;lt;code&amp;gt;csa113Comp_PublishEvent&amp;lt;/code&amp;gt;.  The work of the application takes place in &amp;lt;code&amp;gt;csa113Comp_PublishEvent&amp;lt;/code&amp;gt;, which is presented below.&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffccaa;&amp;quot; align=&amp;quot;center&amp;quot;| clCompAppMain.c&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
    static ClRcT&lt;br /&gt;
    csa113Comp_PublishEvent()&lt;br /&gt;
    {&lt;br /&gt;
        ClRcT           rc              = CL_OK;&lt;br /&gt;
        ClEventIdT      eventId         = 0;&lt;br /&gt;
        static int      index           = 0;&lt;br /&gt;
        ClSizeT         data_len        = 0;&lt;br /&gt;
        char            *data           = 0;&lt;br /&gt;
        typedef void (*Generator)(char **, ClSizeT*);&lt;br /&gt;
    &lt;br /&gt;
        //&lt;br /&gt;
        // Note: to add a new generator, just define it above and then include&lt;br /&gt;
        // the new functions name in the generators list.&lt;br /&gt;
        // Next, maybe something that gets disk free info by way of getfsent&lt;br /&gt;
        // and statfs?&lt;br /&gt;
        static Generator generators[]   =&lt;br /&gt;
        { &lt;br /&gt;
            generate_time_of_day,&lt;br /&gt;
            generate_load_average&lt;br /&gt;
        };&lt;br /&gt;
&lt;br /&gt;
        //&lt;br /&gt;
        // every time through increment index and then set index to&lt;br /&gt;
        // it's value modulo the number of entries in the generators&lt;br /&gt;
        // array.  This will cause us to cycle through the list of&lt;br /&gt;
        // generators as we're called to publish events.&lt;br /&gt;
        (*generators[index++])(&amp;amp;data, &amp;amp;data_len);&lt;br /&gt;
        index %= (int)(sizeof generators / sizeof generators[0]);&lt;br /&gt;
        if (data == 0 || data_len == 0)&lt;br /&gt;
        {&lt;br /&gt;
            clprintf(CL_LOG_SEV_ERROR, &amp;quot;no event data generated&amp;quot;);&lt;br /&gt;
            return CL_ERR_NO_MEMORY;&lt;br /&gt;
        }&lt;br /&gt;
        clprintf(CL_LOG_SEV_NOTICE,&amp;quot;Publishing Event: %.*s&amp;quot;, (int)data_len, data);&lt;br /&gt;
        rc = clEventPublish(eventHandle, data, data_len, &amp;amp;eventId);&lt;br /&gt;
        clHeapFree(data);&lt;br /&gt;
&lt;br /&gt;
        return CL_OK;&lt;br /&gt;
    }&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
There's code to call one of a list of generator functions.  The functions on the list, return a pointer and a length which are used to pass to &amp;lt;code&amp;gt;clEventPublish&amp;lt;/code&amp;gt;.  We pass the eventHandle  prepared earlier with &amp;lt;code&amp;gt;clEventAllocate&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;clEventExtAttributesSet&amp;lt;/code&amp;gt;.  Pass the pointer and the length that we get back from the generator function.  Those are used to package up the event data and send it to any subscribers.  We also pass the address of the &amp;lt;code&amp;gt;eventId&amp;lt;/code&amp;gt; local variable.  This is required so that the &amp;lt;code&amp;gt;clEventPublish&amp;lt;/code&amp;gt; function can return the event ID.  We don't need it, so we promptly drop it in the bit bucket.  Finally, we free the data that was allocated in the generator function and passed back as we no longer need it.&lt;br /&gt;
&lt;br /&gt;
===csa213 SA Forum Compliant Event Publication===&lt;br /&gt;
&lt;br /&gt;
This sample application demonstrates the usage of SA Forum Event Service. As mentioned previously, this sample application does not deviate functionally with csa113. The code differences are due to using SA Forum data types (structures) and APIs , as presented in the following two tables. (Note we have not repeated data types and APIs covered previously.)&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|+align=&amp;quot;bottom&amp;quot;| '''SA Forum Data Types with the SAFplus Platform equivalent'''&lt;br /&gt;
|- style=&amp;quot;color:black;background-color:#ffffaa;&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
!SA Forum Data Types   &lt;br /&gt;
!OpenClovis Data Types&lt;br /&gt;
|-&lt;br /&gt;
|SaEvtHandleT&lt;br /&gt;
|ClEventHandleT&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|+align=&amp;quot;bottom&amp;quot;| '''SA Forum APIs with the SAFplus Platform equivalent'''&lt;br /&gt;
|- style=&amp;quot;color:black;background-color:#ffffaa;&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
!SA Forum APIs&lt;br /&gt;
!OpenClovis APIs&lt;br /&gt;
|-&lt;br /&gt;
|SaEvtEventAllocate&lt;br /&gt;
|ClEventAllocate&lt;br /&gt;
|-&lt;br /&gt;
|saEvtEventAttributesSet&lt;br /&gt;
|clEventExtAttributesSet&lt;br /&gt;
|-&lt;br /&gt;
|saEvtEventPublish&lt;br /&gt;
|clEventPublish&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===How to Run csa113 and What to Observe===&lt;br /&gt;
&lt;br /&gt;
In csa113 you will be observing an event publishing application. This will be far more interesting if you observe an event subscription application at the same time. For this we will use the example from csa112.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;First you should start up csa112 and put it in a LockAssignment state so that it can receive events.(Unlock csa212SGI0 instead of csa112SGI0 to run csa213).&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
 # cd /root/asp/bin&lt;br /&gt;
 # ./asp_console&lt;br /&gt;
&lt;br /&gt;
cli[Test]-&amp;gt; setc 1&lt;br /&gt;
cli[Test:SCNodeI0]-&amp;gt; setc cpm&lt;br /&gt;
cli[Test:SCNodeI0:CPM]-&amp;gt; amsLockAssignment sg csa112SGI0&lt;br /&gt;
cli[Test:SCNodeI0:CPM]-&amp;gt; amsUnlock sg csa112SGI0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the csa112 application log you should see:&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffffaa;&amp;quot; align=&amp;quot;center&amp;quot;| $ /root/asp/var/log/csa112CompI0Log.latest &lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
Mon Jul 14 22:50:34 2008   (SCNodeI0.24830 : csa112CompEO.---.---.00037 :   INFO)&lt;br /&gt;
 csa112: Instantiated as component instance csa112CompI0.&lt;br /&gt;
Mon Jul 14 22:50:34 2008   (SCNodeI0.24830 : csa112CompEO.---.---.00038 :   INFO)&lt;br /&gt;
 csa112CompI0: Waiting for CSI assignment...&lt;br /&gt;
Mon Jul 14 22:51:20 2008   (SCNodeI0.24830 : csa112CompEO.---.---.00041 :   INFO)&lt;br /&gt;
 Component [csa112CompI0] : PID [24830]. CSI Set Received&lt;br /&gt;
Mon Jul 14 22:51:20 2008   (SCNodeI0.24830 : csa112CompEO.---.---.00042 :   INFO)&lt;br /&gt;
    CSI Flags               : [Add One]&lt;br /&gt;
Mon Jul 14 22:51:20 2008   (SCNodeI0.24830 : csa112CompEO.---.---.00043 :   INFO)&lt;br /&gt;
    CSI Name                : [csa112CSII0]&lt;br /&gt;
Mon Jul 14 22:51:20 2008   (SCNodeI0.24830 : csa112CompEO.---.---.00044 :   INFO)&lt;br /&gt;
    Name Value Pairs        :&lt;br /&gt;
Mon Jul 14 22:51:20 2008   (SCNodeI0.24830 : csa112CompEO.---.---.00045 :   INFO)&lt;br /&gt;
    HA State                : [Active]&lt;br /&gt;
Mon Jul 14 22:51:20 2008   (SCNodeI0.24830 : csa112CompEO.---.---.00046 :   INFO)&lt;br /&gt;
    Active Descriptor       :&lt;br /&gt;
Mon Jul 14 22:51:20 2008   (SCNodeI0.24830 : csa112CompEO.---.---.00047 :   INFO)&lt;br /&gt;
      Transition Descriptor : [1]&lt;br /&gt;
Mon Jul 14 22:51:20 2008   (SCNodeI0.24830 : csa112CompEO.---.---.00048 :   INFO)&lt;br /&gt;
        Active Component    : [csa112CompI0]&lt;br /&gt;
Mon Jul 14 22:51:20 2008   (SCNodeI0.24830 : csa112CompEO.---.---.00049 :   INFO)&lt;br /&gt;
 csa112: ACTIVE state requested; activating service&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
[[File:OpenClovis_Note.png]]When running model csa212 you will not see the output described above for the the amsLockAssignment and amsUnlock commands. Unlock csa212SGI0 instead of csa112SGI0.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;Now you can start up the event publishing application and put it in a LockAssignment state. (Unlock csa213SGI0 instead of csa113SGI0 to run csa213).&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
cli[Test:SCNodeI0:CPM]-&amp;gt; amsLockAssignment sg csa113SGI0&lt;br /&gt;
cli[Test:SCNodeI0:CPM]-&amp;gt; amsUnlock sg csa113SGI0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Putting csa113 into a LockAssignment state caused it to begin publishing events. Using &amp;lt;code&amp;gt;tail -f /root/asp/var/log/csa113CompI0Log.latest&amp;lt;/code&amp;gt; on the csa113 application log you can see the events being published.(Unlock csa213SGI0 instead of csa113SGI0 to run SAF version).&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffffaa;&amp;quot; align=&amp;quot;center&amp;quot;| $ /root/asp/var/log/csa113CompI0Log.latest &lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
Mon Jul 14 22:53:54 2008   (SCNodeI0.24890 : csa113CompEO.---.---.00028 :   INFO)&lt;br /&gt;
 Component [csa113CompI0] : PID [24890]. Initializing&lt;br /&gt;
Mon Jul 14 22:53:54 2008   (SCNodeI0.24890 : csa113CompEO.---.---.00029 :   INFO)&lt;br /&gt;
    IOC Address             : 0x1&lt;br /&gt;
Mon Jul 14 22:53:54 2008   (SCNodeI0.24890 : csa113CompEO.---.---.00030 :   INFO)&lt;br /&gt;
    IOC Port                : 0x81&lt;br /&gt;
Mon Jul 14 22:53:54 2008   (SCNodeI0.24890 : csa113CompEO.---.---.00037 :   INFO)&lt;br /&gt;
 Instantiated as component instance csa113CompI0.&lt;br /&gt;
Mon Jul 14 22:53:54 2008   (SCNodeI0.24890 : csa113CompEO.---.---.00038 :   INFO)&lt;br /&gt;
 csa113CompI0: Waiting for CSI assignment...&lt;br /&gt;
Mon Jul 14 22:53:59 2008   (SCNodeI0.24890 : csa113CompEO.---.---.00041 :   INFO)&lt;br /&gt;
 Component [csa113CompI0] : PID [24890]. CSI Set Received&lt;br /&gt;
Mon Jul 14 22:53:59 2008   (SCNodeI0.24890 : csa113CompEO.---.---.00042 :   INFO)&lt;br /&gt;
    CSI Flags               : [Add One]&lt;br /&gt;
Mon Jul 14 22:53:59 2008   (SCNodeI0.24890 : csa113CompEO.---.---.00043 :   INFO)&lt;br /&gt;
    CSI Name                : [csa113CSII0]&lt;br /&gt;
Mon Jul 14 22:53:59 2008   (SCNodeI0.24890 : csa113CompEO.---.---.00044 :   INFO)&lt;br /&gt;
    Name Value Pairs        :&lt;br /&gt;
Mon Jul 14 22:53:59 2008   (SCNodeI0.24890 : csa113CompEO.---.---.00045 :   INFO)&lt;br /&gt;
    HA State                : [Active]&lt;br /&gt;
Mon Jul 14 22:53:59 2008   (SCNodeI0.24890 : csa113CompEO.---.---.00046 :   INFO)&lt;br /&gt;
    Active Descriptor       :&lt;br /&gt;
Mon Jul 14 22:53:59 2008   (SCNodeI0.24890 : csa113CompEO.---.---.00047 :   INFO)&lt;br /&gt;
      Transition Descriptor : [1]&lt;br /&gt;
Mon Jul 14 22:53:59 2008   (SCNodeI0.24890 : csa113CompEO.---.---.00048 :   INFO)&lt;br /&gt;
        Active Component    : [csa113CompI0]&lt;br /&gt;
Mon Jul 14 22:53:59 2008   (SCNodeI0.24890 : csa113CompEO.---.---.00049 :   INFO)&lt;br /&gt;
 csa113: ACTIVE state requested; activating service&lt;br /&gt;
Mon Jul 14 22:53:59 2008   (SCNodeI0.24890 : csa113CompEO.---.---.00050 : NOTICE)&lt;br /&gt;
 Publishing Event: Mon Jul 14 22:53:59 2008&lt;br /&gt;
Mon Jul 14 22:54:00 2008   (SCNodeI0.24890 : csa113CompEO.---.---.00052 : NOTICE)&lt;br /&gt;
 Publishing Event: 0.05 0.07 0.03&lt;br /&gt;
Mon Jul 14 22:54:01 2008   (SCNodeI0.24890 : csa113CompEO.---.---.00054 : NOTICE)&lt;br /&gt;
 Publishing Event: Mon Jul 14 22:54:01 2008&lt;br /&gt;
Mon Jul 14 22:54:02 2008   (SCNodeI0.24890 : csa113CompEO.---.---.00056 : NOTICE)&lt;br /&gt;
 Publishing Event: 0.05 0.07 0.03&lt;br /&gt;
Mon Jul 14 22:54:03 2008   (SCNodeI0.24890 : csa113CompEO.---.---.00058 : NOTICE)&lt;br /&gt;
 Publishing Event: Mon Jul 14 22:54:03 2008&lt;br /&gt;
Mon Jul 14 22:54:04 2008   (SCNodeI0.24890 : csa113CompEO.---.---.00060 : NOTICE)&lt;br /&gt;
 Publishing Event: 0.05 0.07 0.03&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
Since the event subscriber application is also running you can see the events that it is receiving in the csa112 application log file. Again using &amp;lt;code&amp;gt;tail -f /rootasp//var/log/csa112CompI0Log.latest&amp;lt;/code&amp;gt; you can see the following:&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffffaa;&amp;quot; align=&amp;quot;center&amp;quot;| /root/asp/var/log/csa112CompI0Log.latest&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
Mon Jul 14 22:53:59 2008   (SCNodeI0.24830 : csa112CompEO.---.---.00052 : NOTICE)&lt;br /&gt;
 We've got an event to receive&lt;br /&gt;
Mon Jul 14 22:53:59 2008   (SCNodeI0.24830 : csa112CompEO.---.---.00054 : NOTICE)&lt;br /&gt;
 received event: Mon Jul 14 22:53:59 2008&lt;br /&gt;
Mon Jul 14 22:54:00 2008   (SCNodeI0.24830 : csa112CompEO.---.---.00058 : NOTICE)&lt;br /&gt;
 We've got an event to receive&lt;br /&gt;
Mon Jul 14 22:54:00 2008   (SCNodeI0.24830 : csa112CompEO.---.---.00060 : NOTICE)&lt;br /&gt;
 received event: 0.05 0.07 0.03&lt;br /&gt;
Mon Jul 14 22:54:01 2008   (SCNodeI0.24830 : csa112CompEO.---.---.00064 : NOTICE)&lt;br /&gt;
 We've got an event to receive&lt;br /&gt;
Mon Jul 14 22:54:01 2008   (SCNodeI0.24830 : csa112CompEO.---.---.00066 : NOTICE)&lt;br /&gt;
 received event: Mon Jul 14 22:54:01 2008&lt;br /&gt;
Mon Jul 14 22:54:02 2008   (SCNodeI0.24830 : csa112CompEO.---.---.00070 : NOTICE)&lt;br /&gt;
 We've got an event to receive&lt;br /&gt;
Mon Jul 14 22:54:02 2008   (SCNodeI0.24830 : csa112CompEO.---.---.00072 : NOTICE)&lt;br /&gt;
 received event: 0.05 0.07 0.03&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;Now you can shut everything down in the usual manner. Note that you will be shutting down two service groups.&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
cli[Test:SCNodeI0:CPM]-&amp;gt; amsLockAssignment sg csa113SGI0&lt;br /&gt;
cli[Test:SCNodeI0:CPM]-&amp;gt; amsLockAssignment sg csa112SGI0&lt;br /&gt;
cli[Test:SCNodeI0:CPM]-&amp;gt; amsLockInstantiation sg csa113SGI0&lt;br /&gt;
cli[Test:SCNodeI0:CPM]-&amp;gt; amsLockInstantiation sg csa112SGI0&lt;br /&gt;
cli[Test:SCNodeI0:CPM]-&amp;gt; end&lt;br /&gt;
cli[Test:SCNodeI0]-&amp;gt; end&lt;br /&gt;
cli[Test]-&amp;gt; bye&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Summary and References===&lt;br /&gt;
&lt;br /&gt;
We've seen how to initialize the event manager subsystem as an event publisher.  We've seen:&lt;br /&gt;
*events flow from the event publisher to the subscriber.  &lt;br /&gt;
*how to format events and send them through the event manager subsystem&lt;br /&gt;
*For further reading, check the same sources as listed under the csa112 section.&lt;/div&gt;</summary>
		<author><name>Madhu</name></author>	</entry>

	<entry>
		<id>https://help.openclovis.com/index.php/Doc:latest/evalguide</id>
		<title>Doc:latest/evalguide</title>
		<link rel="alternate" type="text/html" href="https://help.openclovis.com/index.php/Doc:latest/evalguide"/>
				<updated>2010-10-13T07:28:47Z</updated>
		
		<summary type="html">&lt;p&gt;Madhu: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Table of contents:&lt;br /&gt;
* [[Doc:latest/evalguide/preface | Preface ]]&lt;br /&gt;
* [[Doc:latest/evalguide/scope | Objectives and Scope ]]&lt;br /&gt;
* [[Doc:latest/evalguide/prerequisites | Hardware and Software Prerequisites]]&lt;br /&gt;
* [[Doc:latest/evalguide/setup | Runtime Hardware Setup ]]&lt;br /&gt;
* [[Doc:latest/evalguide/build | Building the Evaluation System and Deploying Runtime Images]]&lt;br /&gt;
* [[Doc:latest/evalguide/csa |Sample Applications]]&lt;br /&gt;
&amp;lt;!--**[[Doc:latest/evalguide/csa101 | csa101&amp;lt;sub&amp;gt;csa201&amp;lt;/sub&amp;gt; Component Management]]--&amp;gt;&lt;br /&gt;
**[[Doc:latest/evalguide/csa102 | csa102 Redundancy and Failover]]&lt;br /&gt;
**[[Doc:latest/evalguide/csa103 | csa103&amp;lt;sub&amp;gt;csa203&amp;lt;/sub&amp;gt; Checkpointing]]&lt;br /&gt;
**[[Doc:latest/evalguide/csa104 | csa104 Provisioning]]&lt;br /&gt;
**[[Doc:latest/evalguide/csa105 | csa105 Software Alarm Management and Provisioning]]&lt;br /&gt;
&amp;lt;!--**[[Doc:latest/evalguide/csa106 | csa106 HAL/DO (hardware provisioning with Ethernet port)]]--&amp;gt;&lt;br /&gt;
&amp;lt;!--**[[Doc:latest/evalguide/csa111 | csa111 Hello World with logging]]--&amp;gt;&lt;br /&gt;
**[[Doc:latest/evalguide/csa212 | csa212 Event Subscription]]&lt;br /&gt;
**[[Doc:latest/evalguide/csa113 | csa113&amp;lt;sub&amp;gt;csa213&amp;lt;/sub&amp;gt; Event Publication]]&lt;br /&gt;
**[[Doc:latest/evalguide/csa213 | csa213 Event Publication]]&lt;br /&gt;
&amp;lt;!--**[[Doc:latest/evalguide/csa114 | csa114 IOC &amp;amp; RMD]]--&amp;gt;&lt;br /&gt;
&amp;lt;!--**[[Doc:latest/evalguide/csa115 | csa115 Name Service]]--&amp;gt;&lt;br /&gt;
&amp;lt;!--**[[Doc:latest/evalguide/csa501 | csa501 Logical Addressing and RMD calls]]--&amp;gt;&lt;br /&gt;
**[[Doc:latest/evalguide/dhaDemo | Dynamic HA application]]&lt;br /&gt;
**[[Doc:latest/evalguide/csasum | Summary and Next Steps]]&lt;br /&gt;
* [[Doc:latest/evalguide/app_ide | Appendix: OpenClovis IDE ]]&lt;/div&gt;</summary>
		<author><name>Madhu</name></author>	</entry>

	<entry>
		<id>https://help.openclovis.com/index.php/Doc:latest/evalguide/csa212</id>
		<title>Doc:latest/evalguide/csa212</title>
		<link rel="alternate" type="text/html" href="https://help.openclovis.com/index.php/Doc:latest/evalguide/csa212"/>
				<updated>2010-10-01T09:51:42Z</updated>
		
		<summary type="html">&lt;p&gt;Madhu: /* Code */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==csa212 Event Subscription==&lt;br /&gt;
&lt;br /&gt;
===Objective===&lt;br /&gt;
&lt;br /&gt;
The objective of csa212 is to learn how to use Clovis' event service to subscribe to events and to extract the relevant information from the events received by subscription.&lt;br /&gt;
&lt;br /&gt;
===What you will learn===&lt;br /&gt;
&lt;br /&gt;
You will learn &lt;br /&gt;
*how to initialize the event library&lt;br /&gt;
*how to subscribe to events&lt;br /&gt;
*how to receive events&lt;br /&gt;
*how to extract the event data&lt;br /&gt;
&lt;br /&gt;
===Code===&lt;br /&gt;
&lt;br /&gt;
One difference to note between this application and previous ones is that this application will not have a main loop in &amp;lt;code&amp;gt;clCompAppInitialize&amp;lt;/code&amp;gt;.  Instead we will do our work in callback code.  This means that when we return from &amp;lt;code&amp;gt;clCompAppInitialize&amp;lt;/code&amp;gt; we won't exit the application.&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffccaa;&amp;quot; align=&amp;quot;center&amp;quot;| clCompAppMain.c&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
    SaNameT    evtChannelName = {&lt;br /&gt;
                    sizeof EVENT_CHANNEL_NAME - 1,&lt;br /&gt;
                    EVENT_CHANNEL_NAME&lt;br /&gt;
           };&lt;br /&gt;
&lt;br /&gt;
    SaEvtChannelHandleT    evtChannelHandle = 0;&lt;br /&gt;
    SaEvtHandleT      evtHandle = CL_HANDLE_INVALID_VALUE;&lt;br /&gt;
&lt;br /&gt;
    static void&lt;br /&gt;
    csa212Comp_appEventCallback( SaEvtSubscriptionIdT subscriptionId,&lt;br /&gt;
                                          SaEvtEventHandleT eventHandle,&lt;br /&gt;
                                          SaSizeT eventDataSize);&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
Here we define variables to hold the payload of our event. Note the initialization of the &amp;lt;code&amp;gt;evtChannelName&amp;lt;/code&amp;gt;.  The length is set to the length of the &amp;lt;code&amp;gt;EVENT_CHANNEL_NAME&amp;lt;/code&amp;gt; string WITHOUT including the &amp;lt;code&amp;gt;null&amp;lt;/code&amp;gt; terminator.&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffccaa;&amp;quot; align=&amp;quot;center&amp;quot;| clCompAppMain.c&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
    int&lt;br /&gt;
    main(int argc, char *argv[])&lt;br /&gt;
    {&lt;br /&gt;
        ....&lt;br /&gt;
&lt;br /&gt;
        const SaEvtCallbacksT   evtCallbacks = {&lt;br /&gt;
                           NULL,&lt;br /&gt;
                           csa212Comp_appEventCallback&lt;br /&gt;
                        };&lt;br /&gt;
&lt;br /&gt;
        ...&lt;br /&gt;
&lt;br /&gt;
        // publish our event callbacks&lt;br /&gt;
        rc = saEvtInitialize(&amp;amp;evtHandle, &amp;amp;evtCallbacks, &amp;amp;evtVersion);&lt;br /&gt;
&lt;br /&gt;
        ...&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
We initialize the OpenClovis Event Manager with &amp;lt;code&amp;gt;saEventInitialize&amp;lt;/code&amp;gt;.  We pass the address of the variable where we want the event handle stored.  We pass the address of our event callback functions structure.  Note that the only event callback function that we specify is &amp;lt;code&amp;gt;csa212Comp_appEventCallback&amp;lt;/code&amp;gt;.  We do not specify the other callback which is the Asynchronous channel open callback.  We specify &amp;lt;code&amp;gt;NULL&amp;lt;/code&amp;gt; for that field of &amp;lt;code&amp;gt;evtCallbacks&amp;lt;/code&amp;gt; because we don't open our event channel asynchronously.:&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffccaa;&amp;quot; align=&amp;quot;center&amp;quot;| clCompAppMain.c&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
    int&lt;br /&gt;
    main(int argc, char *argv[])&lt;br /&gt;
    {&lt;br /&gt;
&lt;br /&gt;
        ....&lt;br /&gt;
&lt;br /&gt;
        // Open an event chanel so that we can subscribe to events on that channel&lt;br /&gt;
        rc = saEvtChannelOpen(evtHandle,&lt;br /&gt;
                &amp;amp;evtChannelName,&lt;br /&gt;
                (SA_EVT_CHANNEL_SUBSCRIBER |&lt;br /&gt;
                 SA_EVENT_CHANNEL_CREATE),&lt;br /&gt;
                (SaTimeT)SA_TIME_END,&lt;br /&gt;
                &amp;amp;evtChannelHandle);&lt;br /&gt;
        if (rc != SA_AIS_OK)&lt;br /&gt;
        {   &lt;br /&gt;
            clprintf(CL_LOG_SEV_ERROR, &amp;quot;%s\t:Failure opening event channel[0x%x] at %ld\n&amp;quot;, appname,&lt;br /&gt;
&lt;br /&gt;
            logrc(CL_LOG_ERROR, &amp;quot;%s\t:Failure opening event channel[0x%x]\n&amp;quot;,&lt;br /&gt;
                    appname, rc&lt;br /&gt;
            goto errorexit;&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        rc = saEvtEventSubscribe(evtChannelHandle, NULL, 1);&lt;br /&gt;
        if (rc != SA_AIS_OK)&lt;br /&gt;
        {&lt;br /&gt;
            clprintf(CL_LOG_SEV_ERROR, &amp;quot;%s\t: Failed to subscribe to event channel [0x%x]\n&amp;quot;,&lt;br /&gt;
                    appname, rc);&lt;br /&gt;
            logrc(CL_LOG_ERROR,&lt;br /&gt;
                    &amp;quot;%s\t:Failed to subscribe to event channel [0x%x]\n&amp;quot;,&lt;br /&gt;
                    appname, rc);&lt;br /&gt;
            goto errorexit;&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
Within the above code we open the channel synchronously.  We pass the handle we got back from &amp;lt;code&amp;gt;saEventInitialize&amp;lt;/code&amp;gt;, the channel name we defined previously, flags that indicate this process is subscribing to the channel and it's a global channel, and that the channel should be created if it's not already there, a timeout value of &amp;quot;forever&amp;quot;, and the address of the location where the channel handle should be stored.  Then, we subscribe to a specific event stream on the event channel.  The &amp;lt;code&amp;gt;EVENT_TYPE&amp;lt;/code&amp;gt; constant is defined in &amp;lt;code&amp;gt;common/common.h&amp;lt;/code&amp;gt; as 5432.  This value is used by the event publisher when it sends events.  The constant 1 being passed simply identifies this specific subscription on this channel.  This value will be passed to our event delivery callback function.&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffccaa;&amp;quot; align=&amp;quot;center&amp;quot;| clCompAppMain.c&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
    static void&lt;br /&gt;
    csa212Comp_appEventCallback( SaEvtSubscriptionIdT subscriptionId,&lt;br /&gt;
                                              SaEvtEventHandleT eventHandle,&lt;br /&gt;
                                              SaSizeT eventDataSize)&lt;br /&gt;
    {&lt;br /&gt;
        SaAisErrorT  rc = SA_AIS_OK;&lt;br /&gt;
        static ClPtrT  resTest = NULL;&lt;br /&gt;
        static ClSizeT resSize = 0;&lt;br /&gt;
&lt;br /&gt;
        if (running == 0 || ha_state != SA_AMF_HA_ACTIVE)&lt;br /&gt;
        {&lt;br /&gt;
           return; &lt;br /&gt;
        }&lt;br /&gt;
        clprintf(CL_LOG_SEV_INFO,&amp;quot;We've got an event to receive&amp;quot;);&lt;br /&gt;
        &lt;br /&gt;
        if (resTest != 0)&lt;br /&gt;
        {&lt;br /&gt;
            // Maybe try to save the previously allocated buffer if it's big&lt;br /&gt;
            // enough to hold the new event message.&lt;br /&gt;
            clHeapFree((char *)resTest);&lt;br /&gt;
            resTest = 0;&lt;br /&gt;
            resSize = 0;&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        resTest = clHeapAllocate(eventDataSize + 1);&lt;br /&gt;
        if (resTest == NULL)&lt;br /&gt;
        {&lt;br /&gt;
            logmsg(CL_LOG_ERROR, &amp;quot;%s\tFailed to allocate space for event\n, appname&amp;quot;);&lt;br /&gt;
            return; &lt;br /&gt;
        }&lt;br /&gt;
        *(((char *)resTest) + eventDataSize) = 0;&lt;br /&gt;
        resSize = eventDataSize;&lt;br /&gt;
        rc = saEvtEventDataGet(eventHandle, resTest, &amp;amp;resSize);&lt;br /&gt;
        if (rc != SA_AIS_OK)&lt;br /&gt;
        {&lt;br /&gt;
           logrc(CL_LOG_ERROR, &amp;quot;%s\t:Failed to get event data [0x%x]\n&amp;quot;,&lt;br /&gt;
                    appname, rc);&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        clprintf(CL_LOG_SEV_INFO,&amp;quot;received event: %s\n&amp;quot;, (char *)resTest);&lt;br /&gt;
        return;&lt;br /&gt;
&lt;br /&gt;
    }&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
The event delivery callback function is named &amp;lt;code&amp;gt;csa212Comp_appEventCallback&amp;lt;/code&amp;gt;.  First it checks that the running variable is not zero and that the High Availability State is &amp;lt;code&amp;gt;CL_AMS_HA_STATE_ACTIVE&amp;lt;/code&amp;gt;, otherwise it returns, dropping the event in the bit bucket.  Next it checks whether our incoming data buffer needs to be deallocated.  If there is a buffer, it deallocates it and then allocates enough data to receive the incoming event data.  Then, we extract the data from the event into the newly allocated buffer using &amp;lt;code&amp;gt;saEvtEventDataGet&amp;lt;/code&amp;gt;.  Finally, we print the event data we received using &amp;lt;code&amp;gt;clprintf&amp;lt;/code&amp;gt; which is another member of Clovis' OS Abstraction Layer.  As its name and usage suggest, it is the OSAL replacement for printf.&lt;br /&gt;
&lt;br /&gt;
===csa212 SA Forum Compliant Event Subscription===&lt;br /&gt;
&lt;br /&gt;
csa212 demonstrates the usage of SA Forum's Event Service. This sample application does not deviate functionally from csa112. The differences in code are due to using SA Forum data types (structures) and APIs , as presented in the following two tables. (Note we have not repeated data types and APIs covered previously.)&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|+align=&amp;quot;bottom&amp;quot;| '''SA Forum Data Types with the SAFplus Platform equivalent'''&lt;br /&gt;
|- style=&amp;quot;color:black;background-color:#ffffaa;&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
!SA Forum Data Types   &lt;br /&gt;
!OpenClovis Data Types&lt;br /&gt;
|-&lt;br /&gt;
|SaEvtHandleT&lt;br /&gt;
|ClEventInitHandleT&lt;br /&gt;
|-&lt;br /&gt;
|SaEvtChannelHandleT&lt;br /&gt;
|ClEventChannelHandleT&lt;br /&gt;
|-&lt;br /&gt;
|SaEvtCallbacksT&lt;br /&gt;
|ClEventCallbacksT&lt;br /&gt;
|-&lt;br /&gt;
|SA_EVT_CHANNEL_SUBSCRIBER&lt;br /&gt;
|CL_EVENT_CHANNEL_SUBSCRIBER &lt;br /&gt;
|-&lt;br /&gt;
|SA_EVT_CHANNEL_CREATE&lt;br /&gt;
|CL_EVENT_CHANNEL_CREATE&lt;br /&gt;
|-&lt;br /&gt;
|SA_TIME_END&lt;br /&gt;
|CL_RMD_TIMEOUT_FOREVER &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|+align=&amp;quot;bottom&amp;quot;| '''SA Forum APIs with the SAFplus Platform equivalent'''&lt;br /&gt;
|- style=&amp;quot;color:black;background-color:#ffffaa;&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
!SA Forum APIs&lt;br /&gt;
!OpenClovis APIs&lt;br /&gt;
|-&lt;br /&gt;
|SaEvtInitialize&lt;br /&gt;
|ClEventInitialize&lt;br /&gt;
|-&lt;br /&gt;
|saEvtChannelOpen&lt;br /&gt;
|clEventChannelOpen&lt;br /&gt;
|-&lt;br /&gt;
|saEvtEventSubscribe&lt;br /&gt;
|clEventExtSubscribe&lt;br /&gt;
|-&lt;br /&gt;
|saEvtEventDataGet&lt;br /&gt;
|clEventDataGet&lt;br /&gt;
|-&lt;br /&gt;
|saEvtChannelClose&lt;br /&gt;
|clEventChannelClose&lt;br /&gt;
|-&lt;br /&gt;
|saEvtFinalize&lt;br /&gt;
|clEventFinalize&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===How to Run csa212 and What to Observe===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Start example csa212 in the same manner that we have started previous examples, with the SAFplus Platform Console.(Unlock csa212SGI0 instead of csa112SGI0 to run csa212).&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
 # cd /root/asp/bin&lt;br /&gt;
 # ./asp_console&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
cli[Test]-&amp;gt; setc 1&lt;br /&gt;
cli[Test:SCNodeI0]-&amp;gt; setc cpm&lt;br /&gt;
cli[Test:SCNodeI0:CPM]-&amp;gt; amsLockAssignment sg csa212SGI0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Looking at the log file for this example you should see the following.&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffffaa;&amp;quot; align=&amp;quot;center&amp;quot;| /root/asp/var/log/csa212CompI3Log.latest&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
  Fri Oct  1 13:14:16.935 2010 (PayloadNodeI1.10366 : csa212CompEO.---.---.00001 :   INFO) Component [csa212CompI3] : PID [10366]. Initializing&lt;br /&gt;
&lt;br /&gt;
  Fri Oct  1 13:14:16.935 2010 (PayloadNodeI1.10366 : csa212CompEO.---.---.00002 :   INFO)    IOC Address             : 0x4&lt;br /&gt;
&lt;br /&gt;
  Fri Oct  1 13:14:16.935 2010 (PayloadNodeI1.10366 : csa212CompEO.---.---.00003 :   INFO)    IOC Port                : 0x80&lt;br /&gt;
&lt;br /&gt;
  Fri Oct  1 13:15:31.389 2010 (PayloadNodeI1.10366 : csa212CompEO.---.---.00004 :   INFO) Component [csa212CompI3] : PID [10366]. CSI Set Received&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;Now unlock the application with:&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
cli[Test:SCNodeI0:CPM]-&amp;gt; amsUnlock sg csa212SGI0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At this point you should see the following in the log.&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffffaa;&amp;quot; align=&amp;quot;center&amp;quot;| /root/asp/var/log/csa212CompI3Log.latest&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
 Fri Oct  1 13:15:31.389 2010 (PayloadNodeI1.10366 : csa212CompEO.---.---.00012 :   INFO) csa212: ACTIVE state requested; activating service&lt;br /&gt;
&lt;br /&gt;
  &lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Thats all there is to this example. What you are looking at in the log is the output of our event listener. It doesn't appear very interesting because we have not yet written an event publisher that will give the program something to output. We'll do that in the next example (csa213).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;At this point we can shut down our example in the usual fashion.&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
cli[Test:SCNodeI0:CPM]-&amp;gt; amsLockAssignment sg csa212SGI0&lt;br /&gt;
cli[Test:SCNodeI0:CPM]-&amp;gt; amsLockInstantiation sg csa212SGI0&lt;br /&gt;
cli[Test:SCNodeI0:CPM]-&amp;gt; end&lt;br /&gt;
cli[Test:SCNodeI0]-&amp;gt; end&lt;br /&gt;
cli[Test]-&amp;gt; bye&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
[[File:OpenClovis_Note.png]]When running model csa212 you will not see the output described for the the amsLockAssignment and amsUnlock commands.&lt;br /&gt;
&lt;br /&gt;
===Summary and References===&lt;br /&gt;
&lt;br /&gt;
We've seen how to create a basic event subscriber application using Clovis' event manager library.  For further reading check the Clovis SAFplus Platform API reference guide, specifically the section on the event manager.  Also, the header file: &amp;lt;code&amp;gt;clEventExtApi.h&amp;lt;/code&amp;gt; should be helpful.&lt;/div&gt;</summary>
		<author><name>Madhu</name></author>	</entry>

	<entry>
		<id>https://help.openclovis.com/index.php/Doc:latest/evalguide/csa212</id>
		<title>Doc:latest/evalguide/csa212</title>
		<link rel="alternate" type="text/html" href="https://help.openclovis.com/index.php/Doc:latest/evalguide/csa212"/>
				<updated>2010-10-01T09:40:15Z</updated>
		
		<summary type="html">&lt;p&gt;Madhu: /* Code */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==csa212 Event Subscription==&lt;br /&gt;
&lt;br /&gt;
===Objective===&lt;br /&gt;
&lt;br /&gt;
The objective of csa212 is to learn how to use Clovis' event service to subscribe to events and to extract the relevant information from the events received by subscription.&lt;br /&gt;
&lt;br /&gt;
===What you will learn===&lt;br /&gt;
&lt;br /&gt;
You will learn &lt;br /&gt;
*how to initialize the event library&lt;br /&gt;
*how to subscribe to events&lt;br /&gt;
*how to receive events&lt;br /&gt;
*how to extract the event data&lt;br /&gt;
&lt;br /&gt;
===Code===&lt;br /&gt;
&lt;br /&gt;
One difference to note between this application and previous ones is that this application will not have a main loop in &amp;lt;code&amp;gt;clCompAppInitialize&amp;lt;/code&amp;gt;.  Instead we will do our work in callback code.  This means that when we return from &amp;lt;code&amp;gt;clCompAppInitialize&amp;lt;/code&amp;gt; we won't exit the application.&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffccaa;&amp;quot; align=&amp;quot;center&amp;quot;| clCompAppMain.c&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
    SaNameT    evtChannelName = {&lt;br /&gt;
                    sizeof EVENT_CHANNEL_NAME - 1,&lt;br /&gt;
                    EVENT_CHANNEL_NAME&lt;br /&gt;
           };&lt;br /&gt;
&lt;br /&gt;
    SaEvtChannelHandleT    evtChannelHandle = 0;&lt;br /&gt;
    SaEvtHandleT      evtHandle = CL_HANDLE_INVALID_VALUE;&lt;br /&gt;
&lt;br /&gt;
    static void&lt;br /&gt;
    csa212Comp_appEventCallback( SaEvtSubscriptionIdT subscriptionId,&lt;br /&gt;
                                          SaEvtEventHandleT eventHandle,&lt;br /&gt;
                                          SaSizeT eventDataSize);&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
Here we define variables to hold the payload of our event. Note the initialization of the &amp;lt;code&amp;gt;evtChannelName&amp;lt;/code&amp;gt;.  The length is set to the length of the &amp;lt;code&amp;gt;EVENT_CHANNEL_NAME&amp;lt;/code&amp;gt; string WITHOUT including the &amp;lt;code&amp;gt;null&amp;lt;/code&amp;gt; terminator.&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffccaa;&amp;quot; align=&amp;quot;center&amp;quot;| clCompAppMain.c&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
    int&lt;br /&gt;
    main(int argc, char *argv[])&lt;br /&gt;
    {&lt;br /&gt;
        ....&lt;br /&gt;
&lt;br /&gt;
        const SaEvtCallbacksT   evtCallbacks = {&lt;br /&gt;
                           NULL,&lt;br /&gt;
                           csa212Comp_appEventCallback&lt;br /&gt;
                        };&lt;br /&gt;
&lt;br /&gt;
        ...&lt;br /&gt;
&lt;br /&gt;
        // publish our event callbacks&lt;br /&gt;
        rc = saEvtInitialize(&amp;amp;evtHandle, &amp;amp;evtCallbacks, &amp;amp;evtVersion);&lt;br /&gt;
&lt;br /&gt;
        ...&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
We initialize the OpenClovis Event Manager with &amp;lt;code&amp;gt;saEventInitialize&amp;lt;/code&amp;gt;.  We pass the address of the variable where we want the event handle stored.  We pass the address of our event callback functions structure.  Note that the only event callback function that we specify is &amp;lt;code&amp;gt;csa212Comp_appEventCallback&amp;lt;/code&amp;gt;.  We do not specify the other callback which is the Asynchronous channel open callback.  We specify &amp;lt;code&amp;gt;NULL&amp;lt;/code&amp;gt; for that field of &amp;lt;code&amp;gt;evtCallbacks&amp;lt;/code&amp;gt; because we don't open our event channel asynchronously.:&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffccaa;&amp;quot; align=&amp;quot;center&amp;quot;| clCompAppMain.c&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
    int&lt;br /&gt;
    main(int argc, char *argv[])&lt;br /&gt;
    {&lt;br /&gt;
&lt;br /&gt;
        ....&lt;br /&gt;
&lt;br /&gt;
        // Open an event chanel so that we can subscribe to events on that channel&lt;br /&gt;
        rc = saEvtChannelOpen(evtHandle,&lt;br /&gt;
                &amp;amp;evtChannelName,&lt;br /&gt;
                (SA_EVT_CHANNEL_SUBSCRIBER |&lt;br /&gt;
                 SA_EVENT_CHANNEL_CREATE),&lt;br /&gt;
                (SaTimeT)SA_TIME_END,&lt;br /&gt;
                &amp;amp;evtChannelHandle);&lt;br /&gt;
        if (rc != SA_AIS_OK)&lt;br /&gt;
        {   &lt;br /&gt;
            clprintf(CL_LOG_SEV_ERROR, &amp;quot;%s\t:Failure opening event channel[0x%x] at %ld\n&amp;quot;, appname,&lt;br /&gt;
&lt;br /&gt;
            logrc(CL_LOG_ERROR, &amp;quot;%s\t:Failure opening event channel[0x%x]\n&amp;quot;,&lt;br /&gt;
                    appname, rc&lt;br /&gt;
            goto errorexit;&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        rc = saEvtEventSubscribe(evtChannelHandle, NULL, 1);&lt;br /&gt;
        if (rc != SA_AIS_OK)&lt;br /&gt;
        {&lt;br /&gt;
            clprintf(CL_LOG_SEV_ERROR, &amp;quot;%s\t: Failed to subscribe to event channel [0x%x]\n&amp;quot;,&lt;br /&gt;
                    appname, rc);&lt;br /&gt;
            logrc(CL_LOG_ERROR,&lt;br /&gt;
                    &amp;quot;%s\t:Failed to subscribe to event channel [0x%x]\n&amp;quot;,&lt;br /&gt;
                    appname, rc);&lt;br /&gt;
            goto errorexit;&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
Within the above code we open the channel synchronously.  We pass the handle we got back from &amp;lt;code&amp;gt;saEventInitialize&amp;lt;/code&amp;gt;, the channel name we defined previously, flags that indicate this process is subscribing to the channel and it's a global channel, and that the channel should be created if it's not already there, a timeout value of &amp;quot;forever&amp;quot;, and the address of the location where the channel handle should be stored.  Then, we subscribe to a specific event stream on the event channel.  The &amp;lt;code&amp;gt;EVENT_TYPE&amp;lt;/code&amp;gt; constant is defined in &amp;lt;code&amp;gt;common/common.h&amp;lt;/code&amp;gt; as 5432.  This value is used by the event publisher when it sends events.  The constant 1 being passed simply identifies this specific subscription on this channel.  This value will be passed to our event delivery callback function.&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffccaa;&amp;quot; align=&amp;quot;center&amp;quot;| clCompAppMain.c&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
    static void&lt;br /&gt;
    csa212Comp_appEventCallback( SaEvtSubscriptionIdT subscriptionId,&lt;br /&gt;
                                              SaEvtEventHandleT eventHandle,&lt;br /&gt;
                                              SaSizeT eventDataSize)&lt;br /&gt;
    {&lt;br /&gt;
        SaAisErrorT  rc = SA_AIS_OK;&lt;br /&gt;
        static ClPtrT  resTest = NULL;&lt;br /&gt;
        static ClSizeT resSize;&lt;br /&gt;
&lt;br /&gt;
        if (running == 0 || ha_state != SA_AMF_HA_ACTIVE)&lt;br /&gt;
        {&lt;br /&gt;
           return; &lt;br /&gt;
        }&lt;br /&gt;
        clprintf(CL_LOG_SEV_INFO,&amp;quot;We've got an event to receive&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
        resTest = clHeapAllocate(eventDataSize + 1);&lt;br /&gt;
        if (resTest == NULL)&lt;br /&gt;
        {&lt;br /&gt;
            logmsg(CL_LOG_ERROR, &amp;quot;%s\tFailed to allocate space for event\n, appname&amp;quot;);&lt;br /&gt;
            return; &lt;br /&gt;
        }&lt;br /&gt;
        *(((char *)resTest) + eventDataSize) = 0;&lt;br /&gt;
        resSize = eventDataSize;&lt;br /&gt;
        rc = saEvtEventDataGet(eventHandle, resTest, &amp;amp;resSize);&lt;br /&gt;
        if (rc != SA_AIS_OK)&lt;br /&gt;
        {&lt;br /&gt;
           logrc(CL_LOG_ERROR, &amp;quot;%s\t:Failed to get event data [0x%x]\n&amp;quot;,&lt;br /&gt;
                    appname, rc);&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        clprintf(CL_LOG_SEV_INFO,&amp;quot;received event: %s\n&amp;quot;, (char *)resTest);&lt;br /&gt;
        return;&lt;br /&gt;
&lt;br /&gt;
    }&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
The event delivery callback function is named &amp;lt;code&amp;gt;csa112Comp_appEventCallback&amp;lt;/code&amp;gt;.  First it checks that the running variable is not zero and that the High Availability State is &amp;lt;code&amp;gt;CL_AMS_HA_STATE_ACTIVE&amp;lt;/code&amp;gt;, otherwise it returns, dropping the event in the bit bucket.  Next it checks whether our incoming data buffer needs to be deallocated.  If there is a buffer, it deallocates it and then allocates enough data to receive the incoming event data.  Then, we extract the data from the event into the newly allocated buffer using &amp;lt;code&amp;gt;clEventDataGet&amp;lt;/code&amp;gt;.  Finally, we print the event data we received using &amp;lt;code&amp;gt;clprintf&amp;lt;/code&amp;gt; which is another member of Clovis' OS Abstraction Layer.  As its name and usage suggest, it is the OSAL replacement for printf.&lt;br /&gt;
&lt;br /&gt;
===csa212 SA Forum Compliant Event Subscription===&lt;br /&gt;
&lt;br /&gt;
csa212 demonstrates the usage of SA Forum's Event Service. This sample application does not deviate functionally from csa112. The differences in code are due to using SA Forum data types (structures) and APIs , as presented in the following two tables. (Note we have not repeated data types and APIs covered previously.)&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|+align=&amp;quot;bottom&amp;quot;| '''SA Forum Data Types with the SAFplus Platform equivalent'''&lt;br /&gt;
|- style=&amp;quot;color:black;background-color:#ffffaa;&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
!SA Forum Data Types   &lt;br /&gt;
!OpenClovis Data Types&lt;br /&gt;
|-&lt;br /&gt;
|SaEvtHandleT&lt;br /&gt;
|ClEventInitHandleT&lt;br /&gt;
|-&lt;br /&gt;
|SaEvtChannelHandleT&lt;br /&gt;
|ClEventChannelHandleT&lt;br /&gt;
|-&lt;br /&gt;
|SaEvtCallbacksT&lt;br /&gt;
|ClEventCallbacksT&lt;br /&gt;
|-&lt;br /&gt;
|SA_EVT_CHANNEL_SUBSCRIBER&lt;br /&gt;
|CL_EVENT_CHANNEL_SUBSCRIBER &lt;br /&gt;
|-&lt;br /&gt;
|SA_EVT_CHANNEL_CREATE&lt;br /&gt;
|CL_EVENT_CHANNEL_CREATE&lt;br /&gt;
|-&lt;br /&gt;
|SA_TIME_END&lt;br /&gt;
|CL_RMD_TIMEOUT_FOREVER &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|+align=&amp;quot;bottom&amp;quot;| '''SA Forum APIs with the SAFplus Platform equivalent'''&lt;br /&gt;
|- style=&amp;quot;color:black;background-color:#ffffaa;&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
!SA Forum APIs&lt;br /&gt;
!OpenClovis APIs&lt;br /&gt;
|-&lt;br /&gt;
|SaEvtInitialize&lt;br /&gt;
|ClEventInitialize&lt;br /&gt;
|-&lt;br /&gt;
|saEvtChannelOpen&lt;br /&gt;
|clEventChannelOpen&lt;br /&gt;
|-&lt;br /&gt;
|saEvtEventSubscribe&lt;br /&gt;
|clEventExtSubscribe&lt;br /&gt;
|-&lt;br /&gt;
|saEvtEventDataGet&lt;br /&gt;
|clEventDataGet&lt;br /&gt;
|-&lt;br /&gt;
|saEvtChannelClose&lt;br /&gt;
|clEventChannelClose&lt;br /&gt;
|-&lt;br /&gt;
|saEvtFinalize&lt;br /&gt;
|clEventFinalize&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===How to Run csa212 and What to Observe===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Start example csa212 in the same manner that we have started previous examples, with the SAFplus Platform Console.(Unlock csa212SGI0 instead of csa112SGI0 to run csa212).&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
 # cd /root/asp/bin&lt;br /&gt;
 # ./asp_console&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
cli[Test]-&amp;gt; setc 1&lt;br /&gt;
cli[Test:SCNodeI0]-&amp;gt; setc cpm&lt;br /&gt;
cli[Test:SCNodeI0:CPM]-&amp;gt; amsLockAssignment sg csa212SGI0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Looking at the log file for this example you should see the following.&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffffaa;&amp;quot; align=&amp;quot;center&amp;quot;| /root/asp/var/log/csa212CompI3Log.latest&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
  Fri Oct  1 13:14:16.935 2010 (PayloadNodeI1.10366 : csa212CompEO.---.---.00001 :   INFO) Component [csa212CompI3] : PID [10366]. Initializing&lt;br /&gt;
&lt;br /&gt;
  Fri Oct  1 13:14:16.935 2010 (PayloadNodeI1.10366 : csa212CompEO.---.---.00002 :   INFO)    IOC Address             : 0x4&lt;br /&gt;
&lt;br /&gt;
  Fri Oct  1 13:14:16.935 2010 (PayloadNodeI1.10366 : csa212CompEO.---.---.00003 :   INFO)    IOC Port                : 0x80&lt;br /&gt;
&lt;br /&gt;
  Fri Oct  1 13:15:31.389 2010 (PayloadNodeI1.10366 : csa212CompEO.---.---.00004 :   INFO) Component [csa212CompI3] : PID [10366]. CSI Set Received&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;Now unlock the application with:&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
cli[Test:SCNodeI0:CPM]-&amp;gt; amsUnlock sg csa212SGI0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At this point you should see the following in the log.&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffffaa;&amp;quot; align=&amp;quot;center&amp;quot;| /root/asp/var/log/csa212CompI3Log.latest&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
 Fri Oct  1 13:15:31.389 2010 (PayloadNodeI1.10366 : csa212CompEO.---.---.00012 :   INFO) csa212: ACTIVE state requested; activating service&lt;br /&gt;
&lt;br /&gt;
  &lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Thats all there is to this example. What you are looking at in the log is the output of our event listener. It doesn't appear very interesting because we have not yet written an event publisher that will give the program something to output. We'll do that in the next example (csa213).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;At this point we can shut down our example in the usual fashion.&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
cli[Test:SCNodeI0:CPM]-&amp;gt; amsLockAssignment sg csa212SGI0&lt;br /&gt;
cli[Test:SCNodeI0:CPM]-&amp;gt; amsLockInstantiation sg csa212SGI0&lt;br /&gt;
cli[Test:SCNodeI0:CPM]-&amp;gt; end&lt;br /&gt;
cli[Test:SCNodeI0]-&amp;gt; end&lt;br /&gt;
cli[Test]-&amp;gt; bye&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
[[File:OpenClovis_Note.png]]When running model csa212 you will not see the output described for the the amsLockAssignment and amsUnlock commands.&lt;br /&gt;
&lt;br /&gt;
===Summary and References===&lt;br /&gt;
&lt;br /&gt;
We've seen how to create a basic event subscriber application using Clovis' event manager library.  For further reading check the Clovis SAFplus Platform API reference guide, specifically the section on the event manager.  Also, the header file: &amp;lt;code&amp;gt;clEventExtApi.h&amp;lt;/code&amp;gt; should be helpful.&lt;/div&gt;</summary>
		<author><name>Madhu</name></author>	</entry>

	<entry>
		<id>https://help.openclovis.com/index.php/Doc:latest/evalguide/csa212</id>
		<title>Doc:latest/evalguide/csa212</title>
		<link rel="alternate" type="text/html" href="https://help.openclovis.com/index.php/Doc:latest/evalguide/csa212"/>
				<updated>2010-10-01T09:32:19Z</updated>
		
		<summary type="html">&lt;p&gt;Madhu: /* Code */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==csa212 Event Subscription==&lt;br /&gt;
&lt;br /&gt;
===Objective===&lt;br /&gt;
&lt;br /&gt;
The objective of csa212 is to learn how to use Clovis' event service to subscribe to events and to extract the relevant information from the events received by subscription.&lt;br /&gt;
&lt;br /&gt;
===What you will learn===&lt;br /&gt;
&lt;br /&gt;
You will learn &lt;br /&gt;
*how to initialize the event library&lt;br /&gt;
*how to subscribe to events&lt;br /&gt;
*how to receive events&lt;br /&gt;
*how to extract the event data&lt;br /&gt;
&lt;br /&gt;
===Code===&lt;br /&gt;
&lt;br /&gt;
One difference to note between this application and previous ones is that this application will not have a main loop in &amp;lt;code&amp;gt;clCompAppInitialize&amp;lt;/code&amp;gt;.  Instead we will do our work in callback code.  This means that when we return from &amp;lt;code&amp;gt;clCompAppInitialize&amp;lt;/code&amp;gt; we won't exit the application.&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffccaa;&amp;quot; align=&amp;quot;center&amp;quot;| clCompAppMain.c&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
    SaNameT    evtChannelName = {&lt;br /&gt;
                    sizeof EVENT_CHANNEL_NAME - 1,&lt;br /&gt;
                    EVENT_CHANNEL_NAME&lt;br /&gt;
           };&lt;br /&gt;
&lt;br /&gt;
    SaEvtChannelHandleT    evtChannelHandle = 0;&lt;br /&gt;
    SaEvtHandleT      evtHandle = CL_HANDLE_INVALID_VALUE;&lt;br /&gt;
&lt;br /&gt;
    static void&lt;br /&gt;
    csa212Comp_appEventCallback( SaEvtSubscriptionIdT subscriptionId,&lt;br /&gt;
                                          SaEvtEventHandleT eventHandle,&lt;br /&gt;
                                          SaSizeT eventDataSize);&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
Here we define variables to hold the payload of our event. Note the initialization of the &amp;lt;code&amp;gt;evtChannelName&amp;lt;/code&amp;gt;.  The length is set to the length of the &amp;lt;code&amp;gt;EVENT_CHANNEL_NAME&amp;lt;/code&amp;gt; string WITHOUT including the &amp;lt;code&amp;gt;null&amp;lt;/code&amp;gt; terminator.&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffccaa;&amp;quot; align=&amp;quot;center&amp;quot;| clCompAppMain.c&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
    int&lt;br /&gt;
    main(int argc, char *argv[])&lt;br /&gt;
    {&lt;br /&gt;
        ....&lt;br /&gt;
&lt;br /&gt;
        const SaEvtCallbacksT   evtCallbacks = {&lt;br /&gt;
                           NULL,&lt;br /&gt;
                           csa212Comp_appEventCallback&lt;br /&gt;
                        };&lt;br /&gt;
&lt;br /&gt;
        ...&lt;br /&gt;
&lt;br /&gt;
        // publish our event callbacks&lt;br /&gt;
        rc = saEvtInitialize(&amp;amp;evtHandle, &amp;amp;evtCallbacks, &amp;amp;evtVersion);&lt;br /&gt;
&lt;br /&gt;
        ...&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
We initialize the OpenClovis Event Manager with &amp;lt;code&amp;gt;clEventInitialize&amp;lt;/code&amp;gt;.  We pass the address of the variable where we want the event handle stored.  We pass the address of our event callback functions structure.  Note that the only event callback function that we specify is &amp;lt;code&amp;gt;csa212Comp_appEventCallback&amp;lt;/code&amp;gt;.  We do not specify the other callback which is the Asynchronous channel open callback.  We specify &amp;lt;code&amp;gt;NULL&amp;lt;/code&amp;gt; for that field of &amp;lt;code&amp;gt;evtCallbacks&amp;lt;/code&amp;gt; because we don't open our event channel asynchronously.:&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffccaa;&amp;quot; align=&amp;quot;center&amp;quot;| clCompAppMain.c&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
    int&lt;br /&gt;
    main(int argc, char *argv[])&lt;br /&gt;
    {&lt;br /&gt;
&lt;br /&gt;
        ....&lt;br /&gt;
&lt;br /&gt;
        // Open an event chanel so that we can subscribe to events on that channel&lt;br /&gt;
        rc = saEvtChannelOpen(evtHandle,&lt;br /&gt;
                &amp;amp;evtChannelName,&lt;br /&gt;
                (SA_EVT_CHANNEL_SUBSCRIBER |&lt;br /&gt;
                 SA_EVENT_CHANNEL_CREATE),&lt;br /&gt;
                (SaTimeT)SA_TIME_END,&lt;br /&gt;
                &amp;amp;evtChannelHandle);&lt;br /&gt;
        if (rc != SA_AIS_OK)&lt;br /&gt;
        {   &lt;br /&gt;
            clprintf(CL_LOG_SEV_ERROR, &amp;quot;%s\t:Failure opening event channel[0x%x] at %ld\n&amp;quot;, appname,&lt;br /&gt;
&lt;br /&gt;
            logrc(CL_LOG_ERROR, &amp;quot;%s\t:Failure opening event channel[0x%x]\n&amp;quot;,&lt;br /&gt;
                    appname, rc&lt;br /&gt;
            goto errorexit;&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        rc = saEvtEventSubscribe(evtChannelHandle, NULL, 1);&lt;br /&gt;
        if (rc != SA_AIS_OK)&lt;br /&gt;
        {&lt;br /&gt;
            clprintf(CL_LOG_SEV_ERROR, &amp;quot;%s\t: Failed to subscribe to event channel [0x%x]\n&amp;quot;,&lt;br /&gt;
                    appname, rc);&lt;br /&gt;
            logrc(CL_LOG_ERROR,&lt;br /&gt;
                    &amp;quot;%s\t:Failed to subscribe to event channel [0x%x]\n&amp;quot;,&lt;br /&gt;
                    appname, rc);&lt;br /&gt;
            goto errorexit;&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
Within the above code we open the channel synchronously.  We pass the handle we got back from &amp;lt;code&amp;gt;clEventInitialize&amp;lt;/code&amp;gt;, the channel name we defined previously, flags that indicate this process is subscribing to the channel and it's a global channel, and that the channel should be created if it's not already there, a timeout value of &amp;quot;forever&amp;quot;, and the address of the location where the channel handle should be stored.  Then, we subscribe to a specific event stream on the event channel.  The &amp;lt;code&amp;gt;EVENT_TYPE&amp;lt;/code&amp;gt; constant is defined in &amp;lt;code&amp;gt;common/common.h&amp;lt;/code&amp;gt; as 5432.  This value is used by the event publisher when it sends events.  The constant 1 being passed simply identifies this specific subscription on this channel.  This value will be passed to our event delivery callback function.&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffccaa;&amp;quot; align=&amp;quot;center&amp;quot;| clCompAppMain.c&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
    static void&lt;br /&gt;
    csa212Comp_appEventCallback( SaEvtSubscriptionIdT subscriptionId,&lt;br /&gt;
                                              SaEvtEventHandleT eventHandle,&lt;br /&gt;
                                              SaSizeT eventDataSize)&lt;br /&gt;
    {&lt;br /&gt;
        SaAisErrorT  rc = SA_AIS_OK;&lt;br /&gt;
&lt;br /&gt;
        ClPtrT  resTest = NULL;&lt;br /&gt;
        ClSizeT resSize;&lt;br /&gt;
        if (running == 0 || ha_state != SA_AMF_HA_ACTIVE)&lt;br /&gt;
        {&lt;br /&gt;
           return; &lt;br /&gt;
        }&lt;br /&gt;
        clprintf(CL_LOG_SEV_INFO,&amp;quot;We've got an event to receive&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
        resTest = clHeapAllocate(eventDataSize + 1);&lt;br /&gt;
        if (resTest == NULL)&lt;br /&gt;
        {&lt;br /&gt;
            logmsg(CL_LOG_ERROR, &amp;quot;%s\tFailed to allocate space for event\n, appname&amp;quot;);&lt;br /&gt;
            return; &lt;br /&gt;
        }&lt;br /&gt;
        *(((char *)resTest) + eventDataSize) = 0;&lt;br /&gt;
        resSize = eventDataSize;&lt;br /&gt;
        rc = saEvtEventDataGet(eventHandle, resTest, &amp;amp;resSize);&lt;br /&gt;
        if (rc != SA_AIS_OK)&lt;br /&gt;
        {&lt;br /&gt;
           logrc(CL_LOG_ERROR, &amp;quot;%s\t:Failed to get event data [0x%x]\n&amp;quot;,&lt;br /&gt;
                    appname, rc);&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        clprintf(CL_LOG_SEV_INFO,&amp;quot;received event: %s\n&amp;quot;, (char *)resTest);&lt;br /&gt;
        return;&lt;br /&gt;
&lt;br /&gt;
    }&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
The event delivery callback function is named &amp;lt;code&amp;gt;csa112Comp_appEventCallback&amp;lt;/code&amp;gt;.  First it checks that the running variable is not zero and that the High Availability State is &amp;lt;code&amp;gt;CL_AMS_HA_STATE_ACTIVE&amp;lt;/code&amp;gt;, otherwise it returns, dropping the event in the bit bucket.  Next it checks whether our incoming data buffer needs to be deallocated.  If there is a buffer, it deallocates it and then allocates enough data to receive the incoming event data.  Then, we extract the data from the event into the newly allocated buffer using &amp;lt;code&amp;gt;clEventDataGet&amp;lt;/code&amp;gt;.  Finally, we print the event data we received using &amp;lt;code&amp;gt;clprintf&amp;lt;/code&amp;gt; which is another member of Clovis' OS Abstraction Layer.  As its name and usage suggest, it is the OSAL replacement for printf.&lt;br /&gt;
&lt;br /&gt;
===csa212 SA Forum Compliant Event Subscription===&lt;br /&gt;
&lt;br /&gt;
csa212 demonstrates the usage of SA Forum's Event Service. This sample application does not deviate functionally from csa112. The differences in code are due to using SA Forum data types (structures) and APIs , as presented in the following two tables. (Note we have not repeated data types and APIs covered previously.)&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|+align=&amp;quot;bottom&amp;quot;| '''SA Forum Data Types with the SAFplus Platform equivalent'''&lt;br /&gt;
|- style=&amp;quot;color:black;background-color:#ffffaa;&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
!SA Forum Data Types   &lt;br /&gt;
!OpenClovis Data Types&lt;br /&gt;
|-&lt;br /&gt;
|SaEvtHandleT&lt;br /&gt;
|ClEventInitHandleT&lt;br /&gt;
|-&lt;br /&gt;
|SaEvtChannelHandleT&lt;br /&gt;
|ClEventChannelHandleT&lt;br /&gt;
|-&lt;br /&gt;
|SaEvtCallbacksT&lt;br /&gt;
|ClEventCallbacksT&lt;br /&gt;
|-&lt;br /&gt;
|SA_EVT_CHANNEL_SUBSCRIBER&lt;br /&gt;
|CL_EVENT_CHANNEL_SUBSCRIBER &lt;br /&gt;
|-&lt;br /&gt;
|SA_EVT_CHANNEL_CREATE&lt;br /&gt;
|CL_EVENT_CHANNEL_CREATE&lt;br /&gt;
|-&lt;br /&gt;
|SA_TIME_END&lt;br /&gt;
|CL_RMD_TIMEOUT_FOREVER &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|+align=&amp;quot;bottom&amp;quot;| '''SA Forum APIs with the SAFplus Platform equivalent'''&lt;br /&gt;
|- style=&amp;quot;color:black;background-color:#ffffaa;&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
!SA Forum APIs&lt;br /&gt;
!OpenClovis APIs&lt;br /&gt;
|-&lt;br /&gt;
|SaEvtInitialize&lt;br /&gt;
|ClEventInitialize&lt;br /&gt;
|-&lt;br /&gt;
|saEvtChannelOpen&lt;br /&gt;
|clEventChannelOpen&lt;br /&gt;
|-&lt;br /&gt;
|saEvtEventSubscribe&lt;br /&gt;
|clEventExtSubscribe&lt;br /&gt;
|-&lt;br /&gt;
|saEvtEventDataGet&lt;br /&gt;
|clEventDataGet&lt;br /&gt;
|-&lt;br /&gt;
|saEvtChannelClose&lt;br /&gt;
|clEventChannelClose&lt;br /&gt;
|-&lt;br /&gt;
|saEvtFinalize&lt;br /&gt;
|clEventFinalize&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===How to Run csa212 and What to Observe===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Start example csa212 in the same manner that we have started previous examples, with the SAFplus Platform Console.(Unlock csa212SGI0 instead of csa112SGI0 to run csa212).&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
 # cd /root/asp/bin&lt;br /&gt;
 # ./asp_console&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
cli[Test]-&amp;gt; setc 1&lt;br /&gt;
cli[Test:SCNodeI0]-&amp;gt; setc cpm&lt;br /&gt;
cli[Test:SCNodeI0:CPM]-&amp;gt; amsLockAssignment sg csa212SGI0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Looking at the log file for this example you should see the following.&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffffaa;&amp;quot; align=&amp;quot;center&amp;quot;| /root/asp/var/log/csa212CompI3Log.latest&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
  Fri Oct  1 13:14:16.935 2010 (PayloadNodeI1.10366 : csa212CompEO.---.---.00001 :   INFO) Component [csa212CompI3] : PID [10366]. Initializing&lt;br /&gt;
&lt;br /&gt;
  Fri Oct  1 13:14:16.935 2010 (PayloadNodeI1.10366 : csa212CompEO.---.---.00002 :   INFO)    IOC Address             : 0x4&lt;br /&gt;
&lt;br /&gt;
  Fri Oct  1 13:14:16.935 2010 (PayloadNodeI1.10366 : csa212CompEO.---.---.00003 :   INFO)    IOC Port                : 0x80&lt;br /&gt;
&lt;br /&gt;
  Fri Oct  1 13:15:31.389 2010 (PayloadNodeI1.10366 : csa212CompEO.---.---.00004 :   INFO) Component [csa212CompI3] : PID [10366]. CSI Set Received&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;Now unlock the application with:&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
cli[Test:SCNodeI0:CPM]-&amp;gt; amsUnlock sg csa212SGI0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At this point you should see the following in the log.&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffffaa;&amp;quot; align=&amp;quot;center&amp;quot;| /root/asp/var/log/csa212CompI3Log.latest&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
 Fri Oct  1 13:15:31.389 2010 (PayloadNodeI1.10366 : csa212CompEO.---.---.00012 :   INFO) csa212: ACTIVE state requested; activating service&lt;br /&gt;
&lt;br /&gt;
  &lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Thats all there is to this example. What you are looking at in the log is the output of our event listener. It doesn't appear very interesting because we have not yet written an event publisher that will give the program something to output. We'll do that in the next example (csa213).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;At this point we can shut down our example in the usual fashion.&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
cli[Test:SCNodeI0:CPM]-&amp;gt; amsLockAssignment sg csa212SGI0&lt;br /&gt;
cli[Test:SCNodeI0:CPM]-&amp;gt; amsLockInstantiation sg csa212SGI0&lt;br /&gt;
cli[Test:SCNodeI0:CPM]-&amp;gt; end&lt;br /&gt;
cli[Test:SCNodeI0]-&amp;gt; end&lt;br /&gt;
cli[Test]-&amp;gt; bye&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
[[File:OpenClovis_Note.png]]When running model csa212 you will not see the output described for the the amsLockAssignment and amsUnlock commands.&lt;br /&gt;
&lt;br /&gt;
===Summary and References===&lt;br /&gt;
&lt;br /&gt;
We've seen how to create a basic event subscriber application using Clovis' event manager library.  For further reading check the Clovis SAFplus Platform API reference guide, specifically the section on the event manager.  Also, the header file: &amp;lt;code&amp;gt;clEventExtApi.h&amp;lt;/code&amp;gt; should be helpful.&lt;/div&gt;</summary>
		<author><name>Madhu</name></author>	</entry>

	<entry>
		<id>https://help.openclovis.com/index.php/Doc:latest/evalguide/csa212</id>
		<title>Doc:latest/evalguide/csa212</title>
		<link rel="alternate" type="text/html" href="https://help.openclovis.com/index.php/Doc:latest/evalguide/csa212"/>
				<updated>2010-10-01T09:22:33Z</updated>
		
		<summary type="html">&lt;p&gt;Madhu: /* Code */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==csa212 Event Subscription==&lt;br /&gt;
&lt;br /&gt;
===Objective===&lt;br /&gt;
&lt;br /&gt;
The objective of csa212 is to learn how to use Clovis' event service to subscribe to events and to extract the relevant information from the events received by subscription.&lt;br /&gt;
&lt;br /&gt;
===What you will learn===&lt;br /&gt;
&lt;br /&gt;
You will learn &lt;br /&gt;
*how to initialize the event library&lt;br /&gt;
*how to subscribe to events&lt;br /&gt;
*how to receive events&lt;br /&gt;
*how to extract the event data&lt;br /&gt;
&lt;br /&gt;
===Code===&lt;br /&gt;
&lt;br /&gt;
One difference to note between this application and previous ones is that this application will not have a main loop in &amp;lt;code&amp;gt;clCompAppInitialize&amp;lt;/code&amp;gt;.  Instead we will do our work in callback code.  This means that when we return from &amp;lt;code&amp;gt;clCompAppInitialize&amp;lt;/code&amp;gt; we won't exit the application.&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffccaa;&amp;quot; align=&amp;quot;center&amp;quot;| clCompAppMain.c&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
    SaNameT    evtChannelName = {&lt;br /&gt;
                    sizeof EVENT_CHANNEL_NAME - 1,&lt;br /&gt;
                    EVENT_CHANNEL_NAME&lt;br /&gt;
           };&lt;br /&gt;
&lt;br /&gt;
    SaEvtChannelHandleT    evtChannelHandle = 0;&lt;br /&gt;
    SaEvtHandleT      evtHandle = CL_HANDLE_INVALID_VALUE;&lt;br /&gt;
&lt;br /&gt;
    static void&lt;br /&gt;
    csa212Comp_appEventCallback( SaEvtSubscriptionIdT subscriptionId,&lt;br /&gt;
                                          SaEvtEventHandleT eventHandle,&lt;br /&gt;
                                          SaSizeT eventDataSize);&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
Here we define variables to hold the payload of our event. Note the initialization of the &amp;lt;code&amp;gt;evtChannelName&amp;lt;/code&amp;gt;.  The length is set to the length of the &amp;lt;code&amp;gt;EVENT_CHANNEL_NAME&amp;lt;/code&amp;gt; string WITHOUT including the &amp;lt;code&amp;gt;null&amp;lt;/code&amp;gt; terminator.&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffccaa;&amp;quot; align=&amp;quot;center&amp;quot;| clCompAppMain.c&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
    ClRcT&lt;br /&gt;
    clCompAppInitialize(ClUint32T argc,ClCharT *argv[])&lt;br /&gt;
    {&lt;br /&gt;
        ....&lt;br /&gt;
&lt;br /&gt;
        const SaEvtCallbacksT   evtCallbacks = {&lt;br /&gt;
                           NULL,&lt;br /&gt;
                           csa212Comp_appEventCallback&lt;br /&gt;
                        };&lt;br /&gt;
&lt;br /&gt;
        ...&lt;br /&gt;
&lt;br /&gt;
        // publish our event callbacks&lt;br /&gt;
        rc = saEvtInitialize(&amp;amp;evtHandle, &amp;amp;evtCallbacks, &amp;amp;evtVersion);&lt;br /&gt;
&lt;br /&gt;
        ...&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
We initialize the OpenClovis Event Manager with &amp;lt;code&amp;gt;clEventInitialize&amp;lt;/code&amp;gt;.  We pass the address of the variable where we want the event handle stored.  We pass the address of our event callback functions structure.  Note that the only event callback function that we specify is &amp;lt;code&amp;gt;csa212Comp_appEventCallback&amp;lt;/code&amp;gt;.  We do not specify the other callback which is the Asynchronous channel open callback.  We specify &amp;lt;code&amp;gt;NULL&amp;lt;/code&amp;gt; for that field of &amp;lt;code&amp;gt;evtCallbacks&amp;lt;/code&amp;gt; because we don't open our event channel asynchronously.:&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffccaa;&amp;quot; align=&amp;quot;center&amp;quot;| clCompAppMain.c&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
    ClRcT&lt;br /&gt;
    clCompAppInitialize(ClUint32T argc, ClCharT *argv[])&lt;br /&gt;
    {&lt;br /&gt;
&lt;br /&gt;
        ....&lt;br /&gt;
&lt;br /&gt;
        // Open an event chanel so that we can subscribe to events on that channel&lt;br /&gt;
        rc = saEvtChannelOpen(evtHandle,&lt;br /&gt;
                &amp;amp;evtChannelName,&lt;br /&gt;
                (SA_EVT_CHANNEL_SUBSCRIBER |&lt;br /&gt;
                 SA_EVENT_CHANNEL_CREATE),&lt;br /&gt;
                (SaTimeT)SA_TIME_END,&lt;br /&gt;
                &amp;amp;evtChannelHandle);&lt;br /&gt;
        if (rc != SA_AIS_OK)&lt;br /&gt;
        {   &lt;br /&gt;
            clprintf(CL_LOG_SEV_ERROR, &amp;quot;%s\t:Failure opening event channel[0x%x] at %ld\n&amp;quot;, appname,&lt;br /&gt;
&lt;br /&gt;
            logrc(CL_LOG_ERROR, &amp;quot;%s\t:Failure opening event channel[0x%x]\n&amp;quot;,&lt;br /&gt;
                    appname, rc&lt;br /&gt;
            goto errorexit;&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        rc = saEvtEventSubscribe(evtChannelHandle, NULL, 1);&lt;br /&gt;
        if (rc != CL_OK)&lt;br /&gt;
        {&lt;br /&gt;
            clprintf(CL_LOG_SEV_ERROR, &amp;quot;%s\t: Failed to subscribe to event channel [0x%x]\n&amp;quot;,&lt;br /&gt;
                    appname, rc);&lt;br /&gt;
            logrc(CL_LOG_ERROR,&lt;br /&gt;
                    &amp;quot;%s\t:Failed to subscribe to event channel [0x%x]\n&amp;quot;,&lt;br /&gt;
                    appname, rc);&lt;br /&gt;
            goto errorexit;&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
Within the above code we open the channel synchronously.  We pass the handle we got back from &amp;lt;code&amp;gt;clEventInitialize&amp;lt;/code&amp;gt;, the channel name we defined previously, flags that indicate this process is subscribing to the channel and it's a global channel, and that the channel should be created if it's not already there, a timeout value of &amp;quot;forever&amp;quot;, and the address of the location where the channel handle should be stored.  Then, we subscribe to a specific event stream on the event channel.  The &amp;lt;code&amp;gt;EVENT_TYPE&amp;lt;/code&amp;gt; constant is defined in &amp;lt;code&amp;gt;common/common.h&amp;lt;/code&amp;gt; as 5432.  This value is used by the event publisher when it sends events.  The constant 1 being passed simply identifies this specific subscription on this channel.  This value will be passed to our event delivery callback function.&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffccaa;&amp;quot; align=&amp;quot;center&amp;quot;| clCompAppMain.c&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
    static void&lt;br /&gt;
    csa212Comp_appEventCallback( SaEvtSubscriptionIdT subscriptionId,&lt;br /&gt;
                                              SaEvtEventHandleT eventHandle,&lt;br /&gt;
                                              SaSizeT eventDataSize)&lt;br /&gt;
    {&lt;br /&gt;
        SaAisErrorT  rc = SA_AIS_OK;&lt;br /&gt;
&lt;br /&gt;
        ClPtrT  resTest = NULL;&lt;br /&gt;
        ClSizeT resSize;&lt;br /&gt;
        if (running == 0 || ha_state != SA_AMF_HA_ACTIVE)&lt;br /&gt;
        {&lt;br /&gt;
           return; &lt;br /&gt;
        }&lt;br /&gt;
        clprintf(CL_LOG_SEV_INFO,&amp;quot;We've got an event to receive&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
        resTest = clHeapAllocate(eventDataSize + 1);&lt;br /&gt;
        if (resTest == NULL)&lt;br /&gt;
        {&lt;br /&gt;
            logmsg(CL_LOG_ERROR, &amp;quot;%s\tFailed to allocate space for event\n, appname&amp;quot;);&lt;br /&gt;
            return; &lt;br /&gt;
        }&lt;br /&gt;
        *(((char *)resTest) + eventDataSize) = 0;&lt;br /&gt;
        resSize = eventDataSize;&lt;br /&gt;
        rc = saEvtEventDataGet(eventHandle, resTest, &amp;amp;resSize);&lt;br /&gt;
        if (rc != SA_AIS_OK)&lt;br /&gt;
        {&lt;br /&gt;
           logrc(CL_LOG_ERROR, &amp;quot;%s\t:Failed to get event data [0x%x]\n&amp;quot;,&lt;br /&gt;
                    appname, rc);&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        clprintf(CL_LOG_SEV_INFO,&amp;quot;received event: %s\n&amp;quot;, (char *)resTest);&lt;br /&gt;
        return;&lt;br /&gt;
&lt;br /&gt;
    }&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
The event delivery callback function is named &amp;lt;code&amp;gt;csa112Comp_appEventCallback&amp;lt;/code&amp;gt;.  First it checks that the running variable is not zero and that the High Availability State is &amp;lt;code&amp;gt;CL_AMS_HA_STATE_ACTIVE&amp;lt;/code&amp;gt;, otherwise it returns, dropping the event in the bit bucket.  Next it checks whether our incoming data buffer needs to be deallocated.  If there is a buffer, it deallocates it and then allocates enough data to receive the incoming event data.  Then, we extract the data from the event into the newly allocated buffer using &amp;lt;code&amp;gt;clEventDataGet&amp;lt;/code&amp;gt;.  Finally, we print the event data we received using &amp;lt;code&amp;gt;clprintf&amp;lt;/code&amp;gt; which is another member of Clovis' OS Abstraction Layer.  As its name and usage suggest, it is the OSAL replacement for printf.&lt;br /&gt;
&lt;br /&gt;
===csa212 SA Forum Compliant Event Subscription===&lt;br /&gt;
&lt;br /&gt;
csa212 demonstrates the usage of SA Forum's Event Service. This sample application does not deviate functionally from csa112. The differences in code are due to using SA Forum data types (structures) and APIs , as presented in the following two tables. (Note we have not repeated data types and APIs covered previously.)&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|+align=&amp;quot;bottom&amp;quot;| '''SA Forum Data Types with the SAFplus Platform equivalent'''&lt;br /&gt;
|- style=&amp;quot;color:black;background-color:#ffffaa;&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
!SA Forum Data Types   &lt;br /&gt;
!OpenClovis Data Types&lt;br /&gt;
|-&lt;br /&gt;
|SaEvtHandleT&lt;br /&gt;
|ClEventInitHandleT&lt;br /&gt;
|-&lt;br /&gt;
|SaEvtChannelHandleT&lt;br /&gt;
|ClEventChannelHandleT&lt;br /&gt;
|-&lt;br /&gt;
|SaEvtCallbacksT&lt;br /&gt;
|ClEventCallbacksT&lt;br /&gt;
|-&lt;br /&gt;
|SA_EVT_CHANNEL_SUBSCRIBER&lt;br /&gt;
|CL_EVENT_CHANNEL_SUBSCRIBER &lt;br /&gt;
|-&lt;br /&gt;
|SA_EVT_CHANNEL_CREATE&lt;br /&gt;
|CL_EVENT_CHANNEL_CREATE&lt;br /&gt;
|-&lt;br /&gt;
|SA_TIME_END&lt;br /&gt;
|CL_RMD_TIMEOUT_FOREVER &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|+align=&amp;quot;bottom&amp;quot;| '''SA Forum APIs with the SAFplus Platform equivalent'''&lt;br /&gt;
|- style=&amp;quot;color:black;background-color:#ffffaa;&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
!SA Forum APIs&lt;br /&gt;
!OpenClovis APIs&lt;br /&gt;
|-&lt;br /&gt;
|SaEvtInitialize&lt;br /&gt;
|ClEventInitialize&lt;br /&gt;
|-&lt;br /&gt;
|saEvtChannelOpen&lt;br /&gt;
|clEventChannelOpen&lt;br /&gt;
|-&lt;br /&gt;
|saEvtEventSubscribe&lt;br /&gt;
|clEventExtSubscribe&lt;br /&gt;
|-&lt;br /&gt;
|saEvtEventDataGet&lt;br /&gt;
|clEventDataGet&lt;br /&gt;
|-&lt;br /&gt;
|saEvtChannelClose&lt;br /&gt;
|clEventChannelClose&lt;br /&gt;
|-&lt;br /&gt;
|saEvtFinalize&lt;br /&gt;
|clEventFinalize&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===How to Run csa212 and What to Observe===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Start example csa212 in the same manner that we have started previous examples, with the SAFplus Platform Console.(Unlock csa212SGI0 instead of csa112SGI0 to run csa212).&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
 # cd /root/asp/bin&lt;br /&gt;
 # ./asp_console&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
cli[Test]-&amp;gt; setc 1&lt;br /&gt;
cli[Test:SCNodeI0]-&amp;gt; setc cpm&lt;br /&gt;
cli[Test:SCNodeI0:CPM]-&amp;gt; amsLockAssignment sg csa212SGI0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Looking at the log file for this example you should see the following.&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffffaa;&amp;quot; align=&amp;quot;center&amp;quot;| /root/asp/var/log/csa212CompI3Log.latest&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
  Fri Oct  1 13:14:16.935 2010 (PayloadNodeI1.10366 : csa212CompEO.---.---.00001 :   INFO) Component [csa212CompI3] : PID [10366]. Initializing&lt;br /&gt;
&lt;br /&gt;
  Fri Oct  1 13:14:16.935 2010 (PayloadNodeI1.10366 : csa212CompEO.---.---.00002 :   INFO)    IOC Address             : 0x4&lt;br /&gt;
&lt;br /&gt;
  Fri Oct  1 13:14:16.935 2010 (PayloadNodeI1.10366 : csa212CompEO.---.---.00003 :   INFO)    IOC Port                : 0x80&lt;br /&gt;
&lt;br /&gt;
  Fri Oct  1 13:15:31.389 2010 (PayloadNodeI1.10366 : csa212CompEO.---.---.00004 :   INFO) Component [csa212CompI3] : PID [10366]. CSI Set Received&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;Now unlock the application with:&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
cli[Test:SCNodeI0:CPM]-&amp;gt; amsUnlock sg csa212SGI0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At this point you should see the following in the log.&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffffaa;&amp;quot; align=&amp;quot;center&amp;quot;| /root/asp/var/log/csa212CompI3Log.latest&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
 Fri Oct  1 13:15:31.389 2010 (PayloadNodeI1.10366 : csa212CompEO.---.---.00012 :   INFO) csa212: ACTIVE state requested; activating service&lt;br /&gt;
&lt;br /&gt;
  &lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Thats all there is to this example. What you are looking at in the log is the output of our event listener. It doesn't appear very interesting because we have not yet written an event publisher that will give the program something to output. We'll do that in the next example (csa213).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;At this point we can shut down our example in the usual fashion.&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
cli[Test:SCNodeI0:CPM]-&amp;gt; amsLockAssignment sg csa212SGI0&lt;br /&gt;
cli[Test:SCNodeI0:CPM]-&amp;gt; amsLockInstantiation sg csa212SGI0&lt;br /&gt;
cli[Test:SCNodeI0:CPM]-&amp;gt; end&lt;br /&gt;
cli[Test:SCNodeI0]-&amp;gt; end&lt;br /&gt;
cli[Test]-&amp;gt; bye&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
[[File:OpenClovis_Note.png]]When running model csa212 you will not see the output described for the the amsLockAssignment and amsUnlock commands.&lt;br /&gt;
&lt;br /&gt;
===Summary and References===&lt;br /&gt;
&lt;br /&gt;
We've seen how to create a basic event subscriber application using Clovis' event manager library.  For further reading check the Clovis SAFplus Platform API reference guide, specifically the section on the event manager.  Also, the header file: &amp;lt;code&amp;gt;clEventExtApi.h&amp;lt;/code&amp;gt; should be helpful.&lt;/div&gt;</summary>
		<author><name>Madhu</name></author>	</entry>

	<entry>
		<id>https://help.openclovis.com/index.php/Doc:latest/evalguide/csa212</id>
		<title>Doc:latest/evalguide/csa212</title>
		<link rel="alternate" type="text/html" href="https://help.openclovis.com/index.php/Doc:latest/evalguide/csa212"/>
				<updated>2010-10-01T08:20:49Z</updated>
		
		<summary type="html">&lt;p&gt;Madhu: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==csa212 Event Subscription==&lt;br /&gt;
&lt;br /&gt;
===Objective===&lt;br /&gt;
&lt;br /&gt;
The objective of csa212 is to learn how to use Clovis' event service to subscribe to events and to extract the relevant information from the events received by subscription.&lt;br /&gt;
&lt;br /&gt;
===What you will learn===&lt;br /&gt;
&lt;br /&gt;
You will learn &lt;br /&gt;
*how to initialize the event library&lt;br /&gt;
*how to subscribe to events&lt;br /&gt;
*how to receive events&lt;br /&gt;
*how to extract the event data&lt;br /&gt;
&lt;br /&gt;
===Code===&lt;br /&gt;
&lt;br /&gt;
One difference to note between this application and previous ones is that this application will not have a main loop in &amp;lt;code&amp;gt;clCompAppInitialize&amp;lt;/code&amp;gt;.  Instead we will do our work in callback code.  This means that when we return from &amp;lt;code&amp;gt;clCompAppInitialize&amp;lt;/code&amp;gt; we won't exit the application.&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffccaa;&amp;quot; align=&amp;quot;center&amp;quot;| clCompAppMain.c&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
    SaNameT    evtChannelName = {&lt;br /&gt;
                    sizeof EVENT_CHANNEL_NAME - 1,&lt;br /&gt;
                    EVENT_CHANNEL_NAME&lt;br /&gt;
           };&lt;br /&gt;
&lt;br /&gt;
    SaEvtChannelHandleT    evtChannelHandle = 0;&lt;br /&gt;
    SaEvtHandleT      evtHandle = CL_HANDLE_INVALID_VALUE;&lt;br /&gt;
&lt;br /&gt;
    static void&lt;br /&gt;
    csa212Comp_appEventCallback( SaEvtSubscriptionIdT subscriptionId,&lt;br /&gt;
                                          SaEvtEventHandleT eventHandle,&lt;br /&gt;
                                          SaSizeT eventDataSize);&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
Here we define variables to hold the payload of our event. Note the initialization of the &amp;lt;code&amp;gt;evtChannelName&amp;lt;/code&amp;gt;.  The length is set to the length of the &amp;lt;code&amp;gt;EVENT_CHANNEL_NAME&amp;lt;/code&amp;gt; string WITHOUT including the &amp;lt;code&amp;gt;null&amp;lt;/code&amp;gt; terminator.&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffccaa;&amp;quot; align=&amp;quot;center&amp;quot;| clCompAppMain.c&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
    ClRcT&lt;br /&gt;
    clCompAppInitialize(ClUint32T argc,ClCharT *argv[])&lt;br /&gt;
    {&lt;br /&gt;
        ....&lt;br /&gt;
&lt;br /&gt;
        const SaEvtCallbacksT   evtCallbacks = {&lt;br /&gt;
                           NULL,&lt;br /&gt;
                           csa212Comp_appEventCallback&lt;br /&gt;
                        };&lt;br /&gt;
&lt;br /&gt;
        ...&lt;br /&gt;
&lt;br /&gt;
        // publish our event callbacks&lt;br /&gt;
        rc = saEvtInitialize(&amp;amp;evtHandle, &amp;amp;evtCallbacks, &amp;amp;evtVersion);&lt;br /&gt;
&lt;br /&gt;
        ...&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
We initialize the OpenClovis Event Manager with &amp;lt;code&amp;gt;clEventInitialize&amp;lt;/code&amp;gt;.  We pass the address of the variable where we want the event handle stored.  We pass the address of our event callback functions structure.  Note that the only event callback function that we specify is &amp;lt;code&amp;gt;csa112Comp_appEventCallback&amp;lt;/code&amp;gt;.  We do not specify the other callback which is the Asynchronous channel open callback.  We specify &amp;lt;code&amp;gt;NULL&amp;lt;/code&amp;gt; for that field of &amp;lt;code&amp;gt;evtCallbacks&amp;lt;/code&amp;gt; because we don't open our event channel asynchronously.:&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffccaa;&amp;quot; align=&amp;quot;center&amp;quot;| clCompAppMain.c&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
    ClRcT&lt;br /&gt;
    clCompAppInitialize(ClUint32T argc, ClCharT *argv[])&lt;br /&gt;
    {&lt;br /&gt;
&lt;br /&gt;
        ....&lt;br /&gt;
&lt;br /&gt;
        // Open an event chanel so that we can subscribe to events on that channel&lt;br /&gt;
        rc = saEvtChannelOpen(evtHandle,&lt;br /&gt;
                &amp;amp;evtChannelName,&lt;br /&gt;
                (SA_EVT_CHANNEL_SUBSCRIBER |&lt;br /&gt;
                 SA_EVENT_CHANNEL_CREATE),&lt;br /&gt;
                (SaTimeT)SA_TIME_END,&lt;br /&gt;
                &amp;amp;evtChannelHandle);&lt;br /&gt;
        if (rc != SA_AIS_OK)&lt;br /&gt;
        {   &lt;br /&gt;
            clprintf(CL_LOG_SEV_ERROR, &amp;quot;%s\t:Failure opening event channel[0x%x] at %ld\n&amp;quot;, appname,&lt;br /&gt;
&lt;br /&gt;
            logrc(CL_LOG_ERROR, &amp;quot;%s\t:Failure opening event channel[0x%x]\n&amp;quot;,&lt;br /&gt;
                    appname, rc&lt;br /&gt;
            goto errorexit;&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        rc = saEvtEventSubscribe(evtChannelHandle, NULL, 1);&lt;br /&gt;
        if (rc != CL_OK)&lt;br /&gt;
        {&lt;br /&gt;
            clprintf(CL_LOG_SEV_ERROR, &amp;quot;%s\t: Failed to subscribe to event channel [0x%x]\n&amp;quot;,&lt;br /&gt;
                    appname, rc);&lt;br /&gt;
            logrc(CL_LOG_ERROR,&lt;br /&gt;
                    &amp;quot;%s\t:Failed to subscribe to event channel [0x%x]\n&amp;quot;,&lt;br /&gt;
                    appname, rc);&lt;br /&gt;
            goto errorexit;&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
Within the above code we open the channel synchronously.  We pass the handle we got back from &amp;lt;code&amp;gt;clEventInitialize&amp;lt;/code&amp;gt;, the channel name we defined previously, flags that indicate this process is subscribing to the channel and it's a global channel, and that the channel should be created if it's not already there, a timeout value of &amp;quot;forever&amp;quot;, and the address of the location where the channel handle should be stored.  Then, we subscribe to a specific event stream on the event channel.  The &amp;lt;code&amp;gt;EVENT_TYPE&amp;lt;/code&amp;gt; constant is defined in &amp;lt;code&amp;gt;common/common.h&amp;lt;/code&amp;gt; as 5432.  This value is used by the event publisher when it sends events.  The constant 1 being passed simply identifies this specific subscription on this channel.  This value will be passed to our event delivery callback function.&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffccaa;&amp;quot; align=&amp;quot;center&amp;quot;| clCompAppMain.c&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
    static void&lt;br /&gt;
    csa212Comp_appEventCallback( SaEvtSubscriptionIdT subscriptionId,&lt;br /&gt;
                                              SaEvtEventHandleT eventHandle,&lt;br /&gt;
                                              SaSizeT eventDataSize)&lt;br /&gt;
    {&lt;br /&gt;
        SaAisErrorT  rc = SA_AIS_OK;&lt;br /&gt;
&lt;br /&gt;
        ClPtrT  resTest = NULL;&lt;br /&gt;
        ClSizeT resSize;&lt;br /&gt;
        if (running == 0 || ha_state != SA_AMF_HA_ACTIVE)&lt;br /&gt;
        {&lt;br /&gt;
           return; &lt;br /&gt;
        }&lt;br /&gt;
        clprintf(CL_LOG_SEV_INFO,&amp;quot;We've got an event to receive&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
        resTest = clHeapAllocate(eventDataSize + 1);&lt;br /&gt;
        if (resTest == NULL)&lt;br /&gt;
        {&lt;br /&gt;
            logmsg(CL_LOG_ERROR, &amp;quot;%s\tFailed to allocate space for event\n, appname&amp;quot;);&lt;br /&gt;
            return; &lt;br /&gt;
        }&lt;br /&gt;
        *(((char *)resTest) + eventDataSize) = 0;&lt;br /&gt;
        resSize = eventDataSize;&lt;br /&gt;
        rc = saEvtEventDataGet(eventHandle, resTest, &amp;amp;resSize);&lt;br /&gt;
        if (rc != SA_AIS_OK)&lt;br /&gt;
        {&lt;br /&gt;
           logrc(CL_LOG_ERROR, &amp;quot;%s\t:Failed to get event data [0x%x]\n&amp;quot;,&lt;br /&gt;
                    appname, rc);&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        clprintf(CL_LOG_SEV_INFO,&amp;quot;received event: %s\n&amp;quot;, (char *)resTest);&lt;br /&gt;
        return;&lt;br /&gt;
&lt;br /&gt;
    }&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
The event delivery callback function is named &amp;lt;code&amp;gt;csa112Comp_appEventCallback&amp;lt;/code&amp;gt;.  First it checks that the running variable is not zero and that the High Availability State is &amp;lt;code&amp;gt;CL_AMS_HA_STATE_ACTIVE&amp;lt;/code&amp;gt;, otherwise it returns, dropping the event in the bit bucket.  Next it checks whether our incoming data buffer needs to be deallocated.  If there is a buffer, it deallocates it and then allocates enough data to receive the incoming event data.  Then, we extract the data from the event into the newly allocated buffer using &amp;lt;code&amp;gt;clEventDataGet&amp;lt;/code&amp;gt;.  Finally, we print the event data we received using &amp;lt;code&amp;gt;clprintf&amp;lt;/code&amp;gt; which is another member of Clovis' OS Abstraction Layer.  As its name and usage suggest, it is the OSAL replacement for printf.&lt;br /&gt;
&lt;br /&gt;
===csa212 SA Forum Compliant Event Subscription===&lt;br /&gt;
&lt;br /&gt;
csa212 demonstrates the usage of SA Forum's Event Service. This sample application does not deviate functionally from csa112. The differences in code are due to using SA Forum data types (structures) and APIs , as presented in the following two tables. (Note we have not repeated data types and APIs covered previously.)&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|+align=&amp;quot;bottom&amp;quot;| '''SA Forum Data Types with the SAFplus Platform equivalent'''&lt;br /&gt;
|- style=&amp;quot;color:black;background-color:#ffffaa;&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
!SA Forum Data Types   &lt;br /&gt;
!OpenClovis Data Types&lt;br /&gt;
|-&lt;br /&gt;
|SaEvtHandleT&lt;br /&gt;
|ClEventInitHandleT&lt;br /&gt;
|-&lt;br /&gt;
|SaEvtChannelHandleT&lt;br /&gt;
|ClEventChannelHandleT&lt;br /&gt;
|-&lt;br /&gt;
|SaEvtCallbacksT&lt;br /&gt;
|ClEventCallbacksT&lt;br /&gt;
|-&lt;br /&gt;
|SA_EVT_CHANNEL_SUBSCRIBER&lt;br /&gt;
|CL_EVENT_CHANNEL_SUBSCRIBER &lt;br /&gt;
|-&lt;br /&gt;
|SA_EVT_CHANNEL_CREATE&lt;br /&gt;
|CL_EVENT_CHANNEL_CREATE&lt;br /&gt;
|-&lt;br /&gt;
|SA_TIME_END&lt;br /&gt;
|CL_RMD_TIMEOUT_FOREVER &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|+align=&amp;quot;bottom&amp;quot;| '''SA Forum APIs with the SAFplus Platform equivalent'''&lt;br /&gt;
|- style=&amp;quot;color:black;background-color:#ffffaa;&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
!SA Forum APIs&lt;br /&gt;
!OpenClovis APIs&lt;br /&gt;
|-&lt;br /&gt;
|SaEvtInitialize&lt;br /&gt;
|ClEventInitialize&lt;br /&gt;
|-&lt;br /&gt;
|saEvtChannelOpen&lt;br /&gt;
|clEventChannelOpen&lt;br /&gt;
|-&lt;br /&gt;
|saEvtEventSubscribe&lt;br /&gt;
|clEventExtSubscribe&lt;br /&gt;
|-&lt;br /&gt;
|saEvtEventDataGet&lt;br /&gt;
|clEventDataGet&lt;br /&gt;
|-&lt;br /&gt;
|saEvtChannelClose&lt;br /&gt;
|clEventChannelClose&lt;br /&gt;
|-&lt;br /&gt;
|saEvtFinalize&lt;br /&gt;
|clEventFinalize&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===How to Run csa212 and What to Observe===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Start example csa212 in the same manner that we have started previous examples, with the SAFplus Platform Console.(Unlock csa212SGI0 instead of csa112SGI0 to run csa212).&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
 # cd /root/asp/bin&lt;br /&gt;
 # ./asp_console&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
cli[Test]-&amp;gt; setc 1&lt;br /&gt;
cli[Test:SCNodeI0]-&amp;gt; setc cpm&lt;br /&gt;
cli[Test:SCNodeI0:CPM]-&amp;gt; amsLockAssignment sg csa212SGI0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Looking at the log file for this example you should see the following.&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffffaa;&amp;quot; align=&amp;quot;center&amp;quot;| /root/asp/var/log/csa212CompI3Log.latest&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
  Fri Oct  1 13:14:16.935 2010 (PayloadNodeI1.10366 : csa212CompEO.---.---.00001 :   INFO) Component [csa212CompI3] : PID [10366]. Initializing&lt;br /&gt;
&lt;br /&gt;
  Fri Oct  1 13:14:16.935 2010 (PayloadNodeI1.10366 : csa212CompEO.---.---.00002 :   INFO)    IOC Address             : 0x4&lt;br /&gt;
&lt;br /&gt;
  Fri Oct  1 13:14:16.935 2010 (PayloadNodeI1.10366 : csa212CompEO.---.---.00003 :   INFO)    IOC Port                : 0x80&lt;br /&gt;
&lt;br /&gt;
  Fri Oct  1 13:15:31.389 2010 (PayloadNodeI1.10366 : csa212CompEO.---.---.00004 :   INFO) Component [csa212CompI3] : PID [10366]. CSI Set Received&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;Now unlock the application with:&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
cli[Test:SCNodeI0:CPM]-&amp;gt; amsUnlock sg csa212SGI0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At this point you should see the following in the log.&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffffaa;&amp;quot; align=&amp;quot;center&amp;quot;| /root/asp/var/log/csa212CompI3Log.latest&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
 Fri Oct  1 13:15:31.389 2010 (PayloadNodeI1.10366 : csa212CompEO.---.---.00012 :   INFO) csa212: ACTIVE state requested; activating service&lt;br /&gt;
&lt;br /&gt;
  &lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Thats all there is to this example. What you are looking at in the log is the output of our event listener. It doesn't appear very interesting because we have not yet written an event publisher that will give the program something to output. We'll do that in the next example (csa213).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;At this point we can shut down our example in the usual fashion.&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
cli[Test:SCNodeI0:CPM]-&amp;gt; amsLockAssignment sg csa212SGI0&lt;br /&gt;
cli[Test:SCNodeI0:CPM]-&amp;gt; amsLockInstantiation sg csa212SGI0&lt;br /&gt;
cli[Test:SCNodeI0:CPM]-&amp;gt; end&lt;br /&gt;
cli[Test:SCNodeI0]-&amp;gt; end&lt;br /&gt;
cli[Test]-&amp;gt; bye&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
[[File:OpenClovis_Note.png]]When running model csa212 you will not see the output described for the the amsLockAssignment and amsUnlock commands.&lt;br /&gt;
&lt;br /&gt;
===Summary and References===&lt;br /&gt;
&lt;br /&gt;
We've seen how to create a basic event subscriber application using Clovis' event manager library.  For further reading check the Clovis SAFplus Platform API reference guide, specifically the section on the event manager.  Also, the header file: &amp;lt;code&amp;gt;clEventExtApi.h&amp;lt;/code&amp;gt; should be helpful.&lt;/div&gt;</summary>
		<author><name>Madhu</name></author>	</entry>

	<entry>
		<id>https://help.openclovis.com/index.php/Doc:latest/evalguide</id>
		<title>Doc:latest/evalguide</title>
		<link rel="alternate" type="text/html" href="https://help.openclovis.com/index.php/Doc:latest/evalguide"/>
				<updated>2010-10-01T08:10:29Z</updated>
		
		<summary type="html">&lt;p&gt;Madhu: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Table of contents:&lt;br /&gt;
* [[Doc:latest/evalguide/preface | Preface ]]&lt;br /&gt;
* [[Doc:latest/evalguide/scope | Objectives and Scope ]]&lt;br /&gt;
* [[Doc:latest/evalguide/prerequisites | Hardware and Software Prerequisites]]&lt;br /&gt;
* [[Doc:latest/evalguide/setup | Runtime Hardware Setup ]]&lt;br /&gt;
* [[Doc:latest/evalguide/build | Building the Evaluation System and Deploying Runtime Images]]&lt;br /&gt;
* [[Doc:latest/evalguide/csa |Sample Applications]]&lt;br /&gt;
&amp;lt;!--**[[Doc:latest/evalguide/csa101 | csa101&amp;lt;sub&amp;gt;csa201&amp;lt;/sub&amp;gt; Component Management]]--&amp;gt;&lt;br /&gt;
**[[Doc:latest/evalguide/csa102 | csa102 Redundancy and Failover]]&lt;br /&gt;
**[[Doc:latest/evalguide/csa103 | csa103&amp;lt;sub&amp;gt;csa203&amp;lt;/sub&amp;gt; Checkpointing]]&lt;br /&gt;
**[[Doc:latest/evalguide/csa104 | csa104 Provisioning]]&lt;br /&gt;
**[[Doc:latest/evalguide/csa105 | csa105 Software Alarm Management and Provisioning]]&lt;br /&gt;
&amp;lt;!--**[[Doc:latest/evalguide/csa106 | csa106 HAL/DO (hardware provisioning with Ethernet port)]]--&amp;gt;&lt;br /&gt;
&amp;lt;!--**[[Doc:latest/evalguide/csa111 | csa111 Hello World with logging]]--&amp;gt;&lt;br /&gt;
**[[Doc:latest/evalguide/csa212 | csa212 Event Subscription]]&lt;br /&gt;
**[[Doc:latest/evalguide/csa113 | csa113&amp;lt;sub&amp;gt;csa213&amp;lt;/sub&amp;gt; Event Publication]]&lt;br /&gt;
&amp;lt;!--**[[Doc:latest/evalguide/csa114 | csa114 IOC &amp;amp; RMD]]--&amp;gt;&lt;br /&gt;
&amp;lt;!--**[[Doc:latest/evalguide/csa115 | csa115 Name Service]]--&amp;gt;&lt;br /&gt;
&amp;lt;!--**[[Doc:latest/evalguide/csa501 | csa501 Logical Addressing and RMD calls]]--&amp;gt;&lt;br /&gt;
**[[Doc:latest/evalguide/dhaDemo | Dynamic HA application]]&lt;br /&gt;
**[[Doc:latest/evalguide/csasum | Summary and Next Steps]]&lt;br /&gt;
* [[Doc:latest/evalguide/app_ide | Appendix: OpenClovis IDE ]]&lt;/div&gt;</summary>
		<author><name>Madhu</name></author>	</entry>

	<entry>
		<id>https://help.openclovis.com/index.php/Doc:latest/evalguide/csa112</id>
		<title>Doc:latest/evalguide/csa112</title>
		<link rel="alternate" type="text/html" href="https://help.openclovis.com/index.php/Doc:latest/evalguide/csa112"/>
				<updated>2010-10-01T08:05:22Z</updated>
		
		<summary type="html">&lt;p&gt;Madhu: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==csa212 Event Subscription==&lt;br /&gt;
&lt;br /&gt;
===Objective===&lt;br /&gt;
&lt;br /&gt;
The objective of csa212 is to learn how to use Clovis' event service to subscribe to events and to extract the relevant information from the events received by subscription.&lt;br /&gt;
&lt;br /&gt;
===What you will learn===&lt;br /&gt;
&lt;br /&gt;
You will learn &lt;br /&gt;
*how to initialize the event library&lt;br /&gt;
*how to subscribe to events&lt;br /&gt;
*how to receive events&lt;br /&gt;
*how to extract the event data&lt;br /&gt;
&lt;br /&gt;
===Code===&lt;br /&gt;
&lt;br /&gt;
One difference to note between this application and previous ones is that this application will not have a main loop in &amp;lt;code&amp;gt;clCompAppInitialize&amp;lt;/code&amp;gt;.  Instead we will do our work in callback code.  This means that when we return from &amp;lt;code&amp;gt;clCompAppInitialize&amp;lt;/code&amp;gt; we won't exit the application.&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffccaa;&amp;quot; align=&amp;quot;center&amp;quot;| clCompAppMain.c&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
    SaNameT    evtChannelName = {&lt;br /&gt;
                    sizeof EVENT_CHANNEL_NAME - 1,&lt;br /&gt;
                    EVENT_CHANNEL_NAME&lt;br /&gt;
           };&lt;br /&gt;
&lt;br /&gt;
    SaEvtChannelHandleT    evtChannelHandle = 0;&lt;br /&gt;
    SaEvtHandleT      evtHandle = CL_HANDLE_INVALID_VALUE;&lt;br /&gt;
&lt;br /&gt;
    static void&lt;br /&gt;
    csa212Comp_appEventCallback( SaEvtSubscriptionIdT subscriptionId,&lt;br /&gt;
                                          SaEvtEventHandleT eventHandle,&lt;br /&gt;
                                          SaSizeT eventDataSize);&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
Here we define variables to hold the payload of our event. Note the initialization of the &amp;lt;code&amp;gt;evtChannelName&amp;lt;/code&amp;gt;.  The length is set to the length of the &amp;lt;code&amp;gt;EVENT_CHANNEL_NAME&amp;lt;/code&amp;gt; string WITHOUT including the &amp;lt;code&amp;gt;null&amp;lt;/code&amp;gt; terminator.&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffccaa;&amp;quot; align=&amp;quot;center&amp;quot;| clCompAppMain.c&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
    ClRcT&lt;br /&gt;
    clCompAppInitialize(ClUint32T argc,ClCharT *argv[])&lt;br /&gt;
    {&lt;br /&gt;
        ....&lt;br /&gt;
&lt;br /&gt;
        const SaEvtCallbacksT   evtCallbacks = {&lt;br /&gt;
                           NULL,&lt;br /&gt;
                           csa212Comp_appEventCallback&lt;br /&gt;
                        };&lt;br /&gt;
&lt;br /&gt;
        ...&lt;br /&gt;
&lt;br /&gt;
        // publish our event callbacks&lt;br /&gt;
        rc = saEvtInitialize(&amp;amp;evtHandle, &amp;amp;evtCallbacks, &amp;amp;evtVersion);&lt;br /&gt;
&lt;br /&gt;
        ...&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
We initialize the OpenClovis Event Manager with &amp;lt;code&amp;gt;clEventInitialize&amp;lt;/code&amp;gt;.  We pass the address of the variable where we want the event handle stored.  We pass the address of our event callback functions structure.  Note that the only event callback function that we specify is &amp;lt;code&amp;gt;csa112Comp_appEventCallback&amp;lt;/code&amp;gt;.  We do not specify the other callback which is the Asynchronous channel open callback.  We specify &amp;lt;code&amp;gt;NULL&amp;lt;/code&amp;gt; for that field of &amp;lt;code&amp;gt;evtCallbacks&amp;lt;/code&amp;gt; because we don't open our event channel asynchronously.:&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffccaa;&amp;quot; align=&amp;quot;center&amp;quot;| clCompAppMain.c&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
    ClRcT&lt;br /&gt;
    clCompAppInitialize(ClUint32T argc, ClCharT *argv[])&lt;br /&gt;
    {&lt;br /&gt;
&lt;br /&gt;
        ....&lt;br /&gt;
&lt;br /&gt;
        // Open an event chanel so that we can subscribe to events on that channel&lt;br /&gt;
        rc = saEvtChannelOpen(evtHandle,&lt;br /&gt;
                &amp;amp;evtChannelName,&lt;br /&gt;
                (SA_EVT_CHANNEL_SUBSCRIBER |&lt;br /&gt;
                 SA_EVENT_CHANNEL_CREATE),&lt;br /&gt;
                (SaTimeT)SA_TIME_END,&lt;br /&gt;
                &amp;amp;evtChannelHandle);&lt;br /&gt;
        if (rc != SA_AIS_OK)&lt;br /&gt;
        {   &lt;br /&gt;
            clprintf(CL_LOG_SEV_ERROR, &amp;quot;%s\t:Failure opening event channel[0x%x] at %ld\n&amp;quot;, appname,&lt;br /&gt;
&lt;br /&gt;
            logrc(CL_LOG_ERROR, &amp;quot;%s\t:Failure opening event channel[0x%x]\n&amp;quot;,&lt;br /&gt;
                    appname, rc&lt;br /&gt;
            goto errorexit;&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        rc = saEvtEventSubscribe(evtChannelHandle, NULL, 1);&lt;br /&gt;
        if (rc != CL_OK)&lt;br /&gt;
        {&lt;br /&gt;
            clprintf(CL_LOG_SEV_ERROR, &amp;quot;%s\t: Failed to subscribe to event channel [0x%x]\n&amp;quot;,&lt;br /&gt;
                    appname, rc);&lt;br /&gt;
            logrc(CL_LOG_ERROR,&lt;br /&gt;
                    &amp;quot;%s\t:Failed to subscribe to event channel [0x%x]\n&amp;quot;,&lt;br /&gt;
                    appname, rc);&lt;br /&gt;
            goto errorexit;&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
Within the above code we open the channel synchronously.  We pass the handle we got back from &amp;lt;code&amp;gt;clEventInitialize&amp;lt;/code&amp;gt;, the channel name we defined previously, flags that indicate this process is subscribing to the channel and it's a global channel, and that the channel should be created if it's not already there, a timeout value of &amp;quot;forever&amp;quot;, and the address of the location where the channel handle should be stored.  Then, we subscribe to a specific event stream on the event channel.  The &amp;lt;code&amp;gt;EVENT_TYPE&amp;lt;/code&amp;gt; constant is defined in &amp;lt;code&amp;gt;common/common.h&amp;lt;/code&amp;gt; as 5432.  This value is used by the event publisher when it sends events.  The constant 1 being passed simply identifies this specific subscription on this channel.  This value will be passed to our event delivery callback function.&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffccaa;&amp;quot; align=&amp;quot;center&amp;quot;| clCompAppMain.c&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
    static void&lt;br /&gt;
    csa212Comp_appEventCallback( SaEvtSubscriptionIdT subscriptionId,&lt;br /&gt;
                                              SaEvtEventHandleT eventHandle,&lt;br /&gt;
                                              SaSizeT eventDataSize)&lt;br /&gt;
    {&lt;br /&gt;
        SaAisErrorT  rc = SA_AIS_OK;&lt;br /&gt;
&lt;br /&gt;
        ClPtrT  resTest = NULL;&lt;br /&gt;
        ClSizeT resSize;&lt;br /&gt;
        if (running == 0 || ha_state != SA_AMF_HA_ACTIVE)&lt;br /&gt;
        {&lt;br /&gt;
           return; &lt;br /&gt;
        }&lt;br /&gt;
        clprintf(CL_LOG_SEV_INFO,&amp;quot;We've got an event to receive&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
        resTest = clHeapAllocate(eventDataSize + 1);&lt;br /&gt;
        if (resTest == NULL)&lt;br /&gt;
        {&lt;br /&gt;
            logmsg(CL_LOG_ERROR, &amp;quot;%s\tFailed to allocate space for event\n, appname&amp;quot;);&lt;br /&gt;
            return; &lt;br /&gt;
        }&lt;br /&gt;
        *(((char *)resTest) + eventDataSize) = 0;&lt;br /&gt;
        resSize = eventDataSize;&lt;br /&gt;
        rc = saEvtEventDataGet(eventHandle, resTest, &amp;amp;resSize);&lt;br /&gt;
        if (rc != SA_AIS_OK)&lt;br /&gt;
        {&lt;br /&gt;
           logrc(CL_LOG_ERROR, &amp;quot;%s\t:Failed to get event data [0x%x]\n&amp;quot;,&lt;br /&gt;
                    appname, rc);&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        clprintf(CL_LOG_SEV_INFO,&amp;quot;received event: %s\n&amp;quot;, (char *)resTest);&lt;br /&gt;
        return;&lt;br /&gt;
&lt;br /&gt;
    }&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
The event delivery callback function is named &amp;lt;code&amp;gt;csa112Comp_appEventCallback&amp;lt;/code&amp;gt;.  First it checks that the running variable is not zero and that the High Availability State is &amp;lt;code&amp;gt;CL_AMS_HA_STATE_ACTIVE&amp;lt;/code&amp;gt;, otherwise it returns, dropping the event in the bit bucket.  Next it checks whether our incoming data buffer needs to be deallocated.  If there is a buffer, it deallocates it and then allocates enough data to receive the incoming event data.  Then, we extract the data from the event into the newly allocated buffer using &amp;lt;code&amp;gt;clEventDataGet&amp;lt;/code&amp;gt;.  Finally, we print the event data we received using &amp;lt;code&amp;gt;clprintf&amp;lt;/code&amp;gt; which is another member of Clovis' OS Abstraction Layer.  As its name and usage suggest, it is the OSAL replacement for printf.&lt;br /&gt;
&lt;br /&gt;
===csa212 SA Forum Compliant Event Subscription===&lt;br /&gt;
&lt;br /&gt;
csa212 demonstrates the usage of SA Forum's Event Service. This sample application does not deviate functionally from csa112. The differences in code are due to using SA Forum data types (structures) and APIs , as presented in the following two tables. (Note we have not repeated data types and APIs covered previously.)&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|+align=&amp;quot;bottom&amp;quot;| '''SA Forum Data Types with the SAFplus Platform equivalent'''&lt;br /&gt;
|- style=&amp;quot;color:black;background-color:#ffffaa;&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
!SA Forum Data Types   &lt;br /&gt;
!OpenClovis Data Types&lt;br /&gt;
|-&lt;br /&gt;
|SaEvtHandleT&lt;br /&gt;
|ClEventInitHandleT&lt;br /&gt;
|-&lt;br /&gt;
|SaEvtChannelHandleT&lt;br /&gt;
|ClEventChannelHandleT&lt;br /&gt;
|-&lt;br /&gt;
|SaEvtCallbacksT&lt;br /&gt;
|ClEventCallbacksT&lt;br /&gt;
|-&lt;br /&gt;
|SA_EVT_CHANNEL_SUBSCRIBER&lt;br /&gt;
|CL_EVENT_CHANNEL_SUBSCRIBER &lt;br /&gt;
|-&lt;br /&gt;
|SA_EVT_CHANNEL_CREATE&lt;br /&gt;
|CL_EVENT_CHANNEL_CREATE&lt;br /&gt;
|-&lt;br /&gt;
|SA_TIME_END&lt;br /&gt;
|CL_RMD_TIMEOUT_FOREVER &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|+align=&amp;quot;bottom&amp;quot;| '''SA Forum APIs with the SAFplus Platform equivalent'''&lt;br /&gt;
|- style=&amp;quot;color:black;background-color:#ffffaa;&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
!SA Forum APIs&lt;br /&gt;
!OpenClovis APIs&lt;br /&gt;
|-&lt;br /&gt;
|SaEvtInitialize&lt;br /&gt;
|ClEventInitialize&lt;br /&gt;
|-&lt;br /&gt;
|saEvtChannelOpen&lt;br /&gt;
|clEventChannelOpen&lt;br /&gt;
|-&lt;br /&gt;
|saEvtEventSubscribe&lt;br /&gt;
|clEventExtSubscribe&lt;br /&gt;
|-&lt;br /&gt;
|saEvtEventDataGet&lt;br /&gt;
|clEventDataGet&lt;br /&gt;
|-&lt;br /&gt;
|saEvtChannelClose&lt;br /&gt;
|clEventChannelClose&lt;br /&gt;
|-&lt;br /&gt;
|saEvtFinalize&lt;br /&gt;
|clEventFinalize&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===How to Run csa212 and What to Observe===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Start example csa212 in the same manner that we have started previous examples, with the SAFplus Platform Console.(Unlock csa212SGI0 instead of csa112SGI0 to run csa212).&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
 # cd /root/asp/bin&lt;br /&gt;
 # ./asp_console&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
cli[Test]-&amp;gt; setc 1&lt;br /&gt;
cli[Test:SCNodeI0]-&amp;gt; setc cpm&lt;br /&gt;
cli[Test:SCNodeI0:CPM]-&amp;gt; amsLockAssignment sg csa212SGI0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Looking at the log file for this example you should see the following.&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffffaa;&amp;quot; align=&amp;quot;center&amp;quot;| /root/asp/var/log/csa212CompI3Log.latest&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
  Fri Oct  1 13:14:16.935 2010 (PayloadNodeI1.10366 : csa212CompEO.---.---.00001 :   INFO) Component [csa212CompI3] : PID [10366]. Initializing&lt;br /&gt;
&lt;br /&gt;
  Fri Oct  1 13:14:16.935 2010 (PayloadNodeI1.10366 : csa212CompEO.---.---.00002 :   INFO)    IOC Address             : 0x4&lt;br /&gt;
&lt;br /&gt;
  Fri Oct  1 13:14:16.935 2010 (PayloadNodeI1.10366 : csa212CompEO.---.---.00003 :   INFO)    IOC Port                : 0x80&lt;br /&gt;
&lt;br /&gt;
  Fri Oct  1 13:15:31.389 2010 (PayloadNodeI1.10366 : csa212CompEO.---.---.00004 :   INFO) Component [csa212CompI3] : PID [10366]. CSI Set Received&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;Now unlock the application with:&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
cli[Test:SCNodeI0:CPM]-&amp;gt; amsUnlock sg csa212SGI0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At this point you should see the following in the log.&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffffaa;&amp;quot; align=&amp;quot;center&amp;quot;| /root/asp/var/log/csa212CompI3Log.latest&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
 Fri Oct  1 13:15:31.389 2010 (PayloadNodeI1.10366 : csa212CompEO.---.---.00012 :   INFO) csa212: ACTIVE state requested; activating service&lt;br /&gt;
&lt;br /&gt;
  &lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Thats all there is to this example. What you are looking at in the log is the output of our event listener. It doesn't appear very interesting because we have not yet written an event publisher that will give the program something to output. We'll do that in the next example (csa213).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;At this point we can shut down our example in the usual fashion.&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
cli[Test:SCNodeI0:CPM]-&amp;gt; amsLockAssignment sg csa212SGI0&lt;br /&gt;
cli[Test:SCNodeI0:CPM]-&amp;gt; amsLockInstantiation sg csa212SGI0&lt;br /&gt;
cli[Test:SCNodeI0:CPM]-&amp;gt; end&lt;br /&gt;
cli[Test:SCNodeI0]-&amp;gt; end&lt;br /&gt;
cli[Test]-&amp;gt; bye&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
[[File:OpenClovis_Note.png]]When running model csa212 you will not see the output described for the the amsLockAssignment and amsUnlock commands.&lt;br /&gt;
&lt;br /&gt;
===Summary and References===&lt;br /&gt;
&lt;br /&gt;
We've seen how to create a basic event subscriber application using Clovis' event manager library.  For further reading check the Clovis SAFplus Platform API reference guide, specifically the section on the event manager.  Also, the header file: &amp;lt;code&amp;gt;clEventExtApi.h&amp;lt;/code&amp;gt; should be helpful.&lt;/div&gt;</summary>
		<author><name>Madhu</name></author>	</entry>

	<entry>
		<id>https://help.openclovis.com/index.php/Doc:latest/evalguide/csa103</id>
		<title>Doc:latest/evalguide/csa103</title>
		<link rel="alternate" type="text/html" href="https://help.openclovis.com/index.php/Doc:latest/evalguide/csa103"/>
				<updated>2010-10-01T06:29:32Z</updated>
		
		<summary type="html">&lt;p&gt;Madhu: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==csa103 Checkpointing==&lt;br /&gt;
&lt;br /&gt;
===Objective===&lt;br /&gt;
&lt;br /&gt;
csa103 demonstrates how to use the Clovis Checkpoint service to provide basic failure recovery.  csa103 builds on csa102.&lt;br /&gt;
&lt;br /&gt;
===What Will You Learn===&lt;br /&gt;
&lt;br /&gt;
*how to initialize the checkpoint client library, &lt;br /&gt;
*how to create a checkpoint and  open a checkpoint, &lt;br /&gt;
*how to create a section in the checkpoint &lt;br /&gt;
*how to save data to the checkpoint section and read data from the checkpoint section.&lt;br /&gt;
&lt;br /&gt;
===The Code===&lt;br /&gt;
&lt;br /&gt;
The code can be found within the following directory&lt;br /&gt;
 &amp;lt;project-area_dir&amp;gt;/eval/src/app/csa103Comp&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffccaa;&amp;quot; align=&amp;quot;center&amp;quot;| clCompAppMain.c&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
ClCompAppInitialize()&lt;br /&gt;
&lt;br /&gt;
        ...&lt;br /&gt;
&lt;br /&gt;
        if ((rc = checkpoint_initialize()) != SA_AIS_OK)&lt;br /&gt;
        {&lt;br /&gt;
            clprintf(CL_LOG_SEV_ERROR,&amp;quot;%s: Failed [0x%x] to initialize checkpoint&amp;quot;,&lt;br /&gt;
                    appname, rc);&lt;br /&gt;
            return rc;&lt;br /&gt;
        }&lt;br /&gt;
        if ((rc = checkpoint_read_seq(&amp;amp;seq)) != SA_AIS_OK)&lt;br /&gt;
        {&lt;br /&gt;
            clprintf(CL_LOG_SEV_ERROR,&amp;quot;%s: Failed [0x%x] to read checkpoint&amp;quot;,&lt;br /&gt;
                    appname, rc);&lt;br /&gt;
            checkpoint_finalize();&lt;br /&gt;
            return rc;&lt;br /&gt;
        }&lt;br /&gt;
    #ifdef CL_INST&lt;br /&gt;
        if ((rc = clDataTapInit(DATA_TAP_DEFAULT_FLAGS, 103)) != SA_AIS_OK)&lt;br /&gt;
        {&lt;br /&gt;
            clprintf(CL_LOG_SEV_ERROR,&amp;quot;%s: Failed [0x%x] to initialize data tap&amp;quot;,&lt;br /&gt;
                    appname, rc);&lt;br /&gt;
        }&lt;br /&gt;
    #endif&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
The above software in &amp;lt;code&amp;gt;clCompAppMain.c&amp;lt;/code&amp;gt; is new to csa103. The call to &amp;lt;code&amp;gt;checkpoint_initialize&amp;lt;/code&amp;gt; is pretty straightforward.  This function discussed in detail later within this section.  The call to &amp;lt;code&amp;gt;checkpoint_read_seq&amp;lt;/code&amp;gt; is also pretty straightforward.  It reads the current sequence value from the checkpoint (at this point it should be zero) and loads it into the variable: &amp;lt;code&amp;gt;seq&amp;lt;/code&amp;gt;.  It is important to note the call to &amp;lt;code&amp;gt;checkpont_finalize&amp;lt;/code&amp;gt; if the call to &amp;lt;code&amp;gt;checkpoint_read_seq&amp;lt;/code&amp;gt; does not return &amp;lt;code&amp;gt;CL_OK&amp;lt;/code&amp;gt;.  This call closes the checkpoint and cleanly finalizes the checkpoint library.  We'll look more at &amp;lt;code&amp;gt;checkpoint_read_seq&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;checkpoint_finalize&amp;lt;/code&amp;gt; later.&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffccaa;&amp;quot; align=&amp;quot;center&amp;quot;| clCompAppMain.c&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
        /* Checkpoint new sequence number */&lt;br /&gt;
        rc = checkpoint_write_seq(seq);&lt;br /&gt;
        if (rc != SA_AIS_OK)&lt;br /&gt;
        {&lt;br /&gt;
            clprintf(CL_LOG_SEV_ERROR,&amp;quot;%s: ERROR: Checkpoint write failed. Exiting.&amp;quot;, appname);&lt;br /&gt;
            break;&lt;br /&gt;
        }&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
The rest of the csa103's main loop is the same as the main loop in csa102, but the seven lines above are new.  Here we write the new value of the checkpoint variable to the checkpoint section and print and error if this fails.  We'll look closer at &amp;lt;code&amp;gt;checkpoint_write_seq&amp;lt;/code&amp;gt; later.&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffccaa;&amp;quot; align=&amp;quot;center&amp;quot;| clCompAppMain.c&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
    ClRcT&lt;br /&gt;
    clCompAppAMFCSISet(&lt;br /&gt;
        ClInvocationT       invocation,&lt;br /&gt;
        const ClNameT       *compName,&lt;br /&gt;
        ClAmsHAStateT       haState,&lt;br /&gt;
        ClAmsCSIDescriptorT csiDescriptor)&lt;br /&gt;
    {    &lt;br /&gt;
        /*&lt;br /&gt;
         * ---BEGIN_APPLICATION_CODE--- &lt;br /&gt;
         */&lt;br /&gt;
        ClCharT     compname[100]={0};&lt;br /&gt;
&lt;br /&gt;
        /*&lt;br /&gt;
         * ---END_APPLICATION_CODE---&lt;br /&gt;
         */&lt;br /&gt;
&lt;br /&gt;
        /*&lt;br /&gt;
         * Print information about the CSI Set&lt;br /&gt;
         */&lt;br /&gt;
        strncpy(compname, compName-&amp;gt;value, compName-&amp;gt;length);&lt;br /&gt;
&lt;br /&gt;
        clprintf (CL_LOG_SEV_INFO, &amp;quot;Component [%s] : PID [%d]. CSI Set Received&amp;quot;, &lt;br /&gt;
              compname, (int)mypid);&lt;br /&gt;
&lt;br /&gt;
        clCompAppAMFPrintCSI(csiDescriptor, haState);&lt;br /&gt;
    &lt;br /&gt;
        /*&lt;br /&gt;
          Take appropriate action based on state&lt;br /&gt;
        */&lt;br /&gt;
    &lt;br /&gt;
        switch ( haState )&lt;br /&gt;
        {&lt;br /&gt;
            case CL_AMS_HA_STATE_ACTIVE:&lt;br /&gt;
            {&lt;br /&gt;
                /*&lt;br /&gt;
                  AMF has requested application to take the active HA state&lt;br /&gt;
                  for the CSI.&lt;br /&gt;
                */&lt;br /&gt;
    &lt;br /&gt;
                /*&lt;br /&gt;
                  ---BEGIN_APPLICATION_CODE---&lt;br /&gt;
                */&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffccaa;&amp;quot; align=&amp;quot;center&amp;quot;| clCompAppMain.c&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;   &lt;br /&gt;
                clprintf(CL_LOG_SEV_INFO,&amp;quot;%s: Active state requested from state %d&amp;quot;,&lt;br /&gt;
                        appname, ha_state);&lt;br /&gt;
&lt;br /&gt;
                if (ha_state == SA_AMF_HA_STANDBY)&lt;br /&gt;
                {&lt;br /&gt;
                    /* Read checkpoint, make our replica the active replica */&lt;br /&gt;
                    clprintf(CL_LOG_SEV_INFO,&amp;quot;%s reading checkpoint&amp;quot;, appname);&lt;br /&gt;
                    rc = checkpoint_read_seq(&amp;amp;seq);&lt;br /&gt;
                    clprintf(CL_LOG_SEV_INFO,&amp;quot;%s read checkpoint: seq = %u&amp;quot;, appname, seq);&lt;br /&gt;
                }&lt;br /&gt;
                checkpoint_replica_activate();            &lt;br /&gt;
                ha_state = SA_AMF_HA_ACTIVE;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
                /*&lt;br /&gt;
                 * ---END_APPLICATION_CODE---&lt;br /&gt;
                 */&lt;br /&gt;
&lt;br /&gt;
                clCpmResponse(cpmHandle, invocation, CL_OK);&lt;br /&gt;
                break;&lt;br /&gt;
            }&lt;br /&gt;
&lt;br /&gt;
            case CL_AMS_HA_STATE_STANDBY:&lt;br /&gt;
            {&lt;br /&gt;
                /*&lt;br /&gt;
                 * AMF has requested application to take the standby HA state &lt;br /&gt;
                 * for this CSI.&lt;br /&gt;
                 */&lt;br /&gt;
&lt;br /&gt;
                /*&lt;br /&gt;
                 * ---BEGIN_APPLICATION_CODE---&lt;br /&gt;
                 */&lt;br /&gt;
&lt;br /&gt;
                 clprintf(CL_LOG_SEV_INFO,&amp;quot; Standby state requested from state %d&amp;quot;,ha_state);&lt;br /&gt;
            &lt;br /&gt;
                 ha_state = SA_AMF_HA_STANDBY;&lt;br /&gt;
&lt;br /&gt;
                /*&lt;br /&gt;
                 * ---END_APPLICATION_CODE---&lt;br /&gt;
                 */&lt;br /&gt;
&lt;br /&gt;
                clCpmResponse(cpmHandle, invocation, CL_OK);&lt;br /&gt;
                break;&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffccaa;&amp;quot; align=&amp;quot;center&amp;quot;| clCompAppMain.c&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;    &lt;br /&gt;
            case CL_AMS_HA_STATE_QUIESCED:&lt;br /&gt;
            {&lt;br /&gt;
                /*&lt;br /&gt;
                 * AMF has requested application to quiesce the CSI currently&lt;br /&gt;
                 * assigned the active or quiescing HA state. The application &lt;br /&gt;
                 * must stop work associated with the CSI immediately.&lt;br /&gt;
                 */&lt;br /&gt;
&lt;br /&gt;
                /*&lt;br /&gt;
                 * ---BEGIN_APPLICATION_CODE---&lt;br /&gt;
                 */&lt;br /&gt;
&lt;br /&gt;
                clprintf(CL_LOG_SEV_INFO,&amp;quot;%s: QUIESCED&amp;quot;, appname);&lt;br /&gt;
                ha_state = haState;&lt;br /&gt;
&lt;br /&gt;
                /*&lt;br /&gt;
                 * ---END_APPLICATION_CODE---&lt;br /&gt;
                 */&lt;br /&gt;
&lt;br /&gt;
                clCpmResponse(cpmHandle, invocation, CL_OK);&lt;br /&gt;
                break;&lt;br /&gt;
            }&lt;br /&gt;
&lt;br /&gt;
            case CL_AMS_HA_STATE_QUIESCING:&lt;br /&gt;
            { &lt;br /&gt;
                /*&lt;br /&gt;
                 * AMF has requested application to quiesce the CSI currently&lt;br /&gt;
                 * assigned the active HA state. The application must stop work&lt;br /&gt;
                 * associated with the CSI gracefully and not accept any new&lt;br /&gt;
                 * workloads while the work is being terminated.&lt;br /&gt;
                 */&lt;br /&gt;
&lt;br /&gt;
                /*&lt;br /&gt;
                 * ---BEGIN_APPLICATION_CODE---&lt;br /&gt;
                 */&lt;br /&gt;
&lt;br /&gt;
                clprintf(CL_LOG_SEV_INFO,&amp;quot;%s: QUIESCING&amp;quot;, appname);&lt;br /&gt;
                ha_state = haState;&lt;br /&gt;
&lt;br /&gt;
                /*&lt;br /&gt;
                 * ---END_APPLICATION_CODE---&lt;br /&gt;
                 */&lt;br /&gt;
&lt;br /&gt;
                clCpmCSIQuiescingComplete(cpmHandle, invocation, CL_OK);&lt;br /&gt;
                break;&lt;br /&gt;
            }&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffccaa;&amp;quot; align=&amp;quot;center&amp;quot;| clCompAppMain.c&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
            default:&lt;br /&gt;
            {&lt;br /&gt;
                break;&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
    &lt;br /&gt;
        return CL_OK;&lt;br /&gt;
    }&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now looking at csa103's implementation of &amp;lt;code&amp;gt;clCompAppAMFCSISet&amp;lt;/code&amp;gt;, we see that rather than just a few cases, we handle several cases: &amp;lt;code&amp;gt;QUIESCING&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;QUIESCED&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;ACTIVE&amp;lt;/code&amp;gt;, and  &amp;lt;code&amp;gt;STANDBY&amp;lt;/code&amp;gt;.  In each state, the global variable &amp;lt;code&amp;gt;ha_state&amp;lt;/code&amp;gt; to the new_state value that is passed in is set.  This is similar to csa102, except that we add the feature that in the &amp;lt;code&amp;gt;CL_AMS_HA_STATE_ACTIVE&amp;lt;/code&amp;gt; case if our previous state was &amp;lt;code&amp;gt;CL_AMS_HA_STATE_STANDBY&amp;lt;/code&amp;gt; we read the sequence from the checkpoint so that the main loop will pick it up.&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffccaa;&amp;quot; align=&amp;quot;center&amp;quot;| clCompAppMain.c&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
    static ClRcT&lt;br /&gt;
    checkpoint_initialize()&lt;br /&gt;
    {&lt;br /&gt;
        SaAisErrorT      rc = CL_OK;&lt;br /&gt;
        SaVersionT ckpt_version = {'B', 1, 1};&lt;br /&gt;
        SaNameT    ckpt_name = { strlen(CKPT_NAME), CKPT_NAME };&lt;br /&gt;
        ClUint32T  seq_no;&lt;br /&gt;
        SaCkptCheckpointCreationAttributesT create_atts = {&lt;br /&gt;
            .creationFlags     = SA_CKPT_WR_ACTIVE_REPLICA_WEAK |&lt;br /&gt;
                             SA_CKPT_CHECKPOINT_COLLOCATED,&lt;br /&gt;
            .checkpointSize    = sizeof(ClUint32T),&lt;br /&gt;
            .retentionDuration = (ClTimeT)10,&lt;br /&gt;
            .maxSections       = 2, // two sections &lt;br /&gt;
            .maxSectionSize    = sizeof(ClUint32T),&lt;br /&gt;
            .maxSectionIdSize  = (ClSizeT)64&lt;br /&gt;
&lt;br /&gt;
        &lt;br /&gt;
        };&lt;br /&gt;
        SaCkptSectionCreationAttributesT section_atts = {&lt;br /&gt;
        .sectionId = &amp;amp;ckpt_sid,&lt;br /&gt;
        .expirationTime = SA_TIME_END&lt;br /&gt;
&lt;br /&gt;
        };&lt;br /&gt;
 &lt;br /&gt;
        clprintf(CL_LOG_SEV_INFO,&amp;quot;%s: checkpoint_initialize&amp;quot;, appname);&lt;br /&gt;
        /* Initialize checkpointing service instance */&lt;br /&gt;
        rc = saCkptInitialize(&amp;amp;ckpt_svc_handle,	/* Checkpoint service handle */&lt;br /&gt;
						  NULL,			    /* Optional callbacks table */&lt;br /&gt;
						  &amp;amp;ckpt_version);   /* Required verison number */&lt;br /&gt;
        if (rc != SA_AIS_OK)&lt;br /&gt;
        {&lt;br /&gt;
            clprintf(CL_LOG_SEV_ERROR,&amp;quot;%s: ERROR: Failed to initialize checkpoint service&amp;quot;,&lt;br /&gt;
                    appname);&lt;br /&gt;
            return rc;&lt;br /&gt;
        }&lt;br /&gt;
        clprintf(CL_LOG_SEV_INFO,&amp;quot;%s: Checkpoint service initialized (handle=0x%llx)&amp;quot;,&lt;br /&gt;
           appname, ckpt_svc_handle);&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Here is &amp;lt;code&amp;gt;checkpoint_initialize&amp;lt;/code&amp;gt;.  Here we initialize the &amp;lt;code&amp;gt;ClNameT&amp;lt;/code&amp;gt; structure that holds the name of the checkpoint to be opened/created with the line: &amp;lt;code&amp;gt;ClNameT    ckpt_name = { strlen(CKPT_NAME), CKPT_NAME };&amp;lt;/code&amp;gt;. We then define a set of attributes to associate with the checkpoint when creating that checkpoint. The &amp;lt;code&amp;gt;creationFlags&amp;lt;/code&amp;gt; includes &amp;lt;code&amp;gt;CL_CKPT_WR_ACTIVE_REPLICA&amp;lt;/code&amp;gt;.  This means that the checkpoint to be created will be asynchronous, or once active server updation is completed, the call returns to the application, all other replica updates happens parallel. &amp;lt;code&amp;gt;CheckpointSize&amp;lt;/code&amp;gt; is set to the sizeof a 32 bit unsigned integer, which is the sequence number we print in the main loop.  The &amp;lt;code&amp;gt;retentionDuration&amp;lt;/code&amp;gt; is the time that the checkpoint service will keep the checkpoint in store after the last client has closed the checkpoint.  &amp;lt;code&amp;gt;MaxSections&amp;lt;/code&amp;gt; is 2 as this checkpoint will be used to store two sections.  &amp;lt;code&amp;gt;MaxSectionSize&amp;lt;/code&amp;gt; is the set to the sizeof a 32 bit unsigned integer, as application stores only unsigned integer. And &amp;lt;code&amp;gt;maxSectionIdSize&amp;lt;/code&amp;gt; is 64 bytes.&lt;br /&gt;
&lt;br /&gt;
We next use &amp;lt;code&amp;gt;ClCkptSectionCreationAttributesT section_atts&amp;lt;/code&amp;gt; to define the creation attributes for the sole section of the checkpoint. The &amp;lt;code&amp;gt;sectionId&amp;lt;/code&amp;gt; is just the name of the section along with the number of bytes in the name.  The &amp;lt;code&amp;gt;expirationTime&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;CL_TIME_END&amp;lt;/code&amp;gt; to imply that the section is never deleted automatically if the checkpoint itself still remains.&lt;br /&gt;
&lt;br /&gt;
The call to &amp;lt;code&amp;gt;clCkptInitialize&amp;lt;/code&amp;gt; has to be called before any other checkpoint functions.  The &amp;lt;code&amp;gt;ckpt_svc_handle&amp;lt;/code&amp;gt; is where the handle is returned.  The handle must be passed to some future checkpoint api calls, namely the &amp;lt;code&amp;gt;clCkptCheckpointOpen&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;clCkptFinalize&amp;lt;/code&amp;gt; calls.  The callbacks table is passed as &amp;lt;code&amp;gt;NULL&amp;lt;/code&amp;gt; which implies that our application doesn't provide any callbacks.  Finally the &amp;lt;code&amp;gt;ckpt_version&amp;lt;/code&amp;gt; identifies what version of the api this application is written to.&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffccaa;&amp;quot; align=&amp;quot;center&amp;quot;| clCompAppMain.c&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
        //&lt;br /&gt;
        // Create the checkpoint for read and write.            &lt;br /&gt;
&lt;br /&gt;
        rc = saCkptCheckpointOpen(ckpt_svc_handle,      // Service handle&lt;br /&gt;
                              &amp;amp;ckpt_name,         // Checkpoint name&lt;br /&gt;
                              &amp;amp;create_atts,       // Optional creation attr.&lt;br /&gt;
                              (SA_CKPT_CHECKPOINT_READ |&lt;br /&gt;
                               SA_CKPT_CHECKPOINT_WRITE |&lt;br /&gt;
                               SA_CKPT_CHECKPOINT_CREATE),&lt;br /&gt;
                              (SaTimeT)-1,        // No timeout&lt;br /&gt;
                              &amp;amp;ckpt_handle);      // Checkpoint handle&lt;br /&gt;
&lt;br /&gt;
        if (rc != SA_AIS_OK)&lt;br /&gt;
&lt;br /&gt;
        {&lt;br /&gt;
            clprintf(CL_LOG_SEV_ERROR,&amp;quot;%s: ERROR: Failed [0x%x] to open checkpoint&amp;quot;,&lt;br /&gt;
                    appname, rc);&lt;br /&gt;
            (void)saCkptFinalize(ckpt_svc_handle);&lt;br /&gt;
            return rc;&lt;br /&gt;
        }&lt;br /&gt;
        clprintf(CL_LOG_SEV_INFO,&amp;quot;%s: Checkpoint opened (handle=0x%llx)&amp;quot;, appname, ckpt_handle);&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
 &lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffccaa;&amp;quot; align=&amp;quot;center&amp;quot;| clCompAppMain.c&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
        /*&lt;br /&gt;
         * Try to create a section so that updates can operate by overwriting&lt;br /&gt;
         * the section over and over again.&lt;br /&gt;
         * If subsequent processes come through here, they will fail to create&lt;br /&gt;
         * the section.  That is OK, even though it will cause an error message&lt;br /&gt;
         * If the section create fails because the section is already there, then&lt;br /&gt;
         * read the sequence number&lt;br /&gt;
         */&lt;br /&gt;
        // Put data in network byte order&lt;br /&gt;
        seq_no = htonl(seq);&lt;br /&gt;
&lt;br /&gt;
        // Creating the section&lt;br /&gt;
        checkpoint_replica_activate();&lt;br /&gt;
        rc = saCkptSectionCreate(ckpt_handle,           // Checkpoint handle&lt;br /&gt;
                             &amp;amp;section_atts,         // Section attributes&lt;br /&gt;
                             (SaUint8T*)&amp;amp;seq_no,    // Initial data&lt;br /&gt;
                             (SaSizeT)sizeof(seq_no)); // Size of data&lt;br /&gt;
        if (rc != SA_AIS_OK &amp;amp;&amp;amp; (CL_GET_ERROR_CODE(rc) != SA_AIS_ERR_EXIST))&lt;br /&gt;
        {&lt;br /&gt;
            clprintf(CL_LOG_SEV_ERROR,&amp;quot;%s: ERROR: Failed to create checkpoint section&amp;quot;, appname);&lt;br /&gt;
            (void)saCkptCheckpointClose(ckpt_handle);&lt;br /&gt;
            (void)saCkptFinalize(ckpt_svc_handle);&lt;br /&gt;
            return rc;&lt;br /&gt;
        }&lt;br /&gt;
        else if (rc != SA_AIS_OK &amp;amp;&amp;amp; (CL_GET_ERROR_CODE(rc) == SA_AIS_ERR_EXIST))&lt;br /&gt;
        {&lt;br /&gt;
            rc = checkpoint_read_seq(&amp;amp;seq);&lt;br /&gt;
            if (rc != CL_OK)&lt;br /&gt;
            {&lt;br /&gt;
                clprintf(CL_LOG_SEV_ERROR,&amp;quot;%s: ERROR: Failed [0x%x] to read checkpoint section&amp;quot;,&lt;br /&gt;
                            appname, rc);&lt;br /&gt;
                (void)saCkptCheckpointClose(ckpt_handle);&lt;br /&gt;
                (void)saCkptFinalize(ckpt_svc_handle);&lt;br /&gt;
                return rc;&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
        else&lt;br /&gt;
        {&lt;br /&gt;
            clprintf(CL_LOG_SEV_INFO,&amp;quot;%s: Section created&amp;quot;, appname);&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        return CL_OK;&lt;br /&gt;
    }&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
With &amp;lt;code&amp;gt;rc = clCkptCheckpointOpen&amp;lt;/code&amp;gt; we attempt to open the specified checkpoint.  When &amp;lt;code&amp;gt;checkpoint_initialize&amp;lt;/code&amp;gt; is called the checkpoint may or may not exist.  We attempt to open the checkpoint for READ/WRITE access. &lt;br /&gt;
&lt;br /&gt;
Next we check if we created the checkpoint and then we need to create the section with a call to &amp;lt;code&amp;gt;clCkptSectionCreate&amp;lt;/code&amp;gt;.  We pass the checkpoint handle obtained from &amp;lt;code&amp;gt;clCkptCheckpointOpen&amp;lt;/code&amp;gt;, the section attributes declared earlier, and the address of the initial value along with the size in bytes of the initial value.&lt;br /&gt;
&lt;br /&gt;
We convert the initial value to network byte order by the code &amp;lt;code&amp;gt;seq_no = htonl(seq)&amp;lt;/code&amp;gt;, before passing it to &amp;lt;code&amp;gt;clCkptSectionCreate&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If we do not create the section, then we read the current value in the checkpoint into our global seq variable.&lt;br /&gt;
&lt;br /&gt;
Note that whenever we return an error return code from the function that we have either not opened the checkpoint/initialized the checkpoint service, or we have closed the checkpoint and finalized the checkpoint service with calls to &amp;lt;code&amp;gt;clCkptCheckpointClose&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;clCkptFinalize&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffccaa;&amp;quot; align=&amp;quot;center&amp;quot;| clCompAppMain.c&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
    static ClRcT &lt;br /&gt;
    checkpoint_finalize(void)&lt;br /&gt;
    {&lt;br /&gt;
        SaAisErrorT rc;&lt;br /&gt;
&lt;br /&gt;
        rc = saCkptCheckpointClose(ckpt_handle);&lt;br /&gt;
        if (rc != SA_AIS_OK)&lt;br /&gt;
        {&lt;br /&gt;
            clprintf(CL_LOG_SEV_ERROR,&amp;quot;%s: failed: [0x%x] to close checkpoint handle 0x%llx&amp;quot;,&lt;br /&gt;
                        appname, rc, ckpt_handle);&lt;br /&gt;
        }&lt;br /&gt;
        rc = saCkptFinalize(ckpt_svc_handle);&lt;br /&gt;
        if (rc != SA_AIS_OK)&lt;br /&gt;
        {&lt;br /&gt;
            clprintf(CL_LOG_SEV_ERROR,&amp;quot;%s: failed: [0x%x] to finalize checkpoint&amp;quot;,&lt;br /&gt;
                    appname, rc);&lt;br /&gt;
        }&lt;br /&gt;
        return CL_OK;&lt;br /&gt;
&lt;br /&gt;
    }&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
The above code snippet presents &amp;lt;code&amp;gt;checkpoint_finalize&amp;lt;/code&amp;gt;.  It's quite simple.  First it closes the checkpoint handle with a call to &amp;lt;code&amp;gt;clCkptCheckpointClose&amp;lt;/code&amp;gt;.  Next it finalizes the checkpoint library with a call to &amp;lt;code&amp;gt;clCkptFinalize&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffccaa;&amp;quot; align=&amp;quot;center&amp;quot;| clCompAppMain.c&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
    static ClRcT&lt;br /&gt;
    checkpoint_write_seq(ClUint32T seq)&lt;br /&gt;
    {&lt;br /&gt;
        SaAisErrorT rc = SA_AIS_OK;&lt;br /&gt;
        ClUint32T seq_no;&lt;br /&gt;
&lt;br /&gt;
        /* Putting data in network byte order */&lt;br /&gt;
        seq_no = htonl(seq);&lt;br /&gt;
&lt;br /&gt;
        /* Write checkpoint */&lt;br /&gt;
        retry:&lt;br /&gt;
        rc = saCkptSectionOverwrite(ckpt_handle,&lt;br /&gt;
                                &amp;amp;ckpt_sid,&lt;br /&gt;
                                &amp;amp;seq_no,&lt;br /&gt;
                                sizeof(ClUint32T));&lt;br /&gt;
        if (rc != SA_AIS_OK)&lt;br /&gt;
        {&lt;br /&gt;
            clprintf(CL_LOG_SEV_ERROR,&amp;quot;Failed [0x%x] to write to section&amp;quot;, rc);&lt;br /&gt;
            if(rc == SA_AIS_ERR_NOT_EXIST)&lt;br /&gt;
                rc = checkpoint_replica_activate();&lt;br /&gt;
            if(rc == CL_OK) goto retry;&lt;br /&gt;
        }&lt;br /&gt;
        else&lt;br /&gt;
        {&lt;br /&gt;
            /*&lt;br /&gt;
            * Synchronize the checkpoint to all the replicas.&lt;br /&gt;
            */&lt;br /&gt;
            rc = saCkptCheckpointSynchronize(ckpt_handle, SA_TIME_END );&lt;br /&gt;
            if (rc != SA_AIS_OK)&lt;br /&gt;
            {&lt;br /&gt;
                clprintf(CL_LOG_SEV_ERROR,&amp;quot;Failed [0x%x] to synchronize the checkpoint&amp;quot;, rc);&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        return CL_OK;&lt;br /&gt;
     }&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
With &amp;lt;code&amp;gt;checkpoint_write_seq&amp;lt;/code&amp;gt; we first convert the sequence number passed into network byte order.  Then we pass it to &amp;lt;code&amp;gt;clCKptSectionOverwrite&amp;lt;/code&amp;gt; which writes it to the checkpoint section created in &amp;lt;code&amp;gt;checkpoint_initialize&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffccaa;&amp;quot; align=&amp;quot;center&amp;quot;| clCompAppMain.c&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
    static ClRcT&lt;br /&gt;
    checkpoint_read_seq(ClUint32T *seq)&lt;br /&gt;
    {&lt;br /&gt;
        ClRcT rc = CL_OK;&lt;br /&gt;
        ClUint32T err_idx; /* Error index in ioVector */&lt;br /&gt;
        ClUint32T seq_no = 0xffffffff;&lt;br /&gt;
        SaCkptIOVectorElementT iov = {&lt;br /&gt;
            .sectionId  = ckpt_sid,&lt;br /&gt;
            .dataBuffer = (ClPtrT)&amp;amp;seq_no,&lt;br /&gt;
            .dataSize   = sizeof(ClUint32T),&lt;br /&gt;
            .dataOffset = (ClOffsetT)0,&lt;br /&gt;
            .readSize   = sizeof(ClUint32T)&lt;br /&gt;
        };&lt;br /&gt;
&lt;br /&gt;
        rc = saCkptCheckpointRead(ckpt_handle, &amp;amp;iov, 1, &amp;amp;err_idx);&lt;br /&gt;
        if (rc != SA_AIS_OK)&lt;br /&gt;
        {&lt;br /&gt;
           clprintf(CL_LOG_SEV_ERROR,&amp;quot;Error: [0x%x] from checkpoint read, err_idx = %u&amp;quot;,&lt;br /&gt;
                    rc, err_idx);&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        /* FIXME: How to process this err_idx? */&lt;br /&gt;
        *seq = ntohl(seq_no);&lt;br /&gt;
&lt;br /&gt;
        return CL_OK;&lt;br /&gt;
&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
With &amp;lt;code&amp;gt;checkpoint_read_seq&amp;lt;/code&amp;gt; we initialize &amp;lt;code&amp;gt;seq_no&amp;lt;/code&amp;gt; to all ones just so it will be more obvious if the &amp;lt;code&amp;gt;clCkptCheckpointRead&amp;lt;/code&amp;gt; call fails and the value of &amp;lt;code&amp;gt;seq_no&amp;lt;/code&amp;gt; doesn't get overwritten.  Then, we set up the &amp;lt;code&amp;gt;iov&amp;lt;/code&amp;gt; variable.  We set the &amp;lt;code&amp;gt;sectionID&amp;lt;/code&amp;gt;  field to &amp;lt;code&amp;gt;ckpt_sid&amp;lt;/code&amp;gt; which is the id of the section created in &amp;lt;code&amp;gt;checkpoint_initialize&amp;lt;/code&amp;gt;.  The &amp;lt;code&amp;gt;dataBuffer&amp;lt;/code&amp;gt; gets set to the address of the &amp;lt;code&amp;gt;seq_no&amp;lt;/code&amp;gt; variable which is where we want the checkpoint data loaded.  The &amp;lt;code&amp;gt;dataSize&amp;lt;/code&amp;gt; field is set to the the size of the &amp;lt;code&amp;gt;seq_no&amp;lt;/code&amp;gt; variable.  &amp;lt;code&amp;gt;DataOfset&amp;lt;/code&amp;gt; is set to zero since the sequence number is the only thing stored in the section, so it resides at the front of the section.  &amp;lt;code&amp;gt;readSize&amp;lt;/code&amp;gt; is set to the size of the sequence number variable.&lt;br /&gt;
&lt;br /&gt;
Within &amp;lt;code&amp;gt;checkpoint_read_seq&amp;lt;/code&amp;gt; we pass the iovector to &amp;lt;code&amp;gt;clCkptCheckpointRead&amp;lt;/code&amp;gt; along with the &amp;lt;code&amp;gt;ckpt_handle&amp;lt;/code&amp;gt;, the constant 1, and the address of the &amp;lt;code&amp;gt;err_idx&amp;lt;/code&amp;gt; variable.  The constant 1 is the number of elements in the array of &amp;lt;code&amp;gt;ClCkptIOVectorElementT structs&amp;lt;/code&amp;gt; that we're passing.  That is, we're passing the address of a single &amp;lt;code&amp;gt;ClCkptIOVectorElementT struct&amp;lt;/code&amp;gt;.  The &amp;lt;code&amp;gt;err_idx&amp;lt;/code&amp;gt; will hold the index in that array where &amp;lt;code&amp;gt;clCkptCheckpointRead&amp;lt;/code&amp;gt; found an error.  That is, if there is going to be an error, it will be at index 0 since we're only passing on entry in the &amp;lt;code&amp;gt;iovector&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffccaa;&amp;quot; align=&amp;quot;center&amp;quot;| clCompAppMain.c&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    static ClRcT&lt;br /&gt;
    checkpoint_replica_activate(void)&lt;br /&gt;
    {&lt;br /&gt;
        SaAisErrorT rc = SA_AIS_OK;&lt;br /&gt;
&lt;br /&gt;
        if ((rc = saCkptActiveReplicaSet(ckpt_handle)) != SA_AIS_OK)&lt;br /&gt;
        {&lt;br /&gt;
            clprintf(CL_LOG_SEV_ERROR,&lt;br /&gt;
                    &amp;quot;checkpoint_replica_activate failed [0x%x] in ActiveReplicaSet&amp;quot;,&lt;br /&gt;
                    rc);&lt;br /&gt;
        }&lt;br /&gt;
        else rc = CL_OK;&lt;br /&gt;
&lt;br /&gt;
        return rc;&lt;br /&gt;
    }&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===csa203===&lt;br /&gt;
&lt;br /&gt;
csa203 demonstrates the usage of SA Forum's Checkpointing service. This sample application does not deviate functionally from csa103. The code differences are due to using SA Forum data types (structures) and APIs , as presented in the following two tables. (Note we have not repeated data types and APIs covered previously.)&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|+align=&amp;quot;bottom&amp;quot;| '''SA Forum Data Types with the SAFplus Platform equivalent'''&lt;br /&gt;
|- style=&amp;quot;color:black;background-color:#ffffaa;&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
!SA Forum Data Types   &lt;br /&gt;
!OpenClovis Data Types&lt;br /&gt;
|-&lt;br /&gt;
|SaCkptHandleT&lt;br /&gt;
|ClCkptSvcHdlT&lt;br /&gt;
|-&lt;br /&gt;
|SaCkptHandleT&lt;br /&gt;
|ClCkptHdlT&lt;br /&gt;
|-&lt;br /&gt;
|SaCkptSectionIdT&lt;br /&gt;
|ClCkptSectionIdT&lt;br /&gt;
|-&lt;br /&gt;
|SaCkptCheckpointCreationAttributesT&lt;br /&gt;
|ClCkptCheckpointCreationAttributesT&lt;br /&gt;
|-&lt;br /&gt;
|SaCkptSectionCreationAttributesT&lt;br /&gt;
|ClCkptSectionCreationAttributesT&lt;br /&gt;
|-&lt;br /&gt;
|SaCkptIOVectorElementT&lt;br /&gt;
|ClCkptIOVectorElementT&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|+align=&amp;quot;bottom&amp;quot;| '''SA Forum APIs with the SAFplus Platform equivalent'''&lt;br /&gt;
|- style=&amp;quot;color:black;background-color:#ffffaa;&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
!SA Forum APIs&lt;br /&gt;
!OpenClovis APIs&lt;br /&gt;
|-&lt;br /&gt;
|saCkptInitialize&lt;br /&gt;
|clCkptInitialize&lt;br /&gt;
|-&lt;br /&gt;
|saCkptCheckpointOpen&lt;br /&gt;
|clCkptCheckpointOpen&lt;br /&gt;
|-&lt;br /&gt;
|saCkptSectionCreate&lt;br /&gt;
|clCkptSectionCreate&lt;br /&gt;
|-&lt;br /&gt;
|saCkptCheckpointClose&lt;br /&gt;
|clCkptCheckpointClose&lt;br /&gt;
|-&lt;br /&gt;
|saCkptFinalize&lt;br /&gt;
|clCkptFinalize&lt;br /&gt;
|-&lt;br /&gt;
|saCkptSectionOverwrite&lt;br /&gt;
|clCkptSectionOverwrite&lt;br /&gt;
|-&lt;br /&gt;
|saCkptCheckpointSynchronize&lt;br /&gt;
|clCkptCheckpointSynchronize&lt;br /&gt;
|-&lt;br /&gt;
|saCkptCheckpointRead&lt;br /&gt;
|clCkptCheckpointRead&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===How to Run csa103 and What to Observe===&lt;br /&gt;
&lt;br /&gt;
This sample application can run on all Runtime Hardware Setups. The following, lists which node &amp;lt;code&amp;gt;csa103compI*&amp;lt;/code&amp;gt; runs on.&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;'''Runtime Hardware Setup 1.1 and 2.1'''&lt;br /&gt;
&amp;lt;br&amp;gt;csa103compI0 and csa103compI1 will run upon the single node.&lt;br /&gt;
&amp;lt;li&amp;gt;'''Runtime Hardware Setup 1.2 and 2.2'''&lt;br /&gt;
&amp;lt;br&amp;gt;csa103compI0 runs on PayloadNodeI0 and csa103compI1 runs on PayloadNodeI1&lt;br /&gt;
&amp;lt;li&amp;gt;'''Runtime Hardware Setup 1.3 and 2.3'''&lt;br /&gt;
&amp;lt;br&amp;gt;csa103compI2 and csa103compI3 run on SCNodeI0 and SCNodeI1 respectively. csa103compI0 and csa103compI1 run on PayloadNodeI0 and PayloadNodeI1 respectively.&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;In the four node set up SCNodeI0 and SCNodeI1 output data via &amp;lt;code&amp;gt;/root/asp/var/log/csa103CompI2&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;/root/asp/var/log/csa103CompI3&amp;lt;/code&amp;gt; respectively. Therefore in this case follow the below instructions replacing csa103CompI0 and csa103compI1 with csa103compI2 and csa103compI3 respectively.&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We run csa103 very much the same way we run any of the rest of the sample applications: with the SAFplus Platform Console.&lt;br /&gt;
  &lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;First, on the active System Controller move it to state LockAssignment with (Unlock csa203SGI0 instead of csa103SGI0 to run csa203)&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
cli[Test]-&amp;gt; setc 1&lt;br /&gt;
cli[Test:SCNodeI0]-&amp;gt; setc cpm&lt;br /&gt;
cli[Test:SCNodeI0:CPM]-&amp;gt; amsLockAssignment sg csa103SGI0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The following output is given when you run &amp;lt;code&amp;gt;tail -f&amp;lt;/code&amp;gt; on the csa103 log files. For example:&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
# tail -f /root/asp/var/log/csa103CompI0.log&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffffaa;&amp;quot; align=&amp;quot;center&amp;quot;| /root/asp/var/log/csa103CompI0Log.latest&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
Mon Jul 14 00:01:09 2008   (SCNodeI0.15238 : csa103CompEO.---.---.00030 :   INFO)&lt;br /&gt;
 Component [csa103CompI0] : PID [15238]. Initializing&lt;br /&gt;
Mon Jul 14 00:01:09 2008   (SCNodeI0.15238 : csa103CompEO.---.---.00031 :   INFO)&lt;br /&gt;
    IOC Address             : 0x1&lt;br /&gt;
Mon Jul 14 00:01:09 2008   (SCNodeI0.15238 : csa103CompEO.---.---.00032 :   INFO)&lt;br /&gt;
    IOC Port                : 0x81&lt;br /&gt;
Mon Jul 14 00:01:09 2008   (SCNodeI0.15238 : csa103CompEO.---.---.00033 :   INFO)&lt;br /&gt;
 csa103: Instantiated as component instance csa103CompI0.&lt;br /&gt;
Mon Jul 14 00:01:09 2008   (SCNodeI0.15238 : csa103CompEO.---.---.00034 :   INFO)&lt;br /&gt;
 csa103CompI0: Waiting for CSI assignment...&lt;br /&gt;
Mon Jul 14 00:01:09 2008   (SCNodeI0.15238 : csa103CompEO.---.---.00035 :   INFO)&lt;br /&gt;
 csa103CompI0: Waiting for CSI assignment...&lt;br /&gt;
Mon Jul 14 00:01:09 2008   (SCNodeI0.15238 : csa103CompEO.---.---.00036 :   INFO)&lt;br /&gt;
 csa103CompI0: checkpoint_initialize&lt;br /&gt;
Mon Jul 14 00:01:10 2008   (SCNodeI0.15238 : csa103CompEO.---.---.00043 :   INFO)&lt;br /&gt;
 csa103CompI0: Checkpoint service initialized (handle=0x1)&lt;br /&gt;
Mon Jul 14 00:01:10 2008   (SCNodeI0.15238 : csa103CompEO.---.---.00045 :   INFO)&lt;br /&gt;
 csa103CompI0: Checkpoint opened (handle=0x2)&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
# tail -f /root/asp/var/log/csa103CompI1.log&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffffaa;&amp;quot; align=&amp;quot;center&amp;quot;| /root/asp/var/log/csa103CompI1Log.latest&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
Mon Jul 14 00:01:09 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00030 :   INFO)&lt;br /&gt;
 Component [csa103CompI1] : PID [15234]. Initializing&lt;br /&gt;
Mon Jul 14 00:01:09 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00031 :   INFO)&lt;br /&gt;
    IOC Address             : 0x1&lt;br /&gt;
Mon Jul 14 00:01:09 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00032 :   INFO)&lt;br /&gt;
    IOC Port                : 0x80&lt;br /&gt;
Mon Jul 14 00:01:09 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00033 :   INFO)&lt;br /&gt;
 csa103: Instantiated as component instance csa103CompI1.&lt;br /&gt;
Mon Jul 14 00:01:09 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00034 :   INFO)&lt;br /&gt;
 csa103CompI1: Waiting for CSI assignment...&lt;br /&gt;
Mon Jul 14 00:01:09 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00035 :   INFO)&lt;br /&gt;
 csa103CompI1: Waiting for CSI assignment...&lt;br /&gt;
Mon Jul 14 00:01:09 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00036 :   INFO)&lt;br /&gt;
 csa103CompI1: checkpoint_initialize&lt;br /&gt;
Mon Jul 14 00:01:09 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00043 :   INFO)&lt;br /&gt;
 csa103CompI1: Checkpoint service initialized (handle=0x1)&lt;br /&gt;
Mon Jul 14 00:01:09 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00045 :   INFO)&lt;br /&gt;
 csa103CompI1: Checkpoint opened (handle=0x2)&lt;br /&gt;
Mon Jul 14 00:01:09 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00053 :   INFO)&lt;br /&gt;
 csa103CompI1: Section created&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;Then, unlock the application by running &lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
cli[Test:SCNodeI0:CPM]-&amp;gt; amsUnlock sg csa103SGI0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the application log files, you should see &lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffffaa;&amp;quot; align=&amp;quot;center&amp;quot;| /root/asp/var/log/csa103CompI0Log.latest&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
Mon Jul 14 00:09:08 2008   (SCNodeI0.15238 : csa103CompEO.---.---.00058 :   INFO)&lt;br /&gt;
  Standby state requested from state 0&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffffaa;&amp;quot; align=&amp;quot;center&amp;quot;| /root/asp/var/log/csa103CompI1Log.latest&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
Mon Jul 14 00:09:08 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00064 :   INFO)&lt;br /&gt;
 csa103CompI1: Active state requested from state 0&lt;br /&gt;
Mon Jul 14 00:09:09 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00065 :   INFO)&lt;br /&gt;
 csa103CompI1: Hello World! (seq=0)&lt;br /&gt;
Mon Jul 14 00:09:10 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00066 :   INFO)&lt;br /&gt;
 csa103CompI1: Hello World! (seq=1)&lt;br /&gt;
Mon Jul 14 00:09:11 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00067 :   INFO)&lt;br /&gt;
 csa103CompI1: Hello World! (seq=2)&lt;br /&gt;
Mon Jul 14 00:09:12 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00068 :   INFO)&lt;br /&gt;
 csa103CompI1: Hello World! (seq=3)&lt;br /&gt;
Mon Jul 14 00:09:13 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00069 :   INFO)&lt;br /&gt;
 csa103CompI1: Hello World! (seq=4)&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;Next, find the active csa103 process, the one that's printing the Hello World lines and kill it.  To find the process ID issue the following command from a bash shell.&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
 # ps -eaf | grep csa103&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
This should produce an output that looks similar to the following.&lt;br /&gt;
 root     17830 15663  0 14:21 ?        00:00:00 csa103Comp -p&lt;br /&gt;
 root     17839 15663  0 14:21 ?        00:00:00 csa103Comp -p&lt;br /&gt;
 root     18558 16145  0 14:32 pts/4    00:00:00 grep csa103&lt;br /&gt;
Notice the two entries that end with csa103Comp -p. These are our two component processes. The first one is usually the active process. This is the one that we will kill. In this case the process ID is 17830. So to kill the active component you issue the command:&lt;br /&gt;
&lt;br /&gt;
 # kill -9 17830&lt;br /&gt;
&lt;br /&gt;
[[File:OpenClovis_Note.png]]If this step does not result in the active component being killed then it is likely that the standby component was killed. In this case simply try killing the other process. &lt;br /&gt;
&lt;br /&gt;
After killing the active component you should see lines in the log files like the following:&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffffaa;&amp;quot; align=&amp;quot;center&amp;quot;| /root/asp/var/log/csa103CompI1Log.latest&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
Mon Jul 14 00:16:43 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00515 :   INFO)&lt;br /&gt;
 csa103CompI1: Hello World! (seq=452)&lt;br /&gt;
Mon Jul 14 00:16:44 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00516 :   INFO)&lt;br /&gt;
 csa103CompI1: Hello World! (seq=453)&lt;br /&gt;
Mon Jul 14 00:16:45 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00517 :   INFO)&lt;br /&gt;
 csa103CompI1: Hello World! (seq=454)&lt;br /&gt;
Mon Jul 14 00:16:46 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00518 :   INFO)&lt;br /&gt;
 csa103CompI1: Hello World! (seq=455)&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffffaa;&amp;quot; align=&amp;quot;center&amp;quot;| /var/log/csa103CompI0Log.latest&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
Mon Jul 14 00:16:48 2008   (SCNodeI0.15238 : csa103CompEO.---.---.00065 :   INFO)&lt;br /&gt;
 csa103CompI0: Active state requested from state 2&lt;br /&gt;
Mon Jul 14 00:16:48 2008   (SCNodeI0.15238 : csa103CompEO.---.---.00066 :   INFO)&lt;br /&gt;
 csa103CompI0 reading checkpoint&lt;br /&gt;
Mon Jul 14 00:16:48 2008   (SCNodeI0.15238 : csa103CompEO.---.---.00067 :   INFO)&lt;br /&gt;
 csa103CompI0 read checkpoint: seq = 456&lt;br /&gt;
Mon Jul 14 00:16:49 2008   (SCNodeI0.15238 : csa103CompEO.---.---.00068 :   INFO)&lt;br /&gt;
 csa103CompI0: Hello World! (seq=456)&lt;br /&gt;
Mon Jul 14 00:16:50 2008   (SCNodeI0.15238 : csa103CompEO.---.---.00069 :   INFO)&lt;br /&gt;
 csa103CompI0: Hello World! (seq=457)&lt;br /&gt;
Mon Jul 14 00:16:51 2008   (SCNodeI0.15238 : csa103CompEO.---.---.00070 :   INFO)&lt;br /&gt;
 csa103CompI0: Hello World! (seq=458)&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
Where we can see CompI1 printing 455 and then dieing, where upon CompI0 gets the notice to take over processing, reads the checkpoint and then takes over with seq=456 and so on.&lt;br /&gt;
&lt;br /&gt;
Then, in the CompI1 log file we see:&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffffaa;&amp;quot; align=&amp;quot;center&amp;quot;| /root/asp/var/log/csa103CompI1Log.latest&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
Mon Jul 14 00:16:49 2008   (SCNodeI0.15553 : csa103CompEO.---.---.00044 :   INFO)&lt;br /&gt;
 csa103: Instantiated as component instance csa103CompI1.&lt;br /&gt;
Mon Jul 14 00:16:49 2008   (SCNodeI0.15553 : csa103CompEO.---.---.00045 :   INFO)&lt;br /&gt;
 csa103CompI1: Waiting for CSI assignment...&lt;br /&gt;
Mon Jul 14 00:16:49 2008   (SCNodeI0.15553 : csa103CompEO.---.---.00046 :   INFO)&lt;br /&gt;
 csa103CompI1: Waiting for CSI assignment...&lt;br /&gt;
Mon Jul 14 00:16:49 2008   (SCNodeI0.15553 : csa103CompEO.---.---.00047 :   INFO)&lt;br /&gt;
 csa103CompI1: checkpoint_initialize&lt;br /&gt;
Mon Jul 14 00:16:50 2008   (SCNodeI0.15553 : csa103CompEO.---.---.00054 :   INFO)&lt;br /&gt;
 csa103CompI1: Checkpoint service initialized (handle=0x1)&lt;br /&gt;
Mon Jul 14 00:16:50 2008   (SCNodeI0.15553 : csa103CompEO.---.---.00056 :   INFO)&lt;br /&gt;
 csa103CompI1: Checkpoint opened (handle=0x2)&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
That is the component that had been killed being restarted.  &lt;br /&gt;
&lt;br /&gt;
CompI0 is moving along just fine, and we see CompI1 come back up.  If we then kill CompI0 we see:&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffffaa;&amp;quot; align=&amp;quot;center&amp;quot;| /root/asp/var/log/csa103CompI1Log.latest&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
Mon Jul 14 00:29:44 2008   (SCNodeI0.15553 : csa103CompEO.---.---.00065 :   INFO)&lt;br /&gt;
 csa103CompI1: Active state requested from state 2&lt;br /&gt;
Mon Jul 14 00:29:44 2008   (SCNodeI0.15553 : csa103CompEO.---.---.00066 :   INFO)&lt;br /&gt;
 csa103CompI1 reading checkpoint&lt;br /&gt;
Mon Jul 14 00:29:44 2008   (SCNodeI0.15553 : csa103CompEO.---.---.00067 :   INFO)&lt;br /&gt;
 csa103CompI1 read checkpoint: seq = 1225&lt;br /&gt;
Mon Jul 14 00:29:45 2008   (SCNodeI0.15553 : csa103CompEO.---.---.00068 :   INFO)&lt;br /&gt;
 csa103CompI1: Hello World! (seq=1225)&lt;br /&gt;
Mon Jul 14 00:29:46 2008   (SCNodeI0.15553 : csa103CompEO.---.---.00069 :   INFO)&lt;br /&gt;
 csa103CompI1: Hello World! (seq=1226)&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
Where we can see the CompI0 process die, and CompI1 process read the sequence number from the checkpoint and then take over from where CompI0 left off.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;To stop csa103 use the following SAFplus Platform Console command.&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
cli[Test:SCNodeI0:CPM]-&amp;gt; amsLockAssignment sg csa103SGI0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;Now change the state of csa103SGI0 to LockInstantiation and close the SAFplus Platform Console.&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
cli[Test:SCNodeI0:CPM]-&amp;gt; amsLockInstantiation sg csa103SGI0&lt;br /&gt;
cli[Test:SCNodeI0:CPM] -&amp;gt; end&lt;br /&gt;
cli[Test:SCNodeI0] -&amp;gt; end&lt;br /&gt;
cli[Test] -&amp;gt; bye&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===csa203===&lt;br /&gt;
&lt;br /&gt;
csa203 demonstrates the usage of SA Forum's Checkpointing service. This sample application does not deviate functionally from csa103. The code differences are due to using SA Forum data types (structures) and APIs , as presented in the following two tables. (Note we have not repeated data types and APIs covered previously.)&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|+align=&amp;quot;bottom&amp;quot;| '''SA Forum Data Types with the SAFplus Platform equivalent'''&lt;br /&gt;
|- style=&amp;quot;color:black;background-color:#ffffaa;&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
!SA Forum Data Types   &lt;br /&gt;
!OpenClovis Data Types&lt;br /&gt;
|-&lt;br /&gt;
|SaCkptHandleT&lt;br /&gt;
|ClCkptSvcHdlT&lt;br /&gt;
|-&lt;br /&gt;
|SaCkptHandleT&lt;br /&gt;
|ClCkptHdlT&lt;br /&gt;
|-&lt;br /&gt;
|SaCkptSectionIdT&lt;br /&gt;
|ClCkptSectionIdT&lt;br /&gt;
|-&lt;br /&gt;
|SaCkptCheckpointCreationAttributesT&lt;br /&gt;
|ClCkptCheckpointCreationAttributesT&lt;br /&gt;
|-&lt;br /&gt;
|SaCkptSectionCreationAttributesT&lt;br /&gt;
|ClCkptSectionCreationAttributesT&lt;br /&gt;
|-&lt;br /&gt;
|SaCkptIOVectorElementT&lt;br /&gt;
|ClCkptIOVectorElementT&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|+align=&amp;quot;bottom&amp;quot;| '''SA Forum APIs with the SAFplus Platform equivalent'''&lt;br /&gt;
|- style=&amp;quot;color:black;background-color:#ffffaa;&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
!SA Forum APIs&lt;br /&gt;
!OpenClovis APIs&lt;br /&gt;
|-&lt;br /&gt;
|saCkptInitialize&lt;br /&gt;
|clCkptInitialize&lt;br /&gt;
|-&lt;br /&gt;
|saCkptCheckpointOpen&lt;br /&gt;
|clCkptCheckpointOpen&lt;br /&gt;
|-&lt;br /&gt;
|saCkptSectionCreate&lt;br /&gt;
|clCkptSectionCreate&lt;br /&gt;
|-&lt;br /&gt;
|saCkptCheckpointClose&lt;br /&gt;
|clCkptCheckpointClose&lt;br /&gt;
|-&lt;br /&gt;
|saCkptFinalize&lt;br /&gt;
|clCkptFinalize&lt;br /&gt;
|-&lt;br /&gt;
|saCkptSectionOverwrite&lt;br /&gt;
|clCkptSectionOverwrite&lt;br /&gt;
|-&lt;br /&gt;
|saCkptCheckpointSynchronize&lt;br /&gt;
|clCkptCheckpointSynchronize&lt;br /&gt;
|-&lt;br /&gt;
|saCkptCheckpointRead&lt;br /&gt;
|clCkptCheckpointRead&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===How to Run csa103 and What to Observe===&lt;br /&gt;
&lt;br /&gt;
This sample application can run on all Runtime Hardware Setups. The following, lists which node &amp;lt;code&amp;gt;csa103compI*&amp;lt;/code&amp;gt; runs on.&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;'''Runtime Hardware Setup 1.1 and 2.1'''&lt;br /&gt;
&amp;lt;br&amp;gt;csa103compI0 and csa103compI1 will run upon the single node.&lt;br /&gt;
&amp;lt;li&amp;gt;'''Runtime Hardware Setup 1.2 and 2.2'''&lt;br /&gt;
&amp;lt;br&amp;gt;csa103compI0 runs on PayloadNodeI0 and csa103compI1 runs on PayloadNodeI1&lt;br /&gt;
&amp;lt;li&amp;gt;'''Runtime Hardware Setup 1.3 and 2.3'''&lt;br /&gt;
&amp;lt;br&amp;gt;csa103compI2 and csa103compI3 run on SCNodeI0 and SCNodeI1 respectively. csa103compI0 and csa103compI1 run on PayloadNodeI0 and PayloadNodeI1 respectively.&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;In the four node set up SCNodeI0 and SCNodeI1 output data via &amp;lt;code&amp;gt;/root/asp/var/log/csa103CompI2&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;/root/asp/var/log/csa103CompI3&amp;lt;/code&amp;gt; respectively. Therefore in this case follow the below instructions replacing csa103CompI0 and csa103compI1 with csa103compI2 and csa103compI3 respectively.&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We run csa103 very much the same way we run any of the rest of the sample applications: with the SAFplus Platform Console.&lt;br /&gt;
  &lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;First, on the active System Controller move it to state LockAssignment with (Unlock csa203SGI0 instead of csa103SGI0 to run csa203)&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
cli[Test]-&amp;gt; setc 1&lt;br /&gt;
cli[Test:SCNodeI0]-&amp;gt; setc cpm&lt;br /&gt;
cli[Test:SCNodeI0:CPM]-&amp;gt; amsLockAssignment sg csa103SGI0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The following output is given when you run &amp;lt;code&amp;gt;tail -f&amp;lt;/code&amp;gt; on the csa103 log files. For example:&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
# tail -f /root/asp/var/log/csa103CompI0.log&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffffaa;&amp;quot; align=&amp;quot;center&amp;quot;| /root/asp/var/log/csa103CompI0Log.latest&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
Mon Jul 14 00:01:09 2008   (SCNodeI0.15238 : csa103CompEO.---.---.00030 :   INFO)&lt;br /&gt;
 Component [csa103CompI0] : PID [15238]. Initializing&lt;br /&gt;
Mon Jul 14 00:01:09 2008   (SCNodeI0.15238 : csa103CompEO.---.---.00031 :   INFO)&lt;br /&gt;
    IOC Address             : 0x1&lt;br /&gt;
Mon Jul 14 00:01:09 2008   (SCNodeI0.15238 : csa103CompEO.---.---.00032 :   INFO)&lt;br /&gt;
    IOC Port                : 0x81&lt;br /&gt;
Mon Jul 14 00:01:09 2008   (SCNodeI0.15238 : csa103CompEO.---.---.00033 :   INFO)&lt;br /&gt;
 csa103: Instantiated as component instance csa103CompI0.&lt;br /&gt;
Mon Jul 14 00:01:09 2008   (SCNodeI0.15238 : csa103CompEO.---.---.00034 :   INFO)&lt;br /&gt;
 csa103CompI0: Waiting for CSI assignment...&lt;br /&gt;
Mon Jul 14 00:01:09 2008   (SCNodeI0.15238 : csa103CompEO.---.---.00035 :   INFO)&lt;br /&gt;
 csa103CompI0: Waiting for CSI assignment...&lt;br /&gt;
Mon Jul 14 00:01:09 2008   (SCNodeI0.15238 : csa103CompEO.---.---.00036 :   INFO)&lt;br /&gt;
 csa103CompI0: checkpoint_initialize&lt;br /&gt;
Mon Jul 14 00:01:10 2008   (SCNodeI0.15238 : csa103CompEO.---.---.00043 :   INFO)&lt;br /&gt;
 csa103CompI0: Checkpoint service initialized (handle=0x1)&lt;br /&gt;
Mon Jul 14 00:01:10 2008   (SCNodeI0.15238 : csa103CompEO.---.---.00045 :   INFO)&lt;br /&gt;
 csa103CompI0: Checkpoint opened (handle=0x2)&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
# tail -f /root/asp/var/log/csa103CompI1.log&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffffaa;&amp;quot; align=&amp;quot;center&amp;quot;| /root/asp/var/log/csa103CompI1Log.latest&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
Mon Jul 14 00:01:09 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00030 :   INFO)&lt;br /&gt;
 Component [csa103CompI1] : PID [15234]. Initializing&lt;br /&gt;
Mon Jul 14 00:01:09 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00031 :   INFO)&lt;br /&gt;
    IOC Address             : 0x1&lt;br /&gt;
Mon Jul 14 00:01:09 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00032 :   INFO)&lt;br /&gt;
    IOC Port                : 0x80&lt;br /&gt;
Mon Jul 14 00:01:09 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00033 :   INFO)&lt;br /&gt;
 csa103: Instantiated as component instance csa103CompI1.&lt;br /&gt;
Mon Jul 14 00:01:09 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00034 :   INFO)&lt;br /&gt;
 csa103CompI1: Waiting for CSI assignment...&lt;br /&gt;
Mon Jul 14 00:01:09 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00035 :   INFO)&lt;br /&gt;
 csa103CompI1: Waiting for CSI assignment...&lt;br /&gt;
Mon Jul 14 00:01:09 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00036 :   INFO)&lt;br /&gt;
 csa103CompI1: checkpoint_initialize&lt;br /&gt;
Mon Jul 14 00:01:09 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00043 :   INFO)&lt;br /&gt;
 csa103CompI1: Checkpoint service initialized (handle=0x1)&lt;br /&gt;
Mon Jul 14 00:01:09 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00045 :   INFO)&lt;br /&gt;
 csa103CompI1: Checkpoint opened (handle=0x2)&lt;br /&gt;
Mon Jul 14 00:01:09 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00053 :   INFO)&lt;br /&gt;
 csa103CompI1: Section created&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;Then, unlock the application by running &lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
cli[Test:SCNodeI0:CPM]-&amp;gt; amsUnlock sg csa103SGI0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the application log files, you should see &lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffffaa;&amp;quot; align=&amp;quot;center&amp;quot;| /root/asp/var/log/csa103CompI0Log.latest&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
Mon Jul 14 00:09:08 2008   (SCNodeI0.15238 : csa103CompEO.---.---.00058 :   INFO)&lt;br /&gt;
  Standby state requested from state 0&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffffaa;&amp;quot; align=&amp;quot;center&amp;quot;| /root/asp/var/log/csa103CompI1Log.latest&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
Mon Jul 14 00:09:08 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00064 :   INFO)&lt;br /&gt;
 csa103CompI1: Active state requested from state 0&lt;br /&gt;
Mon Jul 14 00:09:09 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00065 :   INFO)&lt;br /&gt;
 csa103CompI1: Hello World! (seq=0)&lt;br /&gt;
Mon Jul 14 00:09:10 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00066 :   INFO)&lt;br /&gt;
 csa103CompI1: Hello World! (seq=1)&lt;br /&gt;
Mon Jul 14 00:09:11 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00067 :   INFO)&lt;br /&gt;
 csa103CompI1: Hello World! (seq=2)&lt;br /&gt;
Mon Jul 14 00:09:12 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00068 :   INFO)&lt;br /&gt;
 csa103CompI1: Hello World! (seq=3)&lt;br /&gt;
Mon Jul 14 00:09:13 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00069 :   INFO)&lt;br /&gt;
 csa103CompI1: Hello World! (seq=4)&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;Next, find the active csa103 process, the one that's printing the Hello World lines and kill it.  To find the process ID issue the following command from a bash shell.&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
 # ps -eaf | grep csa103&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
This should produce an output that looks similar to the following.&lt;br /&gt;
 root     17830 15663  0 14:21 ?        00:00:00 csa103Comp -p&lt;br /&gt;
 root     17839 15663  0 14:21 ?        00:00:00 csa103Comp -p&lt;br /&gt;
 root     18558 16145  0 14:32 pts/4    00:00:00 grep csa103&lt;br /&gt;
Notice the two entries that end with csa103Comp -p. These are our two component processes. The first one is usually the active process. This is the one that we will kill. In this case the process ID is 17830. So to kill the active component you issue the command:&lt;br /&gt;
&lt;br /&gt;
 # kill -9 17830&lt;br /&gt;
&lt;br /&gt;
[[File:OpenClovis_Note.png]]If this step does not result in the active component being killed then it is likely that the standby component was killed. In this case simply try killing the other process. &lt;br /&gt;
&lt;br /&gt;
After killing the active component you should see lines in the log files like the following:&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffffaa;&amp;quot; align=&amp;quot;center&amp;quot;| /root/asp/var/log/csa103CompI1Log.latest&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
Mon Jul 14 00:16:43 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00515 :   INFO)&lt;br /&gt;
 csa103CompI1: Hello World! (seq=452)&lt;br /&gt;
Mon Jul 14 00:16:44 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00516 :   INFO)&lt;br /&gt;
 csa103CompI1: Hello World! (seq=453)&lt;br /&gt;
Mon Jul 14 00:16:45 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00517 :   INFO)&lt;br /&gt;
 csa103CompI1: Hello World! (seq=454)&lt;br /&gt;
Mon Jul 14 00:16:46 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00518 :   INFO)&lt;br /&gt;
 csa103CompI1: Hello World! (seq=455)&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffffaa;&amp;quot; align=&amp;quot;center&amp;quot;| /var/log/csa103CompI0Log.latest&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
Mon Jul 14 00:16:48 2008   (SCNodeI0.15238 : csa103CompEO.---.---.00065 :   INFO)&lt;br /&gt;
 csa103CompI0: Active state requested from state 2&lt;br /&gt;
Mon Jul 14 00:16:48 2008   (SCNodeI0.15238 : csa103CompEO.---.---.00066 :   INFO)&lt;br /&gt;
 csa103CompI0 reading checkpoint&lt;br /&gt;
Mon Jul 14 00:16:48 2008   (SCNodeI0.15238 : csa103CompEO.---.---.00067 :   INFO)&lt;br /&gt;
 csa103CompI0 read checkpoint: seq = 456&lt;br /&gt;
Mon Jul 14 00:16:49 2008   (SCNodeI0.15238 : csa103CompEO.---.---.00068 :   INFO)&lt;br /&gt;
 csa103CompI0: Hello World! (seq=456)&lt;br /&gt;
Mon Jul 14 00:16:50 2008   (SCNodeI0.15238 : csa103CompEO.---.---.00069 :   INFO)&lt;br /&gt;
 csa103CompI0: Hello World! (seq=457)&lt;br /&gt;
Mon Jul 14 00:16:51 2008   (SCNodeI0.15238 : csa103CompEO.---.---.00070 :   INFO)&lt;br /&gt;
 csa103CompI0: Hello World! (seq=458)&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
Where we can see CompI1 printing 455 and then dieing, where upon CompI0 gets the notice to take over processing, reads the checkpoint and then takes over with seq=456 and so on.&lt;br /&gt;
&lt;br /&gt;
Then, in the CompI1 log file we see:&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffffaa;&amp;quot; align=&amp;quot;center&amp;quot;| /root/asp/var/log/csa103CompI1Log.latest&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
Mon Jul 14 00:16:49 2008   (SCNodeI0.15553 : csa103CompEO.---.---.00044 :   INFO)&lt;br /&gt;
 csa103: Instantiated as component instance csa103CompI1.&lt;br /&gt;
Mon Jul 14 00:16:49 2008   (SCNodeI0.15553 : csa103CompEO.---.---.00045 :   INFO)&lt;br /&gt;
 csa103CompI1: Waiting for CSI assignment...&lt;br /&gt;
Mon Jul 14 00:16:49 2008   (SCNodeI0.15553 : csa103CompEO.---.---.00046 :   INFO)&lt;br /&gt;
 csa103CompI1: Waiting for CSI assignment...&lt;br /&gt;
Mon Jul 14 00:16:49 2008   (SCNodeI0.15553 : csa103CompEO.---.---.00047 :   INFO)&lt;br /&gt;
 csa103CompI1: checkpoint_initialize&lt;br /&gt;
Mon Jul 14 00:16:50 2008   (SCNodeI0.15553 : csa103CompEO.---.---.00054 :   INFO)&lt;br /&gt;
 csa103CompI1: Checkpoint service initialized (handle=0x1)&lt;br /&gt;
Mon Jul 14 00:16:50 2008   (SCNodeI0.15553 : csa103CompEO.---.---.00056 :   INFO)&lt;br /&gt;
 csa103CompI1: Checkpoint opened (handle=0x2)&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
That is the component that had been killed being restarted.  &lt;br /&gt;
&lt;br /&gt;
CompI0 is moving along just fine, and we see CompI1 come back up.  If we then kill CompI0 we see:&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffffaa;&amp;quot; align=&amp;quot;center&amp;quot;| /root/asp/var/log/csa103CompI1Log.latest&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
Mon Jul 14 00:29:44 2008   (SCNodeI0.15553 : csa103CompEO.---.---.00065 :   INFO)&lt;br /&gt;
 csa103CompI1: Active state requested from state 2&lt;br /&gt;
Mon Jul 14 00:29:44 2008   (SCNodeI0.15553 : csa103CompEO.---.---.00066 :   INFO)&lt;br /&gt;
 csa103CompI1 reading checkpoint&lt;br /&gt;
Mon Jul 14 00:29:44 2008   (SCNodeI0.15553 : csa103CompEO.---.---.00067 :   INFO)&lt;br /&gt;
 csa103CompI1 read checkpoint: seq = 1225&lt;br /&gt;
Mon Jul 14 00:29:45 2008   (SCNodeI0.15553 : csa103CompEO.---.---.00068 :   INFO)&lt;br /&gt;
 csa103CompI1: Hello World! (seq=1225)&lt;br /&gt;
Mon Jul 14 00:29:46 2008   (SCNodeI0.15553 : csa103CompEO.---.---.00069 :   INFO)&lt;br /&gt;
 csa103CompI1: Hello World! (seq=1226)&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
Where we can see the CompI0 process die, and CompI1 process read the sequence number from the checkpoint and then take over from where CompI0 left off.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;To stop csa103 use the following SAFplus Platform Console command.&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
cli[Test:SCNodeI0:CPM]-&amp;gt; amsLockAssignment sg csa103SGI0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;Now change the state of csa103SGI0 to LockInstantiation and close the SAFplus Platform Console.&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
cli[Test:SCNodeI0:CPM]-&amp;gt; amsLockInstantiation sg csa103SGI0&lt;br /&gt;
cli[Test:SCNodeI0:CPM] -&amp;gt; end&lt;br /&gt;
cli[Test:SCNodeI0] -&amp;gt; end&lt;br /&gt;
cli[Test] -&amp;gt; bye&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Additional Tests for Runtime Hardware Setup 1.3 and 2.3===&lt;br /&gt;
&lt;br /&gt;
Now repeat  the experiment till the stage before we kill  the active process  and follow these steps.&lt;br /&gt;
&lt;br /&gt;
'''Step A'''&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Stop SAFplus Platform on SCNodeI0 using &amp;lt;code&amp;gt;/etc/init.d/asp stop&amp;lt;/code&amp;gt;. Observer the logs &amp;lt;code&amp;gt;/root/asp/var/log/csa103CompI3Log.latest&amp;lt;/code&amp;gt; on SCNodeI1. This will become active  and start printing the hello world logs as above. &lt;br /&gt;
Note in this case active System Controller SCNode1 is still aware of PayloadNodeI0 and PayloadNodeI1.&lt;br /&gt;
&amp;lt;li&amp;gt;Start looking at the logs  for &amp;lt;code&amp;gt;/root/asp/var/log/csa103CompI0Log.latest&amp;lt;/code&amp;gt; in PayloadNodeI0. This will print the  standby  logs as  above.&lt;br /&gt;
&amp;lt;li&amp;gt;Stop  SAFplus Platform  on PayloadNodeI0  and start observing the logs on PayloadNodeI1 in &amp;lt;code&amp;gt;/root/asp/var/log/csa103CompI1Log.latest&amp;lt;/code&amp;gt; for standby.&lt;br /&gt;
In this case, you can see, via the active System Controller logs that PayloadNodeI0 is not active whilst PayloadNodeI1 is.&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Step B'''  For Hardware Setup 1.3 only&lt;br /&gt;
#Repeat A  with the slight exception  that the  blade running SCNodeI0  is  yanked out(&amp;lt;code&amp;gt;/etc/init.d/asp zap&amp;lt;/code&amp;gt;) instead of gracefully shutting  down SAFplus Platform in step 1.&lt;br /&gt;
&lt;br /&gt;
===Summary and References===&lt;br /&gt;
We've seen :&lt;br /&gt;
&lt;br /&gt;
*how to use Clovis' checkpoint service to save some program state and recover that state from a separate process&lt;br /&gt;
*how to initialize the client checkpoint library&lt;br /&gt;
*how to create and open checkpoints &lt;br /&gt;
*how to create and use sections in an opened checkpoint&lt;br /&gt;
&lt;br /&gt;
Further information can be found within the following: ''OpenClovis API Reference Guide''.&lt;/div&gt;</summary>
		<author><name>Madhu</name></author>	</entry>

	<entry>
		<id>https://help.openclovis.com/index.php/Doc:latest/evalguide/csa103</id>
		<title>Doc:latest/evalguide/csa103</title>
		<link rel="alternate" type="text/html" href="https://help.openclovis.com/index.php/Doc:latest/evalguide/csa103"/>
				<updated>2010-10-01T05:49:33Z</updated>
		
		<summary type="html">&lt;p&gt;Madhu: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==csa203 Checkpointing==&lt;br /&gt;
&lt;br /&gt;
===Objective===&lt;br /&gt;
&lt;br /&gt;
csa203 demonstrates how to use the Clovis Checkpoint service to provide basic failure recovery.  csa203 builds on csa202.&lt;br /&gt;
&lt;br /&gt;
===What Will You Learn===&lt;br /&gt;
&lt;br /&gt;
*how to initialize the checkpoint client library, &lt;br /&gt;
*how to create a checkpoint and  open a checkpoint, &lt;br /&gt;
*how to create a section in the checkpoint &lt;br /&gt;
*how to save data to the checkpoint section and read data from the checkpoint section.&lt;br /&gt;
&lt;br /&gt;
===The Code===&lt;br /&gt;
&lt;br /&gt;
The code can be found within the following directory&lt;br /&gt;
 &amp;lt;project-area_dir&amp;gt;/eval/src/app/csa103Comp&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffccaa;&amp;quot; align=&amp;quot;center&amp;quot;| clCompAppMain.c&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
ClCompAppInitialize()&lt;br /&gt;
&lt;br /&gt;
        ...&lt;br /&gt;
&lt;br /&gt;
        if ((rc = checkpoint_initialize()) != SA_AIS_OK)&lt;br /&gt;
        {&lt;br /&gt;
            clprintf(CL_LOG_SEV_ERROR,&amp;quot;%s: Failed [0x%x] to initialize checkpoint&amp;quot;,&lt;br /&gt;
                    appname, rc);&lt;br /&gt;
            return rc;&lt;br /&gt;
        }&lt;br /&gt;
        if ((rc = checkpoint_read_seq(&amp;amp;seq)) != SA_AIS_OK)&lt;br /&gt;
        {&lt;br /&gt;
            clprintf(CL_LOG_SEV_ERROR,&amp;quot;%s: Failed [0x%x] to read checkpoint&amp;quot;,&lt;br /&gt;
                    appname, rc);&lt;br /&gt;
            checkpoint_finalize();&lt;br /&gt;
            return rc;&lt;br /&gt;
        }&lt;br /&gt;
    #ifdef CL_INST&lt;br /&gt;
        if ((rc = clDataTapInit(DATA_TAP_DEFAULT_FLAGS, 103)) != SA_AIS_OK)&lt;br /&gt;
        {&lt;br /&gt;
            clprintf(CL_LOG_SEV_ERROR,&amp;quot;%s: Failed [0x%x] to initialize data tap&amp;quot;,&lt;br /&gt;
                    appname, rc);&lt;br /&gt;
        }&lt;br /&gt;
    #endif&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
The above software in &amp;lt;code&amp;gt;clCompAppMain.c&amp;lt;/code&amp;gt; is new to csa103. The call to &amp;lt;code&amp;gt;checkpoint_initialize&amp;lt;/code&amp;gt; is pretty straightforward.  This function discussed in detail later within this section.  The call to &amp;lt;code&amp;gt;checkpoint_read_seq&amp;lt;/code&amp;gt; is also pretty straightforward.  It reads the current sequence value from the checkpoint (at this point it should be zero) and loads it into the variable: &amp;lt;code&amp;gt;seq&amp;lt;/code&amp;gt;.  It is important to note the call to &amp;lt;code&amp;gt;checkpont_finalize&amp;lt;/code&amp;gt; if the call to &amp;lt;code&amp;gt;checkpoint_read_seq&amp;lt;/code&amp;gt; does not return &amp;lt;code&amp;gt;CL_OK&amp;lt;/code&amp;gt;.  This call closes the checkpoint and cleanly finalizes the checkpoint library.  We'll look more at &amp;lt;code&amp;gt;checkpoint_read_seq&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;checkpoint_finalize&amp;lt;/code&amp;gt; later.&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffccaa;&amp;quot; align=&amp;quot;center&amp;quot;| clCompAppMain.c&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
        /* Checkpoint new sequence number */&lt;br /&gt;
        rc = checkpoint_write_seq(seq);&lt;br /&gt;
        if (rc != SA_AIS_OK)&lt;br /&gt;
        {&lt;br /&gt;
            clprintf(CL_LOG_SEV_ERROR,&amp;quot;%s: ERROR: Checkpoint write failed. Exiting.&amp;quot;, appname);&lt;br /&gt;
            break;&lt;br /&gt;
        }&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
The rest of the csa103's main loop is the same as the main loop in csa102, but the seven lines above are new.  Here we write the new value of the checkpoint variable to the checkpoint section and print and error if this fails.  We'll look closer at &amp;lt;code&amp;gt;checkpoint_write_seq&amp;lt;/code&amp;gt; later.&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffccaa;&amp;quot; align=&amp;quot;center&amp;quot;| clCompAppMain.c&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
    ClRcT&lt;br /&gt;
    clCompAppAMFCSISet(&lt;br /&gt;
        ClInvocationT       invocation,&lt;br /&gt;
        const ClNameT       *compName,&lt;br /&gt;
        ClAmsHAStateT       haState,&lt;br /&gt;
        ClAmsCSIDescriptorT csiDescriptor)&lt;br /&gt;
    {    &lt;br /&gt;
        /*&lt;br /&gt;
         * ---BEGIN_APPLICATION_CODE--- &lt;br /&gt;
         */&lt;br /&gt;
        ClCharT     compname[100]={0};&lt;br /&gt;
&lt;br /&gt;
        /*&lt;br /&gt;
         * ---END_APPLICATION_CODE---&lt;br /&gt;
         */&lt;br /&gt;
&lt;br /&gt;
        /*&lt;br /&gt;
         * Print information about the CSI Set&lt;br /&gt;
         */&lt;br /&gt;
        strncpy(compname, compName-&amp;gt;value, compName-&amp;gt;length);&lt;br /&gt;
&lt;br /&gt;
        clprintf (CL_LOG_SEV_INFO, &amp;quot;Component [%s] : PID [%d]. CSI Set Received&amp;quot;, &lt;br /&gt;
              compname, (int)mypid);&lt;br /&gt;
&lt;br /&gt;
        clCompAppAMFPrintCSI(csiDescriptor, haState);&lt;br /&gt;
    &lt;br /&gt;
        /*&lt;br /&gt;
          Take appropriate action based on state&lt;br /&gt;
        */&lt;br /&gt;
    &lt;br /&gt;
        switch ( haState )&lt;br /&gt;
        {&lt;br /&gt;
            case CL_AMS_HA_STATE_ACTIVE:&lt;br /&gt;
            {&lt;br /&gt;
                /*&lt;br /&gt;
                  AMF has requested application to take the active HA state&lt;br /&gt;
                  for the CSI.&lt;br /&gt;
                */&lt;br /&gt;
    &lt;br /&gt;
                /*&lt;br /&gt;
                  ---BEGIN_APPLICATION_CODE---&lt;br /&gt;
                */&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffccaa;&amp;quot; align=&amp;quot;center&amp;quot;| clCompAppMain.c&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;   &lt;br /&gt;
                clprintf(CL_LOG_SEV_INFO,&amp;quot;%s: Active state requested from state %d&amp;quot;,&lt;br /&gt;
                        appname, ha_state);&lt;br /&gt;
&lt;br /&gt;
                if (ha_state == SA_AMF_HA_STANDBY)&lt;br /&gt;
                {&lt;br /&gt;
                    /* Read checkpoint, make our replica the active replica */&lt;br /&gt;
                    clprintf(CL_LOG_SEV_INFO,&amp;quot;%s reading checkpoint&amp;quot;, appname);&lt;br /&gt;
                    rc = checkpoint_read_seq(&amp;amp;seq);&lt;br /&gt;
                    clprintf(CL_LOG_SEV_INFO,&amp;quot;%s read checkpoint: seq = %u&amp;quot;, appname, seq);&lt;br /&gt;
                }&lt;br /&gt;
                checkpoint_replica_activate();            &lt;br /&gt;
                ha_state = SA_AMF_HA_ACTIVE;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
                /*&lt;br /&gt;
                 * ---END_APPLICATION_CODE---&lt;br /&gt;
                 */&lt;br /&gt;
&lt;br /&gt;
                clCpmResponse(cpmHandle, invocation, CL_OK);&lt;br /&gt;
                break;&lt;br /&gt;
            }&lt;br /&gt;
&lt;br /&gt;
            case CL_AMS_HA_STATE_STANDBY:&lt;br /&gt;
            {&lt;br /&gt;
                /*&lt;br /&gt;
                 * AMF has requested application to take the standby HA state &lt;br /&gt;
                 * for this CSI.&lt;br /&gt;
                 */&lt;br /&gt;
&lt;br /&gt;
                /*&lt;br /&gt;
                 * ---BEGIN_APPLICATION_CODE---&lt;br /&gt;
                 */&lt;br /&gt;
&lt;br /&gt;
                 clprintf(CL_LOG_SEV_INFO,&amp;quot; Standby state requested from state %d&amp;quot;,ha_state);&lt;br /&gt;
            &lt;br /&gt;
                 ha_state = SA_AMF_HA_STANDBY;&lt;br /&gt;
&lt;br /&gt;
                /*&lt;br /&gt;
                 * ---END_APPLICATION_CODE---&lt;br /&gt;
                 */&lt;br /&gt;
&lt;br /&gt;
                clCpmResponse(cpmHandle, invocation, CL_OK);&lt;br /&gt;
                break;&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffccaa;&amp;quot; align=&amp;quot;center&amp;quot;| clCompAppMain.c&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;    &lt;br /&gt;
            case CL_AMS_HA_STATE_QUIESCED:&lt;br /&gt;
            {&lt;br /&gt;
                /*&lt;br /&gt;
                 * AMF has requested application to quiesce the CSI currently&lt;br /&gt;
                 * assigned the active or quiescing HA state. The application &lt;br /&gt;
                 * must stop work associated with the CSI immediately.&lt;br /&gt;
                 */&lt;br /&gt;
&lt;br /&gt;
                /*&lt;br /&gt;
                 * ---BEGIN_APPLICATION_CODE---&lt;br /&gt;
                 */&lt;br /&gt;
&lt;br /&gt;
                clprintf(CL_LOG_SEV_INFO,&amp;quot;%s: QUIESCED&amp;quot;, appname);&lt;br /&gt;
                ha_state = haState;&lt;br /&gt;
&lt;br /&gt;
                /*&lt;br /&gt;
                 * ---END_APPLICATION_CODE---&lt;br /&gt;
                 */&lt;br /&gt;
&lt;br /&gt;
                clCpmResponse(cpmHandle, invocation, CL_OK);&lt;br /&gt;
                break;&lt;br /&gt;
            }&lt;br /&gt;
&lt;br /&gt;
            case CL_AMS_HA_STATE_QUIESCING:&lt;br /&gt;
            { &lt;br /&gt;
                /*&lt;br /&gt;
                 * AMF has requested application to quiesce the CSI currently&lt;br /&gt;
                 * assigned the active HA state. The application must stop work&lt;br /&gt;
                 * associated with the CSI gracefully and not accept any new&lt;br /&gt;
                 * workloads while the work is being terminated.&lt;br /&gt;
                 */&lt;br /&gt;
&lt;br /&gt;
                /*&lt;br /&gt;
                 * ---BEGIN_APPLICATION_CODE---&lt;br /&gt;
                 */&lt;br /&gt;
&lt;br /&gt;
                clprintf(CL_LOG_SEV_INFO,&amp;quot;%s: QUIESCING&amp;quot;, appname);&lt;br /&gt;
                ha_state = haState;&lt;br /&gt;
&lt;br /&gt;
                /*&lt;br /&gt;
                 * ---END_APPLICATION_CODE---&lt;br /&gt;
                 */&lt;br /&gt;
&lt;br /&gt;
                clCpmCSIQuiescingComplete(cpmHandle, invocation, CL_OK);&lt;br /&gt;
                break;&lt;br /&gt;
            }&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffccaa;&amp;quot; align=&amp;quot;center&amp;quot;| clCompAppMain.c&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
            default:&lt;br /&gt;
            {&lt;br /&gt;
                break;&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
    &lt;br /&gt;
        return CL_OK;&lt;br /&gt;
    }&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now looking at csa103's implementation of &amp;lt;code&amp;gt;clCompAppAMFCSISet&amp;lt;/code&amp;gt;, we see that rather than just a few cases, we handle several cases: &amp;lt;code&amp;gt;QUIESCING&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;QUIESCED&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;ACTIVE&amp;lt;/code&amp;gt;, and  &amp;lt;code&amp;gt;STANDBY&amp;lt;/code&amp;gt;.  In each state, the global variable &amp;lt;code&amp;gt;ha_state&amp;lt;/code&amp;gt; to the new_state value that is passed in is set.  This is similar to csa102, except that we add the feature that in the &amp;lt;code&amp;gt;CL_AMS_HA_STATE_ACTIVE&amp;lt;/code&amp;gt; case if our previous state was &amp;lt;code&amp;gt;CL_AMS_HA_STATE_STANDBY&amp;lt;/code&amp;gt; we read the sequence from the checkpoint so that the main loop will pick it up.&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffccaa;&amp;quot; align=&amp;quot;center&amp;quot;| clCompAppMain.c&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
    static ClRcT&lt;br /&gt;
    checkpoint_initialize()&lt;br /&gt;
    {&lt;br /&gt;
        SaAisErrorT      rc = CL_OK;&lt;br /&gt;
        SaVersionT ckpt_version = {'B', 1, 1};&lt;br /&gt;
        SaNameT    ckpt_name = { strlen(CKPT_NAME), CKPT_NAME };&lt;br /&gt;
        ClUint32T  seq_no;&lt;br /&gt;
        SaCkptCheckpointCreationAttributesT create_atts = {&lt;br /&gt;
            .creationFlags     = SA_CKPT_WR_ACTIVE_REPLICA_WEAK |&lt;br /&gt;
                             SA_CKPT_CHECKPOINT_COLLOCATED,&lt;br /&gt;
            .checkpointSize    = sizeof(ClUint32T),&lt;br /&gt;
            .retentionDuration = (ClTimeT)10,&lt;br /&gt;
            .maxSections       = 2, // two sections &lt;br /&gt;
            .maxSectionSize    = sizeof(ClUint32T),&lt;br /&gt;
            .maxSectionIdSize  = (ClSizeT)64&lt;br /&gt;
&lt;br /&gt;
        &lt;br /&gt;
        };&lt;br /&gt;
        SaCkptSectionCreationAttributesT section_atts = {&lt;br /&gt;
        .sectionId = &amp;amp;ckpt_sid,&lt;br /&gt;
        .expirationTime = SA_TIME_END&lt;br /&gt;
&lt;br /&gt;
        };&lt;br /&gt;
 &lt;br /&gt;
        clprintf(CL_LOG_SEV_INFO,&amp;quot;%s: checkpoint_initialize&amp;quot;, appname);&lt;br /&gt;
        /* Initialize checkpointing service instance */&lt;br /&gt;
        rc = saCkptInitialize(&amp;amp;ckpt_svc_handle,	/* Checkpoint service handle */&lt;br /&gt;
						  NULL,			    /* Optional callbacks table */&lt;br /&gt;
						  &amp;amp;ckpt_version);   /* Required verison number */&lt;br /&gt;
        if (rc != SA_AIS_OK)&lt;br /&gt;
        {&lt;br /&gt;
            clprintf(CL_LOG_SEV_ERROR,&amp;quot;%s: ERROR: Failed to initialize checkpoint service&amp;quot;,&lt;br /&gt;
                    appname);&lt;br /&gt;
            return rc;&lt;br /&gt;
        }&lt;br /&gt;
        clprintf(CL_LOG_SEV_INFO,&amp;quot;%s: Checkpoint service initialized (handle=0x%llx)&amp;quot;,&lt;br /&gt;
           appname, ckpt_svc_handle);&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Here is &amp;lt;code&amp;gt;checkpoint_initialize&amp;lt;/code&amp;gt;.  Here we initialize the &amp;lt;code&amp;gt;ClNameT&amp;lt;/code&amp;gt; structure that holds the name of the checkpoint to be opened/created with the line: &amp;lt;code&amp;gt;ClNameT    ckpt_name = { strlen(CKPT_NAME), CKPT_NAME };&amp;lt;/code&amp;gt;. We then define a set of attributes to associate with the checkpoint when creating that checkpoint. The &amp;lt;code&amp;gt;creationFlags&amp;lt;/code&amp;gt; includes &amp;lt;code&amp;gt;CL_CKPT_WR_ACTIVE_REPLICA&amp;lt;/code&amp;gt;.  This means that the checkpoint to be created will be asynchronous, or once active server updation is completed, the call returns to the application, all other replica updates happens parallel. &amp;lt;code&amp;gt;CheckpointSize&amp;lt;/code&amp;gt; is set to the sizeof a 32 bit unsigned integer, which is the sequence number we print in the main loop.  The &amp;lt;code&amp;gt;retentionDuration&amp;lt;/code&amp;gt; is the time that the checkpoint service will keep the checkpoint in store after the last client has closed the checkpoint.  &amp;lt;code&amp;gt;MaxSections&amp;lt;/code&amp;gt; is 2 as this checkpoint will be used to store two sections.  &amp;lt;code&amp;gt;MaxSectionSize&amp;lt;/code&amp;gt; is the set to the sizeof a 32 bit unsigned integer, as application stores only unsigned integer. And &amp;lt;code&amp;gt;maxSectionIdSize&amp;lt;/code&amp;gt; is 64 bytes.&lt;br /&gt;
&lt;br /&gt;
We next use &amp;lt;code&amp;gt;ClCkptSectionCreationAttributesT section_atts&amp;lt;/code&amp;gt; to define the creation attributes for the sole section of the checkpoint. The &amp;lt;code&amp;gt;sectionId&amp;lt;/code&amp;gt; is just the name of the section along with the number of bytes in the name.  The &amp;lt;code&amp;gt;expirationTime&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;CL_TIME_END&amp;lt;/code&amp;gt; to imply that the section is never deleted automatically if the checkpoint itself still remains.&lt;br /&gt;
&lt;br /&gt;
The call to &amp;lt;code&amp;gt;clCkptInitialize&amp;lt;/code&amp;gt; has to be called before any other checkpoint functions.  The &amp;lt;code&amp;gt;ckpt_svc_handle&amp;lt;/code&amp;gt; is where the handle is returned.  The handle must be passed to some future checkpoint api calls, namely the &amp;lt;code&amp;gt;clCkptCheckpointOpen&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;clCkptFinalize&amp;lt;/code&amp;gt; calls.  The callbacks table is passed as &amp;lt;code&amp;gt;NULL&amp;lt;/code&amp;gt; which implies that our application doesn't provide any callbacks.  Finally the &amp;lt;code&amp;gt;ckpt_version&amp;lt;/code&amp;gt; identifies what version of the api this application is written to.&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffccaa;&amp;quot; align=&amp;quot;center&amp;quot;| clCompAppMain.c&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
        //&lt;br /&gt;
        // Create the checkpoint for read and write.            &lt;br /&gt;
&lt;br /&gt;
        rc = saCkptCheckpointOpen(ckpt_svc_handle,      // Service handle&lt;br /&gt;
                              &amp;amp;ckpt_name,         // Checkpoint name&lt;br /&gt;
                              &amp;amp;create_atts,       // Optional creation attr.&lt;br /&gt;
                              (SA_CKPT_CHECKPOINT_READ |&lt;br /&gt;
                               SA_CKPT_CHECKPOINT_WRITE |&lt;br /&gt;
                               SA_CKPT_CHECKPOINT_CREATE),&lt;br /&gt;
                              (SaTimeT)-1,        // No timeout&lt;br /&gt;
                              &amp;amp;ckpt_handle);      // Checkpoint handle&lt;br /&gt;
&lt;br /&gt;
        if (rc != SA_AIS_OK)&lt;br /&gt;
&lt;br /&gt;
        {&lt;br /&gt;
            clprintf(CL_LOG_SEV_ERROR,&amp;quot;%s: ERROR: Failed [0x%x] to open checkpoint&amp;quot;,&lt;br /&gt;
                    appname, rc);&lt;br /&gt;
            (void)saCkptFinalize(ckpt_svc_handle);&lt;br /&gt;
            return rc;&lt;br /&gt;
        }&lt;br /&gt;
        clprintf(CL_LOG_SEV_INFO,&amp;quot;%s: Checkpoint opened (handle=0x%llx)&amp;quot;, appname, ckpt_handle);&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
 &lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffccaa;&amp;quot; align=&amp;quot;center&amp;quot;| clCompAppMain.c&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
        /*&lt;br /&gt;
         * Try to create a section so that updates can operate by overwriting&lt;br /&gt;
         * the section over and over again.&lt;br /&gt;
         * If subsequent processes come through here, they will fail to create&lt;br /&gt;
         * the section.  That is OK, even though it will cause an error message&lt;br /&gt;
         * If the section create fails because the section is already there, then&lt;br /&gt;
         * read the sequence number&lt;br /&gt;
         */&lt;br /&gt;
        // Put data in network byte order&lt;br /&gt;
        seq_no = htonl(seq);&lt;br /&gt;
&lt;br /&gt;
        // Creating the section&lt;br /&gt;
        checkpoint_replica_activate();&lt;br /&gt;
        rc = saCkptSectionCreate(ckpt_handle,           // Checkpoint handle&lt;br /&gt;
                             &amp;amp;section_atts,         // Section attributes&lt;br /&gt;
                             (SaUint8T*)&amp;amp;seq_no,    // Initial data&lt;br /&gt;
                             (SaSizeT)sizeof(seq_no)); // Size of data&lt;br /&gt;
        if (rc != SA_AIS_OK &amp;amp;&amp;amp; (CL_GET_ERROR_CODE(rc) != SA_AIS_ERR_EXIST))&lt;br /&gt;
        {&lt;br /&gt;
            clprintf(CL_LOG_SEV_ERROR,&amp;quot;%s: ERROR: Failed to create checkpoint section&amp;quot;, appname);&lt;br /&gt;
            (void)saCkptCheckpointClose(ckpt_handle);&lt;br /&gt;
            (void)saCkptFinalize(ckpt_svc_handle);&lt;br /&gt;
            return rc;&lt;br /&gt;
        }&lt;br /&gt;
        else if (rc != SA_AIS_OK &amp;amp;&amp;amp; (CL_GET_ERROR_CODE(rc) == SA_AIS_ERR_EXIST))&lt;br /&gt;
        {&lt;br /&gt;
            rc = checkpoint_read_seq(&amp;amp;seq);&lt;br /&gt;
            if (rc != CL_OK)&lt;br /&gt;
            {&lt;br /&gt;
                clprintf(CL_LOG_SEV_ERROR,&amp;quot;%s: ERROR: Failed [0x%x] to read checkpoint section&amp;quot;,&lt;br /&gt;
                            appname, rc);&lt;br /&gt;
                (void)saCkptCheckpointClose(ckpt_handle);&lt;br /&gt;
                (void)saCkptFinalize(ckpt_svc_handle);&lt;br /&gt;
                return rc;&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
        else&lt;br /&gt;
        {&lt;br /&gt;
            clprintf(CL_LOG_SEV_INFO,&amp;quot;%s: Section created&amp;quot;, appname);&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        return CL_OK;&lt;br /&gt;
    }&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
With &amp;lt;code&amp;gt;rc = clCkptCheckpointOpen&amp;lt;/code&amp;gt; we attempt to open the specified checkpoint.  When &amp;lt;code&amp;gt;checkpoint_initialize&amp;lt;/code&amp;gt; is called the checkpoint may or may not exist.  We attempt to open the checkpoint for READ/WRITE access. &lt;br /&gt;
&lt;br /&gt;
Next we check if we created the checkpoint and then we need to create the section with a call to &amp;lt;code&amp;gt;clCkptSectionCreate&amp;lt;/code&amp;gt;.  We pass the checkpoint handle obtained from &amp;lt;code&amp;gt;clCkptCheckpointOpen&amp;lt;/code&amp;gt;, the section attributes declared earlier, and the address of the initial value along with the size in bytes of the initial value.&lt;br /&gt;
&lt;br /&gt;
We convert the initial value to network byte order by the code &amp;lt;code&amp;gt;seq_no = htonl(seq)&amp;lt;/code&amp;gt;, before passing it to &amp;lt;code&amp;gt;clCkptSectionCreate&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If we do not create the section, then we read the current value in the checkpoint into our global seq variable.&lt;br /&gt;
&lt;br /&gt;
Note that whenever we return an error return code from the function that we have either not opened the checkpoint/initialized the checkpoint service, or we have closed the checkpoint and finalized the checkpoint service with calls to &amp;lt;code&amp;gt;clCkptCheckpointClose&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;clCkptFinalize&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffccaa;&amp;quot; align=&amp;quot;center&amp;quot;| clCompAppMain.c&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
    static ClRcT &lt;br /&gt;
    checkpoint_finalize(void)&lt;br /&gt;
    {&lt;br /&gt;
        SaAisErrorT rc;&lt;br /&gt;
&lt;br /&gt;
        rc = saCkptCheckpointClose(ckpt_handle);&lt;br /&gt;
        if (rc != SA_AIS_OK)&lt;br /&gt;
        {&lt;br /&gt;
            clprintf(CL_LOG_SEV_ERROR,&amp;quot;%s: failed: [0x%x] to close checkpoint handle 0x%llx&amp;quot;,&lt;br /&gt;
                        appname, rc, ckpt_handle);&lt;br /&gt;
        }&lt;br /&gt;
        rc = saCkptFinalize(ckpt_svc_handle);&lt;br /&gt;
        if (rc != SA_AIS_OK)&lt;br /&gt;
        {&lt;br /&gt;
            clprintf(CL_LOG_SEV_ERROR,&amp;quot;%s: failed: [0x%x] to finalize checkpoint&amp;quot;,&lt;br /&gt;
                    appname, rc);&lt;br /&gt;
        }&lt;br /&gt;
        return CL_OK;&lt;br /&gt;
&lt;br /&gt;
    }&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
The above code snippet presents &amp;lt;code&amp;gt;checkpoint_finalize&amp;lt;/code&amp;gt;.  It's quite simple.  First it closes the checkpoint handle with a call to &amp;lt;code&amp;gt;clCkptCheckpointClose&amp;lt;/code&amp;gt;.  Next it finalizes the checkpoint library with a call to &amp;lt;code&amp;gt;clCkptFinalize&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffccaa;&amp;quot; align=&amp;quot;center&amp;quot;| clCompAppMain.c&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
    static ClRcT&lt;br /&gt;
    checkpoint_write_seq(ClUint32T seq)&lt;br /&gt;
    {&lt;br /&gt;
        SaAisErrorT rc = SA_AIS_OK;&lt;br /&gt;
        ClUint32T seq_no;&lt;br /&gt;
&lt;br /&gt;
        /* Putting data in network byte order */&lt;br /&gt;
        seq_no = htonl(seq);&lt;br /&gt;
&lt;br /&gt;
        /* Write checkpoint */&lt;br /&gt;
        retry:&lt;br /&gt;
        rc = saCkptSectionOverwrite(ckpt_handle,&lt;br /&gt;
                                &amp;amp;ckpt_sid,&lt;br /&gt;
                                &amp;amp;seq_no,&lt;br /&gt;
                                sizeof(ClUint32T));&lt;br /&gt;
        if (rc != SA_AIS_OK)&lt;br /&gt;
        {&lt;br /&gt;
            clprintf(CL_LOG_SEV_ERROR,&amp;quot;Failed [0x%x] to write to section&amp;quot;, rc);&lt;br /&gt;
            if(rc == SA_AIS_ERR_NOT_EXIST)&lt;br /&gt;
                rc = checkpoint_replica_activate();&lt;br /&gt;
            if(rc == CL_OK) goto retry;&lt;br /&gt;
        }&lt;br /&gt;
        else&lt;br /&gt;
        {&lt;br /&gt;
            /*&lt;br /&gt;
            * Synchronize the checkpoint to all the replicas.&lt;br /&gt;
            */&lt;br /&gt;
            rc = saCkptCheckpointSynchronize(ckpt_handle, SA_TIME_END );&lt;br /&gt;
            if (rc != SA_AIS_OK)&lt;br /&gt;
            {&lt;br /&gt;
                clprintf(CL_LOG_SEV_ERROR,&amp;quot;Failed [0x%x] to synchronize the checkpoint&amp;quot;, rc);&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        return CL_OK;&lt;br /&gt;
     }&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
With &amp;lt;code&amp;gt;checkpoint_write_seq&amp;lt;/code&amp;gt; we first convert the sequence number passed into network byte order.  Then we pass it to &amp;lt;code&amp;gt;clCKptSectionOverwrite&amp;lt;/code&amp;gt; which writes it to the checkpoint section created in &amp;lt;code&amp;gt;checkpoint_initialize&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffccaa;&amp;quot; align=&amp;quot;center&amp;quot;| clCompAppMain.c&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
    static ClRcT&lt;br /&gt;
    checkpoint_read_seq(ClUint32T *seq)&lt;br /&gt;
    {&lt;br /&gt;
        ClRcT rc = CL_OK;&lt;br /&gt;
        ClUint32T err_idx; /* Error index in ioVector */&lt;br /&gt;
        ClUint32T seq_no = 0xffffffff;&lt;br /&gt;
        SaCkptIOVectorElementT iov = {&lt;br /&gt;
            .sectionId  = ckpt_sid,&lt;br /&gt;
            .dataBuffer = (ClPtrT)&amp;amp;seq_no,&lt;br /&gt;
            .dataSize   = sizeof(ClUint32T),&lt;br /&gt;
            .dataOffset = (ClOffsetT)0,&lt;br /&gt;
            .readSize   = sizeof(ClUint32T)&lt;br /&gt;
        };&lt;br /&gt;
&lt;br /&gt;
        rc = saCkptCheckpointRead(ckpt_handle, &amp;amp;iov, 1, &amp;amp;err_idx);&lt;br /&gt;
        if (rc != SA_AIS_OK)&lt;br /&gt;
        {&lt;br /&gt;
           clprintf(CL_LOG_SEV_ERROR,&amp;quot;Error: [0x%x] from checkpoint read, err_idx = %u&amp;quot;,&lt;br /&gt;
                    rc, err_idx);&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        /* FIXME: How to process this err_idx? */&lt;br /&gt;
        *seq = ntohl(seq_no);&lt;br /&gt;
&lt;br /&gt;
        return CL_OK;&lt;br /&gt;
&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
With &amp;lt;code&amp;gt;checkpoint_read_seq&amp;lt;/code&amp;gt; we initialize &amp;lt;code&amp;gt;seq_no&amp;lt;/code&amp;gt; to all ones just so it will be more obvious if the &amp;lt;code&amp;gt;clCkptCheckpointRead&amp;lt;/code&amp;gt; call fails and the value of &amp;lt;code&amp;gt;seq_no&amp;lt;/code&amp;gt; doesn't get overwritten.  Then, we set up the &amp;lt;code&amp;gt;iov&amp;lt;/code&amp;gt; variable.  We set the &amp;lt;code&amp;gt;sectionID&amp;lt;/code&amp;gt;  field to &amp;lt;code&amp;gt;ckpt_sid&amp;lt;/code&amp;gt; which is the id of the section created in &amp;lt;code&amp;gt;checkpoint_initialize&amp;lt;/code&amp;gt;.  The &amp;lt;code&amp;gt;dataBuffer&amp;lt;/code&amp;gt; gets set to the address of the &amp;lt;code&amp;gt;seq_no&amp;lt;/code&amp;gt; variable which is where we want the checkpoint data loaded.  The &amp;lt;code&amp;gt;dataSize&amp;lt;/code&amp;gt; field is set to the the size of the &amp;lt;code&amp;gt;seq_no&amp;lt;/code&amp;gt; variable.  &amp;lt;code&amp;gt;DataOfset&amp;lt;/code&amp;gt; is set to zero since the sequence number is the only thing stored in the section, so it resides at the front of the section.  &amp;lt;code&amp;gt;readSize&amp;lt;/code&amp;gt; is set to the size of the sequence number variable.&lt;br /&gt;
&lt;br /&gt;
Within &amp;lt;code&amp;gt;checkpoint_read_seq&amp;lt;/code&amp;gt; we pass the iovector to &amp;lt;code&amp;gt;clCkptCheckpointRead&amp;lt;/code&amp;gt; along with the &amp;lt;code&amp;gt;ckpt_handle&amp;lt;/code&amp;gt;, the constant 1, and the address of the &amp;lt;code&amp;gt;err_idx&amp;lt;/code&amp;gt; variable.  The constant 1 is the number of elements in the array of &amp;lt;code&amp;gt;ClCkptIOVectorElementT structs&amp;lt;/code&amp;gt; that we're passing.  That is, we're passing the address of a single &amp;lt;code&amp;gt;ClCkptIOVectorElementT struct&amp;lt;/code&amp;gt;.  The &amp;lt;code&amp;gt;err_idx&amp;lt;/code&amp;gt; will hold the index in that array where &amp;lt;code&amp;gt;clCkptCheckpointRead&amp;lt;/code&amp;gt; found an error.  That is, if there is going to be an error, it will be at index 0 since we're only passing on entry in the &amp;lt;code&amp;gt;iovector&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffccaa;&amp;quot; align=&amp;quot;center&amp;quot;| clCompAppMain.c&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    static ClRcT&lt;br /&gt;
    checkpoint_replica_activate(void)&lt;br /&gt;
    {&lt;br /&gt;
        SaAisErrorT rc = SA_AIS_OK;&lt;br /&gt;
&lt;br /&gt;
        if ((rc = saCkptActiveReplicaSet(ckpt_handle)) != SA_AIS_OK)&lt;br /&gt;
        {&lt;br /&gt;
            clprintf(CL_LOG_SEV_ERROR,&lt;br /&gt;
                    &amp;quot;checkpoint_replica_activate failed [0x%x] in ActiveReplicaSet&amp;quot;,&lt;br /&gt;
                    rc);&lt;br /&gt;
        }&lt;br /&gt;
        else rc = CL_OK;&lt;br /&gt;
&lt;br /&gt;
        return rc;&lt;br /&gt;
    }&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===csa203===&lt;br /&gt;
&lt;br /&gt;
csa203 demonstrates the usage of SA Forum's Checkpointing service. This sample application does not deviate functionally from csa103. The code differences are due to using SA Forum data types (structures) and APIs , as presented in the following two tables. (Note we have not repeated data types and APIs covered previously.)&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|+align=&amp;quot;bottom&amp;quot;| '''SA Forum Data Types with the SAFplus Platform equivalent'''&lt;br /&gt;
|- style=&amp;quot;color:black;background-color:#ffffaa;&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
!SA Forum Data Types   &lt;br /&gt;
!OpenClovis Data Types&lt;br /&gt;
|-&lt;br /&gt;
|SaCkptHandleT&lt;br /&gt;
|ClCkptSvcHdlT&lt;br /&gt;
|-&lt;br /&gt;
|SaCkptHandleT&lt;br /&gt;
|ClCkptHdlT&lt;br /&gt;
|-&lt;br /&gt;
|SaCkptSectionIdT&lt;br /&gt;
|ClCkptSectionIdT&lt;br /&gt;
|-&lt;br /&gt;
|SaCkptCheckpointCreationAttributesT&lt;br /&gt;
|ClCkptCheckpointCreationAttributesT&lt;br /&gt;
|-&lt;br /&gt;
|SaCkptSectionCreationAttributesT&lt;br /&gt;
|ClCkptSectionCreationAttributesT&lt;br /&gt;
|-&lt;br /&gt;
|SaCkptIOVectorElementT&lt;br /&gt;
|ClCkptIOVectorElementT&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|+align=&amp;quot;bottom&amp;quot;| '''SA Forum APIs with the SAFplus Platform equivalent'''&lt;br /&gt;
|- style=&amp;quot;color:black;background-color:#ffffaa;&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
!SA Forum APIs&lt;br /&gt;
!OpenClovis APIs&lt;br /&gt;
|-&lt;br /&gt;
|saCkptInitialize&lt;br /&gt;
|clCkptInitialize&lt;br /&gt;
|-&lt;br /&gt;
|saCkptCheckpointOpen&lt;br /&gt;
|clCkptCheckpointOpen&lt;br /&gt;
|-&lt;br /&gt;
|saCkptSectionCreate&lt;br /&gt;
|clCkptSectionCreate&lt;br /&gt;
|-&lt;br /&gt;
|saCkptCheckpointClose&lt;br /&gt;
|clCkptCheckpointClose&lt;br /&gt;
|-&lt;br /&gt;
|saCkptFinalize&lt;br /&gt;
|clCkptFinalize&lt;br /&gt;
|-&lt;br /&gt;
|saCkptSectionOverwrite&lt;br /&gt;
|clCkptSectionOverwrite&lt;br /&gt;
|-&lt;br /&gt;
|saCkptCheckpointSynchronize&lt;br /&gt;
|clCkptCheckpointSynchronize&lt;br /&gt;
|-&lt;br /&gt;
|saCkptCheckpointRead&lt;br /&gt;
|clCkptCheckpointRead&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===How to Run csa103 and What to Observe===&lt;br /&gt;
&lt;br /&gt;
This sample application can run on all Runtime Hardware Setups. The following, lists which node &amp;lt;code&amp;gt;csa103compI*&amp;lt;/code&amp;gt; runs on.&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;'''Runtime Hardware Setup 1.1 and 2.1'''&lt;br /&gt;
&amp;lt;br&amp;gt;csa103compI0 and csa103compI1 will run upon the single node.&lt;br /&gt;
&amp;lt;li&amp;gt;'''Runtime Hardware Setup 1.2 and 2.2'''&lt;br /&gt;
&amp;lt;br&amp;gt;csa103compI0 runs on PayloadNodeI0 and csa103compI1 runs on PayloadNodeI1&lt;br /&gt;
&amp;lt;li&amp;gt;'''Runtime Hardware Setup 1.3 and 2.3'''&lt;br /&gt;
&amp;lt;br&amp;gt;csa103compI2 and csa103compI3 run on SCNodeI0 and SCNodeI1 respectively. csa103compI0 and csa103compI1 run on PayloadNodeI0 and PayloadNodeI1 respectively.&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;In the four node set up SCNodeI0 and SCNodeI1 output data via &amp;lt;code&amp;gt;/root/asp/var/log/csa103CompI2&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;/root/asp/var/log/csa103CompI3&amp;lt;/code&amp;gt; respectively. Therefore in this case follow the below instructions replacing csa103CompI0 and csa103compI1 with csa103compI2 and csa103compI3 respectively.&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We run csa103 very much the same way we run any of the rest of the sample applications: with the SAFplus Platform Console.&lt;br /&gt;
  &lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;First, on the active System Controller move it to state LockAssignment with (Unlock csa203SGI0 instead of csa103SGI0 to run csa203)&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
cli[Test]-&amp;gt; setc 1&lt;br /&gt;
cli[Test:SCNodeI0]-&amp;gt; setc cpm&lt;br /&gt;
cli[Test:SCNodeI0:CPM]-&amp;gt; amsLockAssignment sg csa103SGI0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The following output is given when you run &amp;lt;code&amp;gt;tail -f&amp;lt;/code&amp;gt; on the csa103 log files. For example:&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
# tail -f /root/asp/var/log/csa103CompI0.log&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffffaa;&amp;quot; align=&amp;quot;center&amp;quot;| /root/asp/var/log/csa103CompI0Log.latest&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
Mon Jul 14 00:01:09 2008   (SCNodeI0.15238 : csa103CompEO.---.---.00030 :   INFO)&lt;br /&gt;
 Component [csa103CompI0] : PID [15238]. Initializing&lt;br /&gt;
Mon Jul 14 00:01:09 2008   (SCNodeI0.15238 : csa103CompEO.---.---.00031 :   INFO)&lt;br /&gt;
    IOC Address             : 0x1&lt;br /&gt;
Mon Jul 14 00:01:09 2008   (SCNodeI0.15238 : csa103CompEO.---.---.00032 :   INFO)&lt;br /&gt;
    IOC Port                : 0x81&lt;br /&gt;
Mon Jul 14 00:01:09 2008   (SCNodeI0.15238 : csa103CompEO.---.---.00033 :   INFO)&lt;br /&gt;
 csa103: Instantiated as component instance csa103CompI0.&lt;br /&gt;
Mon Jul 14 00:01:09 2008   (SCNodeI0.15238 : csa103CompEO.---.---.00034 :   INFO)&lt;br /&gt;
 csa103CompI0: Waiting for CSI assignment...&lt;br /&gt;
Mon Jul 14 00:01:09 2008   (SCNodeI0.15238 : csa103CompEO.---.---.00035 :   INFO)&lt;br /&gt;
 csa103CompI0: Waiting for CSI assignment...&lt;br /&gt;
Mon Jul 14 00:01:09 2008   (SCNodeI0.15238 : csa103CompEO.---.---.00036 :   INFO)&lt;br /&gt;
 csa103CompI0: checkpoint_initialize&lt;br /&gt;
Mon Jul 14 00:01:10 2008   (SCNodeI0.15238 : csa103CompEO.---.---.00043 :   INFO)&lt;br /&gt;
 csa103CompI0: Checkpoint service initialized (handle=0x1)&lt;br /&gt;
Mon Jul 14 00:01:10 2008   (SCNodeI0.15238 : csa103CompEO.---.---.00045 :   INFO)&lt;br /&gt;
 csa103CompI0: Checkpoint opened (handle=0x2)&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
# tail -f /root/asp/var/log/csa103CompI1.log&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffffaa;&amp;quot; align=&amp;quot;center&amp;quot;| /root/asp/var/log/csa103CompI1Log.latest&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
Mon Jul 14 00:01:09 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00030 :   INFO)&lt;br /&gt;
 Component [csa103CompI1] : PID [15234]. Initializing&lt;br /&gt;
Mon Jul 14 00:01:09 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00031 :   INFO)&lt;br /&gt;
    IOC Address             : 0x1&lt;br /&gt;
Mon Jul 14 00:01:09 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00032 :   INFO)&lt;br /&gt;
    IOC Port                : 0x80&lt;br /&gt;
Mon Jul 14 00:01:09 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00033 :   INFO)&lt;br /&gt;
 csa103: Instantiated as component instance csa103CompI1.&lt;br /&gt;
Mon Jul 14 00:01:09 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00034 :   INFO)&lt;br /&gt;
 csa103CompI1: Waiting for CSI assignment...&lt;br /&gt;
Mon Jul 14 00:01:09 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00035 :   INFO)&lt;br /&gt;
 csa103CompI1: Waiting for CSI assignment...&lt;br /&gt;
Mon Jul 14 00:01:09 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00036 :   INFO)&lt;br /&gt;
 csa103CompI1: checkpoint_initialize&lt;br /&gt;
Mon Jul 14 00:01:09 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00043 :   INFO)&lt;br /&gt;
 csa103CompI1: Checkpoint service initialized (handle=0x1)&lt;br /&gt;
Mon Jul 14 00:01:09 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00045 :   INFO)&lt;br /&gt;
 csa103CompI1: Checkpoint opened (handle=0x2)&lt;br /&gt;
Mon Jul 14 00:01:09 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00053 :   INFO)&lt;br /&gt;
 csa103CompI1: Section created&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;Then, unlock the application by running &lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
cli[Test:SCNodeI0:CPM]-&amp;gt; amsUnlock sg csa103SGI0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the application log files, you should see &lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffffaa;&amp;quot; align=&amp;quot;center&amp;quot;| /root/asp/var/log/csa103CompI0Log.latest&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
Mon Jul 14 00:09:08 2008   (SCNodeI0.15238 : csa103CompEO.---.---.00058 :   INFO)&lt;br /&gt;
  Standby state requested from state 0&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffffaa;&amp;quot; align=&amp;quot;center&amp;quot;| /root/asp/var/log/csa103CompI1Log.latest&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
Mon Jul 14 00:09:08 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00064 :   INFO)&lt;br /&gt;
 csa103CompI1: Active state requested from state 0&lt;br /&gt;
Mon Jul 14 00:09:09 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00065 :   INFO)&lt;br /&gt;
 csa103CompI1: Hello World! (seq=0)&lt;br /&gt;
Mon Jul 14 00:09:10 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00066 :   INFO)&lt;br /&gt;
 csa103CompI1: Hello World! (seq=1)&lt;br /&gt;
Mon Jul 14 00:09:11 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00067 :   INFO)&lt;br /&gt;
 csa103CompI1: Hello World! (seq=2)&lt;br /&gt;
Mon Jul 14 00:09:12 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00068 :   INFO)&lt;br /&gt;
 csa103CompI1: Hello World! (seq=3)&lt;br /&gt;
Mon Jul 14 00:09:13 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00069 :   INFO)&lt;br /&gt;
 csa103CompI1: Hello World! (seq=4)&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;Next, find the active csa103 process, the one that's printing the Hello World lines and kill it.  To find the process ID issue the following command from a bash shell.&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
 # ps -eaf | grep csa103&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
This should produce an output that looks similar to the following.&lt;br /&gt;
 root     17830 15663  0 14:21 ?        00:00:00 csa103Comp -p&lt;br /&gt;
 root     17839 15663  0 14:21 ?        00:00:00 csa103Comp -p&lt;br /&gt;
 root     18558 16145  0 14:32 pts/4    00:00:00 grep csa103&lt;br /&gt;
Notice the two entries that end with csa103Comp -p. These are our two component processes. The first one is usually the active process. This is the one that we will kill. In this case the process ID is 17830. So to kill the active component you issue the command:&lt;br /&gt;
&lt;br /&gt;
 # kill -9 17830&lt;br /&gt;
&lt;br /&gt;
[[File:OpenClovis_Note.png]]If this step does not result in the active component being killed then it is likely that the standby component was killed. In this case simply try killing the other process. &lt;br /&gt;
&lt;br /&gt;
After killing the active component you should see lines in the log files like the following:&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffffaa;&amp;quot; align=&amp;quot;center&amp;quot;| /root/asp/var/log/csa103CompI1Log.latest&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
Mon Jul 14 00:16:43 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00515 :   INFO)&lt;br /&gt;
 csa103CompI1: Hello World! (seq=452)&lt;br /&gt;
Mon Jul 14 00:16:44 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00516 :   INFO)&lt;br /&gt;
 csa103CompI1: Hello World! (seq=453)&lt;br /&gt;
Mon Jul 14 00:16:45 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00517 :   INFO)&lt;br /&gt;
 csa103CompI1: Hello World! (seq=454)&lt;br /&gt;
Mon Jul 14 00:16:46 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00518 :   INFO)&lt;br /&gt;
 csa103CompI1: Hello World! (seq=455)&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffffaa;&amp;quot; align=&amp;quot;center&amp;quot;| /var/log/csa103CompI0Log.latest&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
Mon Jul 14 00:16:48 2008   (SCNodeI0.15238 : csa103CompEO.---.---.00065 :   INFO)&lt;br /&gt;
 csa103CompI0: Active state requested from state 2&lt;br /&gt;
Mon Jul 14 00:16:48 2008   (SCNodeI0.15238 : csa103CompEO.---.---.00066 :   INFO)&lt;br /&gt;
 csa103CompI0 reading checkpoint&lt;br /&gt;
Mon Jul 14 00:16:48 2008   (SCNodeI0.15238 : csa103CompEO.---.---.00067 :   INFO)&lt;br /&gt;
 csa103CompI0 read checkpoint: seq = 456&lt;br /&gt;
Mon Jul 14 00:16:49 2008   (SCNodeI0.15238 : csa103CompEO.---.---.00068 :   INFO)&lt;br /&gt;
 csa103CompI0: Hello World! (seq=456)&lt;br /&gt;
Mon Jul 14 00:16:50 2008   (SCNodeI0.15238 : csa103CompEO.---.---.00069 :   INFO)&lt;br /&gt;
 csa103CompI0: Hello World! (seq=457)&lt;br /&gt;
Mon Jul 14 00:16:51 2008   (SCNodeI0.15238 : csa103CompEO.---.---.00070 :   INFO)&lt;br /&gt;
 csa103CompI0: Hello World! (seq=458)&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
Where we can see CompI1 printing 455 and then dieing, where upon CompI0 gets the notice to take over processing, reads the checkpoint and then takes over with seq=456 and so on.&lt;br /&gt;
&lt;br /&gt;
Then, in the CompI1 log file we see:&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffffaa;&amp;quot; align=&amp;quot;center&amp;quot;| /root/asp/var/log/csa103CompI1Log.latest&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
Mon Jul 14 00:16:49 2008   (SCNodeI0.15553 : csa103CompEO.---.---.00044 :   INFO)&lt;br /&gt;
 csa103: Instantiated as component instance csa103CompI1.&lt;br /&gt;
Mon Jul 14 00:16:49 2008   (SCNodeI0.15553 : csa103CompEO.---.---.00045 :   INFO)&lt;br /&gt;
 csa103CompI1: Waiting for CSI assignment...&lt;br /&gt;
Mon Jul 14 00:16:49 2008   (SCNodeI0.15553 : csa103CompEO.---.---.00046 :   INFO)&lt;br /&gt;
 csa103CompI1: Waiting for CSI assignment...&lt;br /&gt;
Mon Jul 14 00:16:49 2008   (SCNodeI0.15553 : csa103CompEO.---.---.00047 :   INFO)&lt;br /&gt;
 csa103CompI1: checkpoint_initialize&lt;br /&gt;
Mon Jul 14 00:16:50 2008   (SCNodeI0.15553 : csa103CompEO.---.---.00054 :   INFO)&lt;br /&gt;
 csa103CompI1: Checkpoint service initialized (handle=0x1)&lt;br /&gt;
Mon Jul 14 00:16:50 2008   (SCNodeI0.15553 : csa103CompEO.---.---.00056 :   INFO)&lt;br /&gt;
 csa103CompI1: Checkpoint opened (handle=0x2)&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
That is the component that had been killed being restarted.  &lt;br /&gt;
&lt;br /&gt;
CompI0 is moving along just fine, and we see CompI1 come back up.  If we then kill CompI0 we see:&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffffaa;&amp;quot; align=&amp;quot;center&amp;quot;| /root/asp/var/log/csa103CompI1Log.latest&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
Mon Jul 14 00:29:44 2008   (SCNodeI0.15553 : csa103CompEO.---.---.00065 :   INFO)&lt;br /&gt;
 csa103CompI1: Active state requested from state 2&lt;br /&gt;
Mon Jul 14 00:29:44 2008   (SCNodeI0.15553 : csa103CompEO.---.---.00066 :   INFO)&lt;br /&gt;
 csa103CompI1 reading checkpoint&lt;br /&gt;
Mon Jul 14 00:29:44 2008   (SCNodeI0.15553 : csa103CompEO.---.---.00067 :   INFO)&lt;br /&gt;
 csa103CompI1 read checkpoint: seq = 1225&lt;br /&gt;
Mon Jul 14 00:29:45 2008   (SCNodeI0.15553 : csa103CompEO.---.---.00068 :   INFO)&lt;br /&gt;
 csa103CompI1: Hello World! (seq=1225)&lt;br /&gt;
Mon Jul 14 00:29:46 2008   (SCNodeI0.15553 : csa103CompEO.---.---.00069 :   INFO)&lt;br /&gt;
 csa103CompI1: Hello World! (seq=1226)&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
Where we can see the CompI0 process die, and CompI1 process read the sequence number from the checkpoint and then take over from where CompI0 left off.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;To stop csa103 use the following SAFplus Platform Console command.&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
cli[Test:SCNodeI0:CPM]-&amp;gt; amsLockAssignment sg csa103SGI0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;Now change the state of csa103SGI0 to LockInstantiation and close the SAFplus Platform Console.&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
cli[Test:SCNodeI0:CPM]-&amp;gt; amsLockInstantiation sg csa103SGI0&lt;br /&gt;
cli[Test:SCNodeI0:CPM] -&amp;gt; end&lt;br /&gt;
cli[Test:SCNodeI0] -&amp;gt; end&lt;br /&gt;
cli[Test] -&amp;gt; bye&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===csa203===&lt;br /&gt;
&lt;br /&gt;
csa203 demonstrates the usage of SA Forum's Checkpointing service. This sample application does not deviate functionally from csa103. The code differences are due to using SA Forum data types (structures) and APIs , as presented in the following two tables. (Note we have not repeated data types and APIs covered previously.)&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|+align=&amp;quot;bottom&amp;quot;| '''SA Forum Data Types with the SAFplus Platform equivalent'''&lt;br /&gt;
|- style=&amp;quot;color:black;background-color:#ffffaa;&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
!SA Forum Data Types   &lt;br /&gt;
!OpenClovis Data Types&lt;br /&gt;
|-&lt;br /&gt;
|SaCkptHandleT&lt;br /&gt;
|ClCkptSvcHdlT&lt;br /&gt;
|-&lt;br /&gt;
|SaCkptHandleT&lt;br /&gt;
|ClCkptHdlT&lt;br /&gt;
|-&lt;br /&gt;
|SaCkptSectionIdT&lt;br /&gt;
|ClCkptSectionIdT&lt;br /&gt;
|-&lt;br /&gt;
|SaCkptCheckpointCreationAttributesT&lt;br /&gt;
|ClCkptCheckpointCreationAttributesT&lt;br /&gt;
|-&lt;br /&gt;
|SaCkptSectionCreationAttributesT&lt;br /&gt;
|ClCkptSectionCreationAttributesT&lt;br /&gt;
|-&lt;br /&gt;
|SaCkptIOVectorElementT&lt;br /&gt;
|ClCkptIOVectorElementT&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|+align=&amp;quot;bottom&amp;quot;| '''SA Forum APIs with the SAFplus Platform equivalent'''&lt;br /&gt;
|- style=&amp;quot;color:black;background-color:#ffffaa;&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
!SA Forum APIs&lt;br /&gt;
!OpenClovis APIs&lt;br /&gt;
|-&lt;br /&gt;
|saCkptInitialize&lt;br /&gt;
|clCkptInitialize&lt;br /&gt;
|-&lt;br /&gt;
|saCkptCheckpointOpen&lt;br /&gt;
|clCkptCheckpointOpen&lt;br /&gt;
|-&lt;br /&gt;
|saCkptSectionCreate&lt;br /&gt;
|clCkptSectionCreate&lt;br /&gt;
|-&lt;br /&gt;
|saCkptCheckpointClose&lt;br /&gt;
|clCkptCheckpointClose&lt;br /&gt;
|-&lt;br /&gt;
|saCkptFinalize&lt;br /&gt;
|clCkptFinalize&lt;br /&gt;
|-&lt;br /&gt;
|saCkptSectionOverwrite&lt;br /&gt;
|clCkptSectionOverwrite&lt;br /&gt;
|-&lt;br /&gt;
|saCkptCheckpointSynchronize&lt;br /&gt;
|clCkptCheckpointSynchronize&lt;br /&gt;
|-&lt;br /&gt;
|saCkptCheckpointRead&lt;br /&gt;
|clCkptCheckpointRead&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===How to Run csa103 and What to Observe===&lt;br /&gt;
&lt;br /&gt;
This sample application can run on all Runtime Hardware Setups. The following, lists which node &amp;lt;code&amp;gt;csa103compI*&amp;lt;/code&amp;gt; runs on.&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;'''Runtime Hardware Setup 1.1 and 2.1'''&lt;br /&gt;
&amp;lt;br&amp;gt;csa103compI0 and csa103compI1 will run upon the single node.&lt;br /&gt;
&amp;lt;li&amp;gt;'''Runtime Hardware Setup 1.2 and 2.2'''&lt;br /&gt;
&amp;lt;br&amp;gt;csa103compI0 runs on PayloadNodeI0 and csa103compI1 runs on PayloadNodeI1&lt;br /&gt;
&amp;lt;li&amp;gt;'''Runtime Hardware Setup 1.3 and 2.3'''&lt;br /&gt;
&amp;lt;br&amp;gt;csa103compI2 and csa103compI3 run on SCNodeI0 and SCNodeI1 respectively. csa103compI0 and csa103compI1 run on PayloadNodeI0 and PayloadNodeI1 respectively.&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;In the four node set up SCNodeI0 and SCNodeI1 output data via &amp;lt;code&amp;gt;/root/asp/var/log/csa103CompI2&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;/root/asp/var/log/csa103CompI3&amp;lt;/code&amp;gt; respectively. Therefore in this case follow the below instructions replacing csa103CompI0 and csa103compI1 with csa103compI2 and csa103compI3 respectively.&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We run csa103 very much the same way we run any of the rest of the sample applications: with the SAFplus Platform Console.&lt;br /&gt;
  &lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;First, on the active System Controller move it to state LockAssignment with (Unlock csa203SGI0 instead of csa103SGI0 to run csa203)&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
cli[Test]-&amp;gt; setc 1&lt;br /&gt;
cli[Test:SCNodeI0]-&amp;gt; setc cpm&lt;br /&gt;
cli[Test:SCNodeI0:CPM]-&amp;gt; amsLockAssignment sg csa103SGI0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The following output is given when you run &amp;lt;code&amp;gt;tail -f&amp;lt;/code&amp;gt; on the csa103 log files. For example:&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
# tail -f /root/asp/var/log/csa103CompI0.log&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffffaa;&amp;quot; align=&amp;quot;center&amp;quot;| /root/asp/var/log/csa103CompI0Log.latest&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
Mon Jul 14 00:01:09 2008   (SCNodeI0.15238 : csa103CompEO.---.---.00030 :   INFO)&lt;br /&gt;
 Component [csa103CompI0] : PID [15238]. Initializing&lt;br /&gt;
Mon Jul 14 00:01:09 2008   (SCNodeI0.15238 : csa103CompEO.---.---.00031 :   INFO)&lt;br /&gt;
    IOC Address             : 0x1&lt;br /&gt;
Mon Jul 14 00:01:09 2008   (SCNodeI0.15238 : csa103CompEO.---.---.00032 :   INFO)&lt;br /&gt;
    IOC Port                : 0x81&lt;br /&gt;
Mon Jul 14 00:01:09 2008   (SCNodeI0.15238 : csa103CompEO.---.---.00033 :   INFO)&lt;br /&gt;
 csa103: Instantiated as component instance csa103CompI0.&lt;br /&gt;
Mon Jul 14 00:01:09 2008   (SCNodeI0.15238 : csa103CompEO.---.---.00034 :   INFO)&lt;br /&gt;
 csa103CompI0: Waiting for CSI assignment...&lt;br /&gt;
Mon Jul 14 00:01:09 2008   (SCNodeI0.15238 : csa103CompEO.---.---.00035 :   INFO)&lt;br /&gt;
 csa103CompI0: Waiting for CSI assignment...&lt;br /&gt;
Mon Jul 14 00:01:09 2008   (SCNodeI0.15238 : csa103CompEO.---.---.00036 :   INFO)&lt;br /&gt;
 csa103CompI0: checkpoint_initialize&lt;br /&gt;
Mon Jul 14 00:01:10 2008   (SCNodeI0.15238 : csa103CompEO.---.---.00043 :   INFO)&lt;br /&gt;
 csa103CompI0: Checkpoint service initialized (handle=0x1)&lt;br /&gt;
Mon Jul 14 00:01:10 2008   (SCNodeI0.15238 : csa103CompEO.---.---.00045 :   INFO)&lt;br /&gt;
 csa103CompI0: Checkpoint opened (handle=0x2)&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
# tail -f /root/asp/var/log/csa103CompI1.log&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffffaa;&amp;quot; align=&amp;quot;center&amp;quot;| /root/asp/var/log/csa103CompI1Log.latest&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
Mon Jul 14 00:01:09 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00030 :   INFO)&lt;br /&gt;
 Component [csa103CompI1] : PID [15234]. Initializing&lt;br /&gt;
Mon Jul 14 00:01:09 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00031 :   INFO)&lt;br /&gt;
    IOC Address             : 0x1&lt;br /&gt;
Mon Jul 14 00:01:09 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00032 :   INFO)&lt;br /&gt;
    IOC Port                : 0x80&lt;br /&gt;
Mon Jul 14 00:01:09 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00033 :   INFO)&lt;br /&gt;
 csa103: Instantiated as component instance csa103CompI1.&lt;br /&gt;
Mon Jul 14 00:01:09 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00034 :   INFO)&lt;br /&gt;
 csa103CompI1: Waiting for CSI assignment...&lt;br /&gt;
Mon Jul 14 00:01:09 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00035 :   INFO)&lt;br /&gt;
 csa103CompI1: Waiting for CSI assignment...&lt;br /&gt;
Mon Jul 14 00:01:09 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00036 :   INFO)&lt;br /&gt;
 csa103CompI1: checkpoint_initialize&lt;br /&gt;
Mon Jul 14 00:01:09 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00043 :   INFO)&lt;br /&gt;
 csa103CompI1: Checkpoint service initialized (handle=0x1)&lt;br /&gt;
Mon Jul 14 00:01:09 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00045 :   INFO)&lt;br /&gt;
 csa103CompI1: Checkpoint opened (handle=0x2)&lt;br /&gt;
Mon Jul 14 00:01:09 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00053 :   INFO)&lt;br /&gt;
 csa103CompI1: Section created&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;Then, unlock the application by running &lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
cli[Test:SCNodeI0:CPM]-&amp;gt; amsUnlock sg csa103SGI0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the application log files, you should see &lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffffaa;&amp;quot; align=&amp;quot;center&amp;quot;| /root/asp/var/log/csa103CompI0Log.latest&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
Mon Jul 14 00:09:08 2008   (SCNodeI0.15238 : csa103CompEO.---.---.00058 :   INFO)&lt;br /&gt;
  Standby state requested from state 0&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffffaa;&amp;quot; align=&amp;quot;center&amp;quot;| /root/asp/var/log/csa103CompI1Log.latest&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
Mon Jul 14 00:09:08 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00064 :   INFO)&lt;br /&gt;
 csa103CompI1: Active state requested from state 0&lt;br /&gt;
Mon Jul 14 00:09:09 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00065 :   INFO)&lt;br /&gt;
 csa103CompI1: Hello World! (seq=0)&lt;br /&gt;
Mon Jul 14 00:09:10 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00066 :   INFO)&lt;br /&gt;
 csa103CompI1: Hello World! (seq=1)&lt;br /&gt;
Mon Jul 14 00:09:11 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00067 :   INFO)&lt;br /&gt;
 csa103CompI1: Hello World! (seq=2)&lt;br /&gt;
Mon Jul 14 00:09:12 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00068 :   INFO)&lt;br /&gt;
 csa103CompI1: Hello World! (seq=3)&lt;br /&gt;
Mon Jul 14 00:09:13 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00069 :   INFO)&lt;br /&gt;
 csa103CompI1: Hello World! (seq=4)&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;Next, find the active csa103 process, the one that's printing the Hello World lines and kill it.  To find the process ID issue the following command from a bash shell.&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
 # ps -eaf | grep csa103&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
This should produce an output that looks similar to the following.&lt;br /&gt;
 root     17830 15663  0 14:21 ?        00:00:00 csa103Comp -p&lt;br /&gt;
 root     17839 15663  0 14:21 ?        00:00:00 csa103Comp -p&lt;br /&gt;
 root     18558 16145  0 14:32 pts/4    00:00:00 grep csa103&lt;br /&gt;
Notice the two entries that end with csa103Comp -p. These are our two component processes. The first one is usually the active process. This is the one that we will kill. In this case the process ID is 17830. So to kill the active component you issue the command:&lt;br /&gt;
&lt;br /&gt;
 # kill -9 17830&lt;br /&gt;
&lt;br /&gt;
[[File:OpenClovis_Note.png]]If this step does not result in the active component being killed then it is likely that the standby component was killed. In this case simply try killing the other process. &lt;br /&gt;
&lt;br /&gt;
After killing the active component you should see lines in the log files like the following:&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffffaa;&amp;quot; align=&amp;quot;center&amp;quot;| /root/asp/var/log/csa103CompI1Log.latest&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
Mon Jul 14 00:16:43 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00515 :   INFO)&lt;br /&gt;
 csa103CompI1: Hello World! (seq=452)&lt;br /&gt;
Mon Jul 14 00:16:44 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00516 :   INFO)&lt;br /&gt;
 csa103CompI1: Hello World! (seq=453)&lt;br /&gt;
Mon Jul 14 00:16:45 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00517 :   INFO)&lt;br /&gt;
 csa103CompI1: Hello World! (seq=454)&lt;br /&gt;
Mon Jul 14 00:16:46 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00518 :   INFO)&lt;br /&gt;
 csa103CompI1: Hello World! (seq=455)&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffffaa;&amp;quot; align=&amp;quot;center&amp;quot;| /var/log/csa103CompI0Log.latest&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
Mon Jul 14 00:16:48 2008   (SCNodeI0.15238 : csa103CompEO.---.---.00065 :   INFO)&lt;br /&gt;
 csa103CompI0: Active state requested from state 2&lt;br /&gt;
Mon Jul 14 00:16:48 2008   (SCNodeI0.15238 : csa103CompEO.---.---.00066 :   INFO)&lt;br /&gt;
 csa103CompI0 reading checkpoint&lt;br /&gt;
Mon Jul 14 00:16:48 2008   (SCNodeI0.15238 : csa103CompEO.---.---.00067 :   INFO)&lt;br /&gt;
 csa103CompI0 read checkpoint: seq = 456&lt;br /&gt;
Mon Jul 14 00:16:49 2008   (SCNodeI0.15238 : csa103CompEO.---.---.00068 :   INFO)&lt;br /&gt;
 csa103CompI0: Hello World! (seq=456)&lt;br /&gt;
Mon Jul 14 00:16:50 2008   (SCNodeI0.15238 : csa103CompEO.---.---.00069 :   INFO)&lt;br /&gt;
 csa103CompI0: Hello World! (seq=457)&lt;br /&gt;
Mon Jul 14 00:16:51 2008   (SCNodeI0.15238 : csa103CompEO.---.---.00070 :   INFO)&lt;br /&gt;
 csa103CompI0: Hello World! (seq=458)&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
Where we can see CompI1 printing 455 and then dieing, where upon CompI0 gets the notice to take over processing, reads the checkpoint and then takes over with seq=456 and so on.&lt;br /&gt;
&lt;br /&gt;
Then, in the CompI1 log file we see:&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffffaa;&amp;quot; align=&amp;quot;center&amp;quot;| /root/asp/var/log/csa103CompI1Log.latest&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
Mon Jul 14 00:16:49 2008   (SCNodeI0.15553 : csa103CompEO.---.---.00044 :   INFO)&lt;br /&gt;
 csa103: Instantiated as component instance csa103CompI1.&lt;br /&gt;
Mon Jul 14 00:16:49 2008   (SCNodeI0.15553 : csa103CompEO.---.---.00045 :   INFO)&lt;br /&gt;
 csa103CompI1: Waiting for CSI assignment...&lt;br /&gt;
Mon Jul 14 00:16:49 2008   (SCNodeI0.15553 : csa103CompEO.---.---.00046 :   INFO)&lt;br /&gt;
 csa103CompI1: Waiting for CSI assignment...&lt;br /&gt;
Mon Jul 14 00:16:49 2008   (SCNodeI0.15553 : csa103CompEO.---.---.00047 :   INFO)&lt;br /&gt;
 csa103CompI1: checkpoint_initialize&lt;br /&gt;
Mon Jul 14 00:16:50 2008   (SCNodeI0.15553 : csa103CompEO.---.---.00054 :   INFO)&lt;br /&gt;
 csa103CompI1: Checkpoint service initialized (handle=0x1)&lt;br /&gt;
Mon Jul 14 00:16:50 2008   (SCNodeI0.15553 : csa103CompEO.---.---.00056 :   INFO)&lt;br /&gt;
 csa103CompI1: Checkpoint opened (handle=0x2)&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
That is the component that had been killed being restarted.  &lt;br /&gt;
&lt;br /&gt;
CompI0 is moving along just fine, and we see CompI1 come back up.  If we then kill CompI0 we see:&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffffaa;&amp;quot; align=&amp;quot;center&amp;quot;| /root/asp/var/log/csa103CompI1Log.latest&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
Mon Jul 14 00:29:44 2008   (SCNodeI0.15553 : csa103CompEO.---.---.00065 :   INFO)&lt;br /&gt;
 csa103CompI1: Active state requested from state 2&lt;br /&gt;
Mon Jul 14 00:29:44 2008   (SCNodeI0.15553 : csa103CompEO.---.---.00066 :   INFO)&lt;br /&gt;
 csa103CompI1 reading checkpoint&lt;br /&gt;
Mon Jul 14 00:29:44 2008   (SCNodeI0.15553 : csa103CompEO.---.---.00067 :   INFO)&lt;br /&gt;
 csa103CompI1 read checkpoint: seq = 1225&lt;br /&gt;
Mon Jul 14 00:29:45 2008   (SCNodeI0.15553 : csa103CompEO.---.---.00068 :   INFO)&lt;br /&gt;
 csa103CompI1: Hello World! (seq=1225)&lt;br /&gt;
Mon Jul 14 00:29:46 2008   (SCNodeI0.15553 : csa103CompEO.---.---.00069 :   INFO)&lt;br /&gt;
 csa103CompI1: Hello World! (seq=1226)&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
Where we can see the CompI0 process die, and CompI1 process read the sequence number from the checkpoint and then take over from where CompI0 left off.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;To stop csa103 use the following SAFplus Platform Console command.&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
cli[Test:SCNodeI0:CPM]-&amp;gt; amsLockAssignment sg csa103SGI0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;Now change the state of csa103SGI0 to LockInstantiation and close the SAFplus Platform Console.&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
cli[Test:SCNodeI0:CPM]-&amp;gt; amsLockInstantiation sg csa103SGI0&lt;br /&gt;
cli[Test:SCNodeI0:CPM] -&amp;gt; end&lt;br /&gt;
cli[Test:SCNodeI0] -&amp;gt; end&lt;br /&gt;
cli[Test] -&amp;gt; bye&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Additional Tests for Runtime Hardware Setup 1.3 and 2.3===&lt;br /&gt;
&lt;br /&gt;
Now repeat  the experiment till the stage before we kill  the active process  and follow these steps.&lt;br /&gt;
&lt;br /&gt;
'''Step A'''&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Stop SAFplus Platform on SCNodeI0 using &amp;lt;code&amp;gt;/etc/init.d/asp stop&amp;lt;/code&amp;gt;. Observer the logs &amp;lt;code&amp;gt;/root/asp/var/log/csa103CompI3Log.latest&amp;lt;/code&amp;gt; on SCNodeI1. This will become active  and start printing the hello world logs as above. &lt;br /&gt;
Note in this case active System Controller SCNode1 is still aware of PayloadNodeI0 and PayloadNodeI1.&lt;br /&gt;
&amp;lt;li&amp;gt;Start looking at the logs  for &amp;lt;code&amp;gt;/root/asp/var/log/csa103CompI0Log.latest&amp;lt;/code&amp;gt; in PayloadNodeI0. This will print the  standby  logs as  above.&lt;br /&gt;
&amp;lt;li&amp;gt;Stop  SAFplus Platform  on PayloadNodeI0  and start observing the logs on PayloadNodeI1 in &amp;lt;code&amp;gt;/root/asp/var/log/csa103CompI1Log.latest&amp;lt;/code&amp;gt; for standby.&lt;br /&gt;
In this case, you can see, via the active System Controller logs that PayloadNodeI0 is not active whilst PayloadNodeI1 is.&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Step B'''  For Hardware Setup 1.3 only&lt;br /&gt;
#Repeat A  with the slight exception  that the  blade running SCNodeI0  is  yanked out(&amp;lt;code&amp;gt;/etc/init.d/asp zap&amp;lt;/code&amp;gt;) instead of gracefully shutting  down SAFplus Platform in step 1.&lt;br /&gt;
&lt;br /&gt;
===Summary and References===&lt;br /&gt;
We've seen :&lt;br /&gt;
&lt;br /&gt;
*how to use Clovis' checkpoint service to save some program state and recover that state from a separate process&lt;br /&gt;
*how to initialize the client checkpoint library&lt;br /&gt;
*how to create and open checkpoints &lt;br /&gt;
*how to create and use sections in an opened checkpoint&lt;br /&gt;
&lt;br /&gt;
Further information can be found within the following: ''OpenClovis API Reference Guide''.&lt;/div&gt;</summary>
		<author><name>Madhu</name></author>	</entry>

	<entry>
		<id>https://help.openclovis.com/index.php/Doc:latest/evalguide/csa103</id>
		<title>Doc:latest/evalguide/csa103</title>
		<link rel="alternate" type="text/html" href="https://help.openclovis.com/index.php/Doc:latest/evalguide/csa103"/>
				<updated>2010-10-01T05:45:41Z</updated>
		
		<summary type="html">&lt;p&gt;Madhu: /* The Code */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==csa103 Checkpointing==&lt;br /&gt;
&lt;br /&gt;
===Objective===&lt;br /&gt;
&lt;br /&gt;
csa103 demonstrates how to use the Clovis Checkpoint service to provide basic failure recovery.  csa103 builds on csa102.&lt;br /&gt;
&lt;br /&gt;
===What Will You Learn===&lt;br /&gt;
&lt;br /&gt;
*how to initialize the checkpoint client library, &lt;br /&gt;
*how to create a checkpoint and  open a checkpoint, &lt;br /&gt;
*how to create a section in the checkpoint &lt;br /&gt;
*how to save data to the checkpoint section and read data from the checkpoint section.&lt;br /&gt;
&lt;br /&gt;
===The Code===&lt;br /&gt;
&lt;br /&gt;
The code can be found within the following directory&lt;br /&gt;
 &amp;lt;project-area_dir&amp;gt;/eval/src/app/csa103Comp&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffccaa;&amp;quot; align=&amp;quot;center&amp;quot;| clCompAppMain.c&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
ClCompAppInitialize()&lt;br /&gt;
&lt;br /&gt;
        ...&lt;br /&gt;
&lt;br /&gt;
        if ((rc = checkpoint_initialize()) != SA_AIS_OK)&lt;br /&gt;
        {&lt;br /&gt;
            clprintf(CL_LOG_SEV_ERROR,&amp;quot;%s: Failed [0x%x] to initialize checkpoint&amp;quot;,&lt;br /&gt;
                    appname, rc);&lt;br /&gt;
            return rc;&lt;br /&gt;
        }&lt;br /&gt;
        if ((rc = checkpoint_read_seq(&amp;amp;seq)) != SA_AIS_OK)&lt;br /&gt;
        {&lt;br /&gt;
            clprintf(CL_LOG_SEV_ERROR,&amp;quot;%s: Failed [0x%x] to read checkpoint&amp;quot;,&lt;br /&gt;
                    appname, rc);&lt;br /&gt;
            checkpoint_finalize();&lt;br /&gt;
            return rc;&lt;br /&gt;
        }&lt;br /&gt;
    #ifdef CL_INST&lt;br /&gt;
        if ((rc = clDataTapInit(DATA_TAP_DEFAULT_FLAGS, 103)) != SA_AIS_OK)&lt;br /&gt;
        {&lt;br /&gt;
            clprintf(CL_LOG_SEV_ERROR,&amp;quot;%s: Failed [0x%x] to initialize data tap&amp;quot;,&lt;br /&gt;
                    appname, rc);&lt;br /&gt;
        }&lt;br /&gt;
    #endif&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
The above software in &amp;lt;code&amp;gt;clCompAppMain.c&amp;lt;/code&amp;gt; is new to csa103. The call to &amp;lt;code&amp;gt;checkpoint_initialize&amp;lt;/code&amp;gt; is pretty straightforward.  This function discussed in detail later within this section.  The call to &amp;lt;code&amp;gt;checkpoint_read_seq&amp;lt;/code&amp;gt; is also pretty straightforward.  It reads the current sequence value from the checkpoint (at this point it should be zero) and loads it into the variable: &amp;lt;code&amp;gt;seq&amp;lt;/code&amp;gt;.  It is important to note the call to &amp;lt;code&amp;gt;checkpont_finalize&amp;lt;/code&amp;gt; if the call to &amp;lt;code&amp;gt;checkpoint_read_seq&amp;lt;/code&amp;gt; does not return &amp;lt;code&amp;gt;CL_OK&amp;lt;/code&amp;gt;.  This call closes the checkpoint and cleanly finalizes the checkpoint library.  We'll look more at &amp;lt;code&amp;gt;checkpoint_read_seq&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;checkpoint_finalize&amp;lt;/code&amp;gt; later.&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffccaa;&amp;quot; align=&amp;quot;center&amp;quot;| clCompAppMain.c&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
        /* Checkpoint new sequence number */&lt;br /&gt;
        rc = checkpoint_write_seq(seq);&lt;br /&gt;
        if (rc != SA_AIS_OK)&lt;br /&gt;
        {&lt;br /&gt;
            clprintf(CL_LOG_SEV_ERROR,&amp;quot;%s: ERROR: Checkpoint write failed. Exiting.&amp;quot;, appname);&lt;br /&gt;
            break;&lt;br /&gt;
        }&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
The rest of the csa103's main loop is the same as the main loop in csa102, but the seven lines above are new.  Here we write the new value of the checkpoint variable to the checkpoint section and print and error if this fails.  We'll look closer at &amp;lt;code&amp;gt;checkpoint_write_seq&amp;lt;/code&amp;gt; later.&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffccaa;&amp;quot; align=&amp;quot;center&amp;quot;| clCompAppMain.c&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
    ClRcT&lt;br /&gt;
    clCompAppAMFCSISet(&lt;br /&gt;
        ClInvocationT       invocation,&lt;br /&gt;
        const ClNameT       *compName,&lt;br /&gt;
        ClAmsHAStateT       haState,&lt;br /&gt;
        ClAmsCSIDescriptorT csiDescriptor)&lt;br /&gt;
    {    &lt;br /&gt;
        /*&lt;br /&gt;
         * ---BEGIN_APPLICATION_CODE--- &lt;br /&gt;
         */&lt;br /&gt;
        ClCharT     compname[100]={0};&lt;br /&gt;
&lt;br /&gt;
        /*&lt;br /&gt;
         * ---END_APPLICATION_CODE---&lt;br /&gt;
         */&lt;br /&gt;
&lt;br /&gt;
        /*&lt;br /&gt;
         * Print information about the CSI Set&lt;br /&gt;
         */&lt;br /&gt;
        strncpy(compname, compName-&amp;gt;value, compName-&amp;gt;length);&lt;br /&gt;
&lt;br /&gt;
        clprintf (CL_LOG_SEV_INFO, &amp;quot;Component [%s] : PID [%d]. CSI Set Received&amp;quot;, &lt;br /&gt;
              compname, (int)mypid);&lt;br /&gt;
&lt;br /&gt;
        clCompAppAMFPrintCSI(csiDescriptor, haState);&lt;br /&gt;
    &lt;br /&gt;
        /*&lt;br /&gt;
          Take appropriate action based on state&lt;br /&gt;
        */&lt;br /&gt;
    &lt;br /&gt;
        switch ( haState )&lt;br /&gt;
        {&lt;br /&gt;
            case CL_AMS_HA_STATE_ACTIVE:&lt;br /&gt;
            {&lt;br /&gt;
                /*&lt;br /&gt;
                  AMF has requested application to take the active HA state&lt;br /&gt;
                  for the CSI.&lt;br /&gt;
                */&lt;br /&gt;
    &lt;br /&gt;
                /*&lt;br /&gt;
                  ---BEGIN_APPLICATION_CODE---&lt;br /&gt;
                */&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffccaa;&amp;quot; align=&amp;quot;center&amp;quot;| clCompAppMain.c&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;   &lt;br /&gt;
                clprintf(CL_LOG_SEV_INFO,&amp;quot;%s: Active state requested from state %d&amp;quot;,&lt;br /&gt;
                        appname, ha_state);&lt;br /&gt;
&lt;br /&gt;
                if (ha_state == SA_AMF_HA_STANDBY)&lt;br /&gt;
                {&lt;br /&gt;
                    /* Read checkpoint, make our replica the active replica */&lt;br /&gt;
                    clprintf(CL_LOG_SEV_INFO,&amp;quot;%s reading checkpoint&amp;quot;, appname);&lt;br /&gt;
                    rc = checkpoint_read_seq(&amp;amp;seq);&lt;br /&gt;
                    clprintf(CL_LOG_SEV_INFO,&amp;quot;%s read checkpoint: seq = %u&amp;quot;, appname, seq);&lt;br /&gt;
                }&lt;br /&gt;
                checkpoint_replica_activate();            &lt;br /&gt;
                ha_state = SA_AMF_HA_ACTIVE;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
                /*&lt;br /&gt;
                 * ---END_APPLICATION_CODE---&lt;br /&gt;
                 */&lt;br /&gt;
&lt;br /&gt;
                clCpmResponse(cpmHandle, invocation, CL_OK);&lt;br /&gt;
                break;&lt;br /&gt;
            }&lt;br /&gt;
&lt;br /&gt;
            case CL_AMS_HA_STATE_STANDBY:&lt;br /&gt;
            {&lt;br /&gt;
                /*&lt;br /&gt;
                 * AMF has requested application to take the standby HA state &lt;br /&gt;
                 * for this CSI.&lt;br /&gt;
                 */&lt;br /&gt;
&lt;br /&gt;
                /*&lt;br /&gt;
                 * ---BEGIN_APPLICATION_CODE---&lt;br /&gt;
                 */&lt;br /&gt;
&lt;br /&gt;
                 clprintf(CL_LOG_SEV_INFO,&amp;quot; Standby state requested from state %d&amp;quot;,ha_state);&lt;br /&gt;
            &lt;br /&gt;
                 ha_state = SA_AMF_HA_STANDBY;&lt;br /&gt;
&lt;br /&gt;
                /*&lt;br /&gt;
                 * ---END_APPLICATION_CODE---&lt;br /&gt;
                 */&lt;br /&gt;
&lt;br /&gt;
                clCpmResponse(cpmHandle, invocation, CL_OK);&lt;br /&gt;
                break;&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffccaa;&amp;quot; align=&amp;quot;center&amp;quot;| clCompAppMain.c&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;    &lt;br /&gt;
            case CL_AMS_HA_STATE_QUIESCED:&lt;br /&gt;
            {&lt;br /&gt;
                /*&lt;br /&gt;
                 * AMF has requested application to quiesce the CSI currently&lt;br /&gt;
                 * assigned the active or quiescing HA state. The application &lt;br /&gt;
                 * must stop work associated with the CSI immediately.&lt;br /&gt;
                 */&lt;br /&gt;
&lt;br /&gt;
                /*&lt;br /&gt;
                 * ---BEGIN_APPLICATION_CODE---&lt;br /&gt;
                 */&lt;br /&gt;
&lt;br /&gt;
                clprintf(CL_LOG_SEV_INFO,&amp;quot;%s: QUIESCED&amp;quot;, appname);&lt;br /&gt;
                ha_state = haState;&lt;br /&gt;
&lt;br /&gt;
                /*&lt;br /&gt;
                 * ---END_APPLICATION_CODE---&lt;br /&gt;
                 */&lt;br /&gt;
&lt;br /&gt;
                clCpmResponse(cpmHandle, invocation, CL_OK);&lt;br /&gt;
                break;&lt;br /&gt;
            }&lt;br /&gt;
&lt;br /&gt;
            case CL_AMS_HA_STATE_QUIESCING:&lt;br /&gt;
            { &lt;br /&gt;
                /*&lt;br /&gt;
                 * AMF has requested application to quiesce the CSI currently&lt;br /&gt;
                 * assigned the active HA state. The application must stop work&lt;br /&gt;
                 * associated with the CSI gracefully and not accept any new&lt;br /&gt;
                 * workloads while the work is being terminated.&lt;br /&gt;
                 */&lt;br /&gt;
&lt;br /&gt;
                /*&lt;br /&gt;
                 * ---BEGIN_APPLICATION_CODE---&lt;br /&gt;
                 */&lt;br /&gt;
&lt;br /&gt;
                clprintf(CL_LOG_SEV_INFO,&amp;quot;%s: QUIESCING&amp;quot;, appname);&lt;br /&gt;
                ha_state = haState;&lt;br /&gt;
&lt;br /&gt;
                /*&lt;br /&gt;
                 * ---END_APPLICATION_CODE---&lt;br /&gt;
                 */&lt;br /&gt;
&lt;br /&gt;
                clCpmCSIQuiescingComplete(cpmHandle, invocation, CL_OK);&lt;br /&gt;
                break;&lt;br /&gt;
            }&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffccaa;&amp;quot; align=&amp;quot;center&amp;quot;| clCompAppMain.c&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
            default:&lt;br /&gt;
            {&lt;br /&gt;
                break;&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
    &lt;br /&gt;
        return CL_OK;&lt;br /&gt;
    }&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now looking at csa103's implementation of &amp;lt;code&amp;gt;clCompAppAMFCSISet&amp;lt;/code&amp;gt;, we see that rather than just a few cases, we handle several cases: &amp;lt;code&amp;gt;QUIESCING&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;QUIESCED&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;ACTIVE&amp;lt;/code&amp;gt;, and  &amp;lt;code&amp;gt;STANDBY&amp;lt;/code&amp;gt;.  In each state, the global variable &amp;lt;code&amp;gt;ha_state&amp;lt;/code&amp;gt; to the new_state value that is passed in is set.  This is similar to csa102, except that we add the feature that in the &amp;lt;code&amp;gt;CL_AMS_HA_STATE_ACTIVE&amp;lt;/code&amp;gt; case if our previous state was &amp;lt;code&amp;gt;CL_AMS_HA_STATE_STANDBY&amp;lt;/code&amp;gt; we read the sequence from the checkpoint so that the main loop will pick it up.&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffccaa;&amp;quot; align=&amp;quot;center&amp;quot;| clCompAppMain.c&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
    static ClRcT&lt;br /&gt;
    checkpoint_initialize()&lt;br /&gt;
    {&lt;br /&gt;
        SaAisErrorT      rc = CL_OK;&lt;br /&gt;
        SaVersionT ckpt_version = {'B', 1, 1};&lt;br /&gt;
        SaNameT    ckpt_name = { strlen(CKPT_NAME), CKPT_NAME };&lt;br /&gt;
        ClUint32T  seq_no;&lt;br /&gt;
        SaCkptCheckpointCreationAttributesT create_atts = {&lt;br /&gt;
            .creationFlags     = SA_CKPT_WR_ACTIVE_REPLICA_WEAK |&lt;br /&gt;
                             SA_CKPT_CHECKPOINT_COLLOCATED,&lt;br /&gt;
            .checkpointSize    = sizeof(ClUint32T),&lt;br /&gt;
            .retentionDuration = (ClTimeT)10,&lt;br /&gt;
            .maxSections       = 2, // two sections &lt;br /&gt;
            .maxSectionSize    = sizeof(ClUint32T),&lt;br /&gt;
            .maxSectionIdSize  = (ClSizeT)64&lt;br /&gt;
&lt;br /&gt;
        &lt;br /&gt;
        };&lt;br /&gt;
        SaCkptSectionCreationAttributesT section_atts = {&lt;br /&gt;
        .sectionId = &amp;amp;ckpt_sid,&lt;br /&gt;
        .expirationTime = SA_TIME_END&lt;br /&gt;
&lt;br /&gt;
        };&lt;br /&gt;
 &lt;br /&gt;
        clprintf(CL_LOG_SEV_INFO,&amp;quot;%s: checkpoint_initialize&amp;quot;, appname);&lt;br /&gt;
        /* Initialize checkpointing service instance */&lt;br /&gt;
        rc = saCkptInitialize(&amp;amp;ckpt_svc_handle,	/* Checkpoint service handle */&lt;br /&gt;
						  NULL,			    /* Optional callbacks table */&lt;br /&gt;
						  &amp;amp;ckpt_version);   /* Required verison number */&lt;br /&gt;
        if (rc != SA_AIS_OK)&lt;br /&gt;
        {&lt;br /&gt;
            clprintf(CL_LOG_SEV_ERROR,&amp;quot;%s: ERROR: Failed to initialize checkpoint service&amp;quot;,&lt;br /&gt;
                    appname);&lt;br /&gt;
            return rc;&lt;br /&gt;
        }&lt;br /&gt;
        clprintf(CL_LOG_SEV_INFO,&amp;quot;%s: Checkpoint service initialized (handle=0x%llx)&amp;quot;,&lt;br /&gt;
           appname, ckpt_svc_handle);&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Here is &amp;lt;code&amp;gt;checkpoint_initialize&amp;lt;/code&amp;gt;.  Here we initialize the &amp;lt;code&amp;gt;ClNameT&amp;lt;/code&amp;gt; structure that holds the name of the checkpoint to be opened/created with the line: &amp;lt;code&amp;gt;ClNameT    ckpt_name = { strlen(CKPT_NAME), CKPT_NAME };&amp;lt;/code&amp;gt;. We then define a set of attributes to associate with the checkpoint when creating that checkpoint. The &amp;lt;code&amp;gt;creationFlags&amp;lt;/code&amp;gt; includes &amp;lt;code&amp;gt;CL_CKPT_WR_ACTIVE_REPLICA&amp;lt;/code&amp;gt;.  This means that the checkpoint to be created will be asynchronous, or once active server updation is completed, the call returns to the application, all other replica updates happens parallel. &amp;lt;code&amp;gt;CheckpointSize&amp;lt;/code&amp;gt; is set to the sizeof a 32 bit unsigned integer, which is the sequence number we print in the main loop.  The &amp;lt;code&amp;gt;retentionDuration&amp;lt;/code&amp;gt; is the time that the checkpoint service will keep the checkpoint in store after the last client has closed the checkpoint.  &amp;lt;code&amp;gt;MaxSections&amp;lt;/code&amp;gt; is 2 as this checkpoint will be used to store two sections.  &amp;lt;code&amp;gt;MaxSectionSize&amp;lt;/code&amp;gt; is the set to the sizeof a 32 bit unsigned integer, as application stores only unsigned integer. And &amp;lt;code&amp;gt;maxSectionIdSize&amp;lt;/code&amp;gt; is 64 bytes.&lt;br /&gt;
&lt;br /&gt;
We next use &amp;lt;code&amp;gt;ClCkptSectionCreationAttributesT section_atts&amp;lt;/code&amp;gt; to define the creation attributes for the sole section of the checkpoint. The &amp;lt;code&amp;gt;sectionId&amp;lt;/code&amp;gt; is just the name of the section along with the number of bytes in the name.  The &amp;lt;code&amp;gt;expirationTime&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;CL_TIME_END&amp;lt;/code&amp;gt; to imply that the section is never deleted automatically if the checkpoint itself still remains.&lt;br /&gt;
&lt;br /&gt;
The call to &amp;lt;code&amp;gt;clCkptInitialize&amp;lt;/code&amp;gt; has to be called before any other checkpoint functions.  The &amp;lt;code&amp;gt;ckpt_svc_handle&amp;lt;/code&amp;gt; is where the handle is returned.  The handle must be passed to some future checkpoint api calls, namely the &amp;lt;code&amp;gt;clCkptCheckpointOpen&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;clCkptFinalize&amp;lt;/code&amp;gt; calls.  The callbacks table is passed as &amp;lt;code&amp;gt;NULL&amp;lt;/code&amp;gt; which implies that our application doesn't provide any callbacks.  Finally the &amp;lt;code&amp;gt;ckpt_version&amp;lt;/code&amp;gt; identifies what version of the api this application is written to.&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffccaa;&amp;quot; align=&amp;quot;center&amp;quot;| clCompAppMain.c&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
        //&lt;br /&gt;
        // Create the checkpoint for read and write.            &lt;br /&gt;
&lt;br /&gt;
        rc = saCkptCheckpointOpen(ckpt_svc_handle,      // Service handle&lt;br /&gt;
                              &amp;amp;ckpt_name,         // Checkpoint name&lt;br /&gt;
                              &amp;amp;create_atts,       // Optional creation attr.&lt;br /&gt;
                              (SA_CKPT_CHECKPOINT_READ |&lt;br /&gt;
                               SA_CKPT_CHECKPOINT_WRITE |&lt;br /&gt;
                               SA_CKPT_CHECKPOINT_CREATE),&lt;br /&gt;
                              (SaTimeT)-1,        // No timeout&lt;br /&gt;
                              &amp;amp;ckpt_handle);      // Checkpoint handle&lt;br /&gt;
&lt;br /&gt;
        if (rc != SA_AIS_OK)&lt;br /&gt;
&lt;br /&gt;
        {&lt;br /&gt;
            clprintf(CL_LOG_SEV_ERROR,&amp;quot;%s: ERROR: Failed [0x%x] to open checkpoint&amp;quot;,&lt;br /&gt;
                    appname, rc);&lt;br /&gt;
            (void)saCkptFinalize(ckpt_svc_handle);&lt;br /&gt;
            return rc;&lt;br /&gt;
        }&lt;br /&gt;
        clprintf(CL_LOG_SEV_INFO,&amp;quot;%s: Checkpoint opened (handle=0x%llx)&amp;quot;, appname, ckpt_handle);&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
 &lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffccaa;&amp;quot; align=&amp;quot;center&amp;quot;| clCompAppMain.c&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
        /*&lt;br /&gt;
         * Try to create a section so that updates can operate by overwriting&lt;br /&gt;
         * the section over and over again.&lt;br /&gt;
         * If subsequent processes come through here, they will fail to create&lt;br /&gt;
         * the section.  That is OK, even though it will cause an error message&lt;br /&gt;
         * If the section create fails because the section is already there, then&lt;br /&gt;
         * read the sequence number&lt;br /&gt;
         */&lt;br /&gt;
        // Put data in network byte order&lt;br /&gt;
        seq_no = htonl(seq);&lt;br /&gt;
&lt;br /&gt;
        // Creating the section&lt;br /&gt;
        checkpoint_replica_activate();&lt;br /&gt;
        rc = saCkptSectionCreate(ckpt_handle,           // Checkpoint handle&lt;br /&gt;
                             &amp;amp;section_atts,         // Section attributes&lt;br /&gt;
                             (SaUint8T*)&amp;amp;seq_no,    // Initial data&lt;br /&gt;
                             (SaSizeT)sizeof(seq_no)); // Size of data&lt;br /&gt;
        if (rc != SA_AIS_OK &amp;amp;&amp;amp; (CL_GET_ERROR_CODE(rc) != SA_AIS_ERR_EXIST))&lt;br /&gt;
        {&lt;br /&gt;
            clprintf(CL_LOG_SEV_ERROR,&amp;quot;%s: ERROR: Failed to create checkpoint section&amp;quot;, appname);&lt;br /&gt;
            (void)saCkptCheckpointClose(ckpt_handle);&lt;br /&gt;
            (void)saCkptFinalize(ckpt_svc_handle);&lt;br /&gt;
            return rc;&lt;br /&gt;
        }&lt;br /&gt;
        else if (rc != SA_AIS_OK &amp;amp;&amp;amp; (CL_GET_ERROR_CODE(rc) == SA_AIS_ERR_EXIST))&lt;br /&gt;
        {&lt;br /&gt;
            rc = checkpoint_read_seq(&amp;amp;seq);&lt;br /&gt;
            if (rc != CL_OK)&lt;br /&gt;
            {&lt;br /&gt;
                clprintf(CL_LOG_SEV_ERROR,&amp;quot;%s: ERROR: Failed [0x%x] to read checkpoint section&amp;quot;,&lt;br /&gt;
                            appname, rc);&lt;br /&gt;
                (void)saCkptCheckpointClose(ckpt_handle);&lt;br /&gt;
                (void)saCkptFinalize(ckpt_svc_handle);&lt;br /&gt;
                return rc;&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
        else&lt;br /&gt;
        {&lt;br /&gt;
            clprintf(CL_LOG_SEV_INFO,&amp;quot;%s: Section created&amp;quot;, appname);&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        return CL_OK;&lt;br /&gt;
    }&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
With &amp;lt;code&amp;gt;rc = clCkptCheckpointOpen&amp;lt;/code&amp;gt; we attempt to open the specified checkpoint.  When &amp;lt;code&amp;gt;checkpoint_initialize&amp;lt;/code&amp;gt; is called the checkpoint may or may not exist.  We attempt to open the checkpoint for READ/WRITE access. &lt;br /&gt;
&lt;br /&gt;
Next we check if we created the checkpoint and then we need to create the section with a call to &amp;lt;code&amp;gt;clCkptSectionCreate&amp;lt;/code&amp;gt;.  We pass the checkpoint handle obtained from &amp;lt;code&amp;gt;clCkptCheckpointOpen&amp;lt;/code&amp;gt;, the section attributes declared earlier, and the address of the initial value along with the size in bytes of the initial value.&lt;br /&gt;
&lt;br /&gt;
We convert the initial value to network byte order by the code &amp;lt;code&amp;gt;seq_no = htonl(seq)&amp;lt;/code&amp;gt;, before passing it to &amp;lt;code&amp;gt;clCkptSectionCreate&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If we do not create the section, then we read the current value in the checkpoint into our global seq variable.&lt;br /&gt;
&lt;br /&gt;
Note that whenever we return an error return code from the function that we have either not opened the checkpoint/initialized the checkpoint service, or we have closed the checkpoint and finalized the checkpoint service with calls to &amp;lt;code&amp;gt;clCkptCheckpointClose&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;clCkptFinalize&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffccaa;&amp;quot; align=&amp;quot;center&amp;quot;| clCompAppMain.c&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
    static ClRcT &lt;br /&gt;
    checkpoint_finalize(void)&lt;br /&gt;
    {&lt;br /&gt;
        SaAisErrorT rc;&lt;br /&gt;
&lt;br /&gt;
        rc = saCkptCheckpointClose(ckpt_handle);&lt;br /&gt;
        if (rc != SA_AIS_OK)&lt;br /&gt;
        {&lt;br /&gt;
            clprintf(CL_LOG_SEV_ERROR,&amp;quot;%s: failed: [0x%x] to close checkpoint handle 0x%llx&amp;quot;,&lt;br /&gt;
                        appname, rc, ckpt_handle);&lt;br /&gt;
        }&lt;br /&gt;
        rc = saCkptFinalize(ckpt_svc_handle);&lt;br /&gt;
        if (rc != SA_AIS_OK)&lt;br /&gt;
        {&lt;br /&gt;
            clprintf(CL_LOG_SEV_ERROR,&amp;quot;%s: failed: [0x%x] to finalize checkpoint&amp;quot;,&lt;br /&gt;
                    appname, rc);&lt;br /&gt;
        }&lt;br /&gt;
        return CL_OK;&lt;br /&gt;
&lt;br /&gt;
    }&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
The above code snippet presents &amp;lt;code&amp;gt;checkpoint_finalize&amp;lt;/code&amp;gt;.  It's quite simple.  First it closes the checkpoint handle with a call to &amp;lt;code&amp;gt;clCkptCheckpointClose&amp;lt;/code&amp;gt;.  Next it finalizes the checkpoint library with a call to &amp;lt;code&amp;gt;clCkptFinalize&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffccaa;&amp;quot; align=&amp;quot;center&amp;quot;| clCompAppMain.c&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
    static ClRcT&lt;br /&gt;
    checkpoint_write_seq(ClUint32T seq)&lt;br /&gt;
    {&lt;br /&gt;
        SaAisErrorT rc = SA_AIS_OK;&lt;br /&gt;
        ClUint32T seq_no;&lt;br /&gt;
&lt;br /&gt;
        /* Putting data in network byte order */&lt;br /&gt;
        seq_no = htonl(seq);&lt;br /&gt;
&lt;br /&gt;
        /* Write checkpoint */&lt;br /&gt;
        retry:&lt;br /&gt;
        rc = saCkptSectionOverwrite(ckpt_handle,&lt;br /&gt;
                                &amp;amp;ckpt_sid,&lt;br /&gt;
                                &amp;amp;seq_no,&lt;br /&gt;
                                sizeof(ClUint32T));&lt;br /&gt;
        if (rc != SA_AIS_OK)&lt;br /&gt;
        {&lt;br /&gt;
            clprintf(CL_LOG_SEV_ERROR,&amp;quot;Failed [0x%x] to write to section&amp;quot;, rc);&lt;br /&gt;
            if(rc == SA_AIS_ERR_NOT_EXIST)&lt;br /&gt;
                rc = checkpoint_replica_activate();&lt;br /&gt;
            if(rc == CL_OK) goto retry;&lt;br /&gt;
        }&lt;br /&gt;
        else&lt;br /&gt;
        {&lt;br /&gt;
            /*&lt;br /&gt;
            * Synchronize the checkpoint to all the replicas.&lt;br /&gt;
            */&lt;br /&gt;
            rc = saCkptCheckpointSynchronize(ckpt_handle, SA_TIME_END );&lt;br /&gt;
            if (rc != SA_AIS_OK)&lt;br /&gt;
            {&lt;br /&gt;
                clprintf(CL_LOG_SEV_ERROR,&amp;quot;Failed [0x%x] to synchronize the checkpoint&amp;quot;, rc);&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        return CL_OK;&lt;br /&gt;
     }&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
With &amp;lt;code&amp;gt;checkpoint_write_seq&amp;lt;/code&amp;gt; we first convert the sequence number passed into network byte order.  Then we pass it to &amp;lt;code&amp;gt;clCKptSectionOverwrite&amp;lt;/code&amp;gt; which writes it to the checkpoint section created in &amp;lt;code&amp;gt;checkpoint_initialize&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffccaa;&amp;quot; align=&amp;quot;center&amp;quot;| clCompAppMain.c&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
    static ClRcT&lt;br /&gt;
    checkpoint_read_seq(ClUint32T *seq)&lt;br /&gt;
    {&lt;br /&gt;
        ClRcT rc = CL_OK;&lt;br /&gt;
        ClUint32T err_idx; /* Error index in ioVector */&lt;br /&gt;
        ClUint32T seq_no = 0xffffffff;&lt;br /&gt;
        SaCkptIOVectorElementT iov = {&lt;br /&gt;
            .sectionId  = ckpt_sid,&lt;br /&gt;
            .dataBuffer = (ClPtrT)&amp;amp;seq_no,&lt;br /&gt;
            .dataSize   = sizeof(ClUint32T),&lt;br /&gt;
            .dataOffset = (ClOffsetT)0,&lt;br /&gt;
            .readSize   = sizeof(ClUint32T)&lt;br /&gt;
        };&lt;br /&gt;
&lt;br /&gt;
        rc = saCkptCheckpointRead(ckpt_handle, &amp;amp;iov, 1, &amp;amp;err_idx);&lt;br /&gt;
        if (rc != SA_AIS_OK)&lt;br /&gt;
        {&lt;br /&gt;
           clprintf(CL_LOG_SEV_ERROR,&amp;quot;Error: [0x%x] from checkpoint read, err_idx = %u&amp;quot;,&lt;br /&gt;
                    rc, err_idx);&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        /* FIXME: How to process this err_idx? */&lt;br /&gt;
        *seq = ntohl(seq_no);&lt;br /&gt;
&lt;br /&gt;
        return CL_OK;&lt;br /&gt;
&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
With &amp;lt;code&amp;gt;checkpoint_read_seq&amp;lt;/code&amp;gt; we initialize &amp;lt;code&amp;gt;seq_no&amp;lt;/code&amp;gt; to all ones just so it will be more obvious if the &amp;lt;code&amp;gt;clCkptCheckpointRead&amp;lt;/code&amp;gt; call fails and the value of &amp;lt;code&amp;gt;seq_no&amp;lt;/code&amp;gt; doesn't get overwritten.  Then, we set up the &amp;lt;code&amp;gt;iov&amp;lt;/code&amp;gt; variable.  We set the &amp;lt;code&amp;gt;sectionID&amp;lt;/code&amp;gt;  field to &amp;lt;code&amp;gt;ckpt_sid&amp;lt;/code&amp;gt; which is the id of the section created in &amp;lt;code&amp;gt;checkpoint_initialize&amp;lt;/code&amp;gt;.  The &amp;lt;code&amp;gt;dataBuffer&amp;lt;/code&amp;gt; gets set to the address of the &amp;lt;code&amp;gt;seq_no&amp;lt;/code&amp;gt; variable which is where we want the checkpoint data loaded.  The &amp;lt;code&amp;gt;dataSize&amp;lt;/code&amp;gt; field is set to the the size of the &amp;lt;code&amp;gt;seq_no&amp;lt;/code&amp;gt; variable.  &amp;lt;code&amp;gt;DataOfset&amp;lt;/code&amp;gt; is set to zero since the sequence number is the only thing stored in the section, so it resides at the front of the section.  &amp;lt;code&amp;gt;readSize&amp;lt;/code&amp;gt; is set to the size of the sequence number variable.&lt;br /&gt;
&lt;br /&gt;
Within &amp;lt;code&amp;gt;checkpoint_read_seq&amp;lt;/code&amp;gt; we pass the iovector to &amp;lt;code&amp;gt;clCkptCheckpointRead&amp;lt;/code&amp;gt; along with the &amp;lt;code&amp;gt;ckpt_handle&amp;lt;/code&amp;gt;, the constant 1, and the address of the &amp;lt;code&amp;gt;err_idx&amp;lt;/code&amp;gt; variable.  The constant 1 is the number of elements in the array of &amp;lt;code&amp;gt;ClCkptIOVectorElementT structs&amp;lt;/code&amp;gt; that we're passing.  That is, we're passing the address of a single &amp;lt;code&amp;gt;ClCkptIOVectorElementT struct&amp;lt;/code&amp;gt;.  The &amp;lt;code&amp;gt;err_idx&amp;lt;/code&amp;gt; will hold the index in that array where &amp;lt;code&amp;gt;clCkptCheckpointRead&amp;lt;/code&amp;gt; found an error.  That is, if there is going to be an error, it will be at index 0 since we're only passing on entry in the &amp;lt;code&amp;gt;iovector&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffccaa;&amp;quot; align=&amp;quot;center&amp;quot;| clCompAppMain.c&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    static ClRcT&lt;br /&gt;
    checkpoint_replica_activate(void)&lt;br /&gt;
    {&lt;br /&gt;
        SaAisErrorT rc = SA_AIS_OK;&lt;br /&gt;
&lt;br /&gt;
        if ((rc = saCkptActiveReplicaSet(ckpt_handle)) != SA_AIS_OK)&lt;br /&gt;
        {&lt;br /&gt;
            clprintf(CL_LOG_SEV_ERROR,&lt;br /&gt;
                    &amp;quot;checkpoint_replica_activate failed [0x%x] in ActiveReplicaSet&amp;quot;,&lt;br /&gt;
                    rc);&lt;br /&gt;
        }&lt;br /&gt;
        else rc = CL_OK;&lt;br /&gt;
&lt;br /&gt;
        return rc;&lt;br /&gt;
    }&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===csa203===&lt;br /&gt;
&lt;br /&gt;
csa203 demonstrates the usage of SA Forum's Checkpointing service. This sample application does not deviate functionally from csa103. The code differences are due to using SA Forum data types (structures) and APIs , as presented in the following two tables. (Note we have not repeated data types and APIs covered previously.)&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|+align=&amp;quot;bottom&amp;quot;| '''SA Forum Data Types with the SAFplus Platform equivalent'''&lt;br /&gt;
|- style=&amp;quot;color:black;background-color:#ffffaa;&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
!SA Forum Data Types   &lt;br /&gt;
!OpenClovis Data Types&lt;br /&gt;
|-&lt;br /&gt;
|SaCkptHandleT&lt;br /&gt;
|ClCkptSvcHdlT&lt;br /&gt;
|-&lt;br /&gt;
|SaCkptHandleT&lt;br /&gt;
|ClCkptHdlT&lt;br /&gt;
|-&lt;br /&gt;
|SaCkptSectionIdT&lt;br /&gt;
|ClCkptSectionIdT&lt;br /&gt;
|-&lt;br /&gt;
|SaCkptCheckpointCreationAttributesT&lt;br /&gt;
|ClCkptCheckpointCreationAttributesT&lt;br /&gt;
|-&lt;br /&gt;
|SaCkptSectionCreationAttributesT&lt;br /&gt;
|ClCkptSectionCreationAttributesT&lt;br /&gt;
|-&lt;br /&gt;
|SaCkptIOVectorElementT&lt;br /&gt;
|ClCkptIOVectorElementT&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|+align=&amp;quot;bottom&amp;quot;| '''SA Forum APIs with the SAFplus Platform equivalent'''&lt;br /&gt;
|- style=&amp;quot;color:black;background-color:#ffffaa;&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
!SA Forum APIs&lt;br /&gt;
!OpenClovis APIs&lt;br /&gt;
|-&lt;br /&gt;
|saCkptInitialize&lt;br /&gt;
|clCkptInitialize&lt;br /&gt;
|-&lt;br /&gt;
|saCkptCheckpointOpen&lt;br /&gt;
|clCkptCheckpointOpen&lt;br /&gt;
|-&lt;br /&gt;
|saCkptSectionCreate&lt;br /&gt;
|clCkptSectionCreate&lt;br /&gt;
|-&lt;br /&gt;
|saCkptCheckpointClose&lt;br /&gt;
|clCkptCheckpointClose&lt;br /&gt;
|-&lt;br /&gt;
|saCkptFinalize&lt;br /&gt;
|clCkptFinalize&lt;br /&gt;
|-&lt;br /&gt;
|saCkptSectionOverwrite&lt;br /&gt;
|clCkptSectionOverwrite&lt;br /&gt;
|-&lt;br /&gt;
|saCkptCheckpointSynchronize&lt;br /&gt;
|clCkptCheckpointSynchronize&lt;br /&gt;
|-&lt;br /&gt;
|saCkptCheckpointRead&lt;br /&gt;
|clCkptCheckpointRead&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===How to Run csa103 and What to Observe===&lt;br /&gt;
&lt;br /&gt;
This sample application can run on all Runtime Hardware Setups. The following, lists which node &amp;lt;code&amp;gt;csa103compI*&amp;lt;/code&amp;gt; runs on.&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;'''Runtime Hardware Setup 1.1 and 2.1'''&lt;br /&gt;
&amp;lt;br&amp;gt;csa103compI0 and csa103compI1 will run upon the single node.&lt;br /&gt;
&amp;lt;li&amp;gt;'''Runtime Hardware Setup 1.2 and 2.2'''&lt;br /&gt;
&amp;lt;br&amp;gt;csa103compI0 runs on PayloadNodeI0 and csa103compI1 runs on PayloadNodeI1&lt;br /&gt;
&amp;lt;li&amp;gt;'''Runtime Hardware Setup 1.3 and 2.3'''&lt;br /&gt;
&amp;lt;br&amp;gt;csa103compI2 and csa103compI3 run on SCNodeI0 and SCNodeI1 respectively. csa103compI0 and csa103compI1 run on PayloadNodeI0 and PayloadNodeI1 respectively.&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;In the four node set up SCNodeI0 and SCNodeI1 output data via &amp;lt;code&amp;gt;/root/asp/var/log/csa103CompI2&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;/root/asp/var/log/csa103CompI3&amp;lt;/code&amp;gt; respectively. Therefore in this case follow the below instructions replacing csa103CompI0 and csa103compI1 with csa103compI2 and csa103compI3 respectively.&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We run csa103 very much the same way we run any of the rest of the sample applications: with the SAFplus Platform Console.&lt;br /&gt;
  &lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;First, on the active System Controller move it to state LockAssignment with (Unlock csa203SGI0 instead of csa103SGI0 to run csa203)&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
cli[Test]-&amp;gt; setc 1&lt;br /&gt;
cli[Test:SCNodeI0]-&amp;gt; setc cpm&lt;br /&gt;
cli[Test:SCNodeI0:CPM]-&amp;gt; amsLockAssignment sg csa103SGI0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The following output is given when you run &amp;lt;code&amp;gt;tail -f&amp;lt;/code&amp;gt; on the csa103 log files. For example:&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
# tail -f /root/asp/var/log/csa103CompI0.log&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffffaa;&amp;quot; align=&amp;quot;center&amp;quot;| /root/asp/var/log/csa103CompI0Log.latest&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
Mon Jul 14 00:01:09 2008   (SCNodeI0.15238 : csa103CompEO.---.---.00030 :   INFO)&lt;br /&gt;
 Component [csa103CompI0] : PID [15238]. Initializing&lt;br /&gt;
Mon Jul 14 00:01:09 2008   (SCNodeI0.15238 : csa103CompEO.---.---.00031 :   INFO)&lt;br /&gt;
    IOC Address             : 0x1&lt;br /&gt;
Mon Jul 14 00:01:09 2008   (SCNodeI0.15238 : csa103CompEO.---.---.00032 :   INFO)&lt;br /&gt;
    IOC Port                : 0x81&lt;br /&gt;
Mon Jul 14 00:01:09 2008   (SCNodeI0.15238 : csa103CompEO.---.---.00033 :   INFO)&lt;br /&gt;
 csa103: Instantiated as component instance csa103CompI0.&lt;br /&gt;
Mon Jul 14 00:01:09 2008   (SCNodeI0.15238 : csa103CompEO.---.---.00034 :   INFO)&lt;br /&gt;
 csa103CompI0: Waiting for CSI assignment...&lt;br /&gt;
Mon Jul 14 00:01:09 2008   (SCNodeI0.15238 : csa103CompEO.---.---.00035 :   INFO)&lt;br /&gt;
 csa103CompI0: Waiting for CSI assignment...&lt;br /&gt;
Mon Jul 14 00:01:09 2008   (SCNodeI0.15238 : csa103CompEO.---.---.00036 :   INFO)&lt;br /&gt;
 csa103CompI0: checkpoint_initialize&lt;br /&gt;
Mon Jul 14 00:01:10 2008   (SCNodeI0.15238 : csa103CompEO.---.---.00043 :   INFO)&lt;br /&gt;
 csa103CompI0: Checkpoint service initialized (handle=0x1)&lt;br /&gt;
Mon Jul 14 00:01:10 2008   (SCNodeI0.15238 : csa103CompEO.---.---.00045 :   INFO)&lt;br /&gt;
 csa103CompI0: Checkpoint opened (handle=0x2)&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
# tail -f /root/asp/var/log/csa103CompI1.log&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffffaa;&amp;quot; align=&amp;quot;center&amp;quot;| /root/asp/var/log/csa103CompI1Log.latest&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
Mon Jul 14 00:01:09 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00030 :   INFO)&lt;br /&gt;
 Component [csa103CompI1] : PID [15234]. Initializing&lt;br /&gt;
Mon Jul 14 00:01:09 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00031 :   INFO)&lt;br /&gt;
    IOC Address             : 0x1&lt;br /&gt;
Mon Jul 14 00:01:09 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00032 :   INFO)&lt;br /&gt;
    IOC Port                : 0x80&lt;br /&gt;
Mon Jul 14 00:01:09 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00033 :   INFO)&lt;br /&gt;
 csa103: Instantiated as component instance csa103CompI1.&lt;br /&gt;
Mon Jul 14 00:01:09 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00034 :   INFO)&lt;br /&gt;
 csa103CompI1: Waiting for CSI assignment...&lt;br /&gt;
Mon Jul 14 00:01:09 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00035 :   INFO)&lt;br /&gt;
 csa103CompI1: Waiting for CSI assignment...&lt;br /&gt;
Mon Jul 14 00:01:09 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00036 :   INFO)&lt;br /&gt;
 csa103CompI1: checkpoint_initialize&lt;br /&gt;
Mon Jul 14 00:01:09 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00043 :   INFO)&lt;br /&gt;
 csa103CompI1: Checkpoint service initialized (handle=0x1)&lt;br /&gt;
Mon Jul 14 00:01:09 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00045 :   INFO)&lt;br /&gt;
 csa103CompI1: Checkpoint opened (handle=0x2)&lt;br /&gt;
Mon Jul 14 00:01:09 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00053 :   INFO)&lt;br /&gt;
 csa103CompI1: Section created&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;Then, unlock the application by running &lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
cli[Test:SCNodeI0:CPM]-&amp;gt; amsUnlock sg csa103SGI0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the application log files, you should see &lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffffaa;&amp;quot; align=&amp;quot;center&amp;quot;| /root/asp/var/log/csa103CompI0Log.latest&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
Mon Jul 14 00:09:08 2008   (SCNodeI0.15238 : csa103CompEO.---.---.00058 :   INFO)&lt;br /&gt;
  Standby state requested from state 0&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffffaa;&amp;quot; align=&amp;quot;center&amp;quot;| /root/asp/var/log/csa103CompI1Log.latest&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
Mon Jul 14 00:09:08 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00064 :   INFO)&lt;br /&gt;
 csa103CompI1: Active state requested from state 0&lt;br /&gt;
Mon Jul 14 00:09:09 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00065 :   INFO)&lt;br /&gt;
 csa103CompI1: Hello World! (seq=0)&lt;br /&gt;
Mon Jul 14 00:09:10 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00066 :   INFO)&lt;br /&gt;
 csa103CompI1: Hello World! (seq=1)&lt;br /&gt;
Mon Jul 14 00:09:11 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00067 :   INFO)&lt;br /&gt;
 csa103CompI1: Hello World! (seq=2)&lt;br /&gt;
Mon Jul 14 00:09:12 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00068 :   INFO)&lt;br /&gt;
 csa103CompI1: Hello World! (seq=3)&lt;br /&gt;
Mon Jul 14 00:09:13 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00069 :   INFO)&lt;br /&gt;
 csa103CompI1: Hello World! (seq=4)&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;Next, find the active csa103 process, the one that's printing the Hello World lines and kill it.  To find the process ID issue the following command from a bash shell.&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
 # ps -eaf | grep csa103&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
This should produce an output that looks similar to the following.&lt;br /&gt;
 root     17830 15663  0 14:21 ?        00:00:00 csa103Comp -p&lt;br /&gt;
 root     17839 15663  0 14:21 ?        00:00:00 csa103Comp -p&lt;br /&gt;
 root     18558 16145  0 14:32 pts/4    00:00:00 grep csa103&lt;br /&gt;
Notice the two entries that end with csa103Comp -p. These are our two component processes. The first one is usually the active process. This is the one that we will kill. In this case the process ID is 17830. So to kill the active component you issue the command:&lt;br /&gt;
&lt;br /&gt;
 # kill -9 17830&lt;br /&gt;
&lt;br /&gt;
[[File:OpenClovis_Note.png]]If this step does not result in the active component being killed then it is likely that the standby component was killed. In this case simply try killing the other process. &lt;br /&gt;
&lt;br /&gt;
After killing the active component you should see lines in the log files like the following:&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffffaa;&amp;quot; align=&amp;quot;center&amp;quot;| /root/asp/var/log/csa103CompI1Log.latest&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
Mon Jul 14 00:16:43 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00515 :   INFO)&lt;br /&gt;
 csa103CompI1: Hello World! (seq=452)&lt;br /&gt;
Mon Jul 14 00:16:44 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00516 :   INFO)&lt;br /&gt;
 csa103CompI1: Hello World! (seq=453)&lt;br /&gt;
Mon Jul 14 00:16:45 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00517 :   INFO)&lt;br /&gt;
 csa103CompI1: Hello World! (seq=454)&lt;br /&gt;
Mon Jul 14 00:16:46 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00518 :   INFO)&lt;br /&gt;
 csa103CompI1: Hello World! (seq=455)&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffffaa;&amp;quot; align=&amp;quot;center&amp;quot;| /var/log/csa103CompI0Log.latest&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
Mon Jul 14 00:16:48 2008   (SCNodeI0.15238 : csa103CompEO.---.---.00065 :   INFO)&lt;br /&gt;
 csa103CompI0: Active state requested from state 2&lt;br /&gt;
Mon Jul 14 00:16:48 2008   (SCNodeI0.15238 : csa103CompEO.---.---.00066 :   INFO)&lt;br /&gt;
 csa103CompI0 reading checkpoint&lt;br /&gt;
Mon Jul 14 00:16:48 2008   (SCNodeI0.15238 : csa103CompEO.---.---.00067 :   INFO)&lt;br /&gt;
 csa103CompI0 read checkpoint: seq = 456&lt;br /&gt;
Mon Jul 14 00:16:49 2008   (SCNodeI0.15238 : csa103CompEO.---.---.00068 :   INFO)&lt;br /&gt;
 csa103CompI0: Hello World! (seq=456)&lt;br /&gt;
Mon Jul 14 00:16:50 2008   (SCNodeI0.15238 : csa103CompEO.---.---.00069 :   INFO)&lt;br /&gt;
 csa103CompI0: Hello World! (seq=457)&lt;br /&gt;
Mon Jul 14 00:16:51 2008   (SCNodeI0.15238 : csa103CompEO.---.---.00070 :   INFO)&lt;br /&gt;
 csa103CompI0: Hello World! (seq=458)&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
Where we can see CompI1 printing 455 and then dieing, where upon CompI0 gets the notice to take over processing, reads the checkpoint and then takes over with seq=456 and so on.&lt;br /&gt;
&lt;br /&gt;
Then, in the CompI1 log file we see:&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffffaa;&amp;quot; align=&amp;quot;center&amp;quot;| /root/asp/var/log/csa103CompI1Log.latest&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
Mon Jul 14 00:16:49 2008   (SCNodeI0.15553 : csa103CompEO.---.---.00044 :   INFO)&lt;br /&gt;
 csa103: Instantiated as component instance csa103CompI1.&lt;br /&gt;
Mon Jul 14 00:16:49 2008   (SCNodeI0.15553 : csa103CompEO.---.---.00045 :   INFO)&lt;br /&gt;
 csa103CompI1: Waiting for CSI assignment...&lt;br /&gt;
Mon Jul 14 00:16:49 2008   (SCNodeI0.15553 : csa103CompEO.---.---.00046 :   INFO)&lt;br /&gt;
 csa103CompI1: Waiting for CSI assignment...&lt;br /&gt;
Mon Jul 14 00:16:49 2008   (SCNodeI0.15553 : csa103CompEO.---.---.00047 :   INFO)&lt;br /&gt;
 csa103CompI1: checkpoint_initialize&lt;br /&gt;
Mon Jul 14 00:16:50 2008   (SCNodeI0.15553 : csa103CompEO.---.---.00054 :   INFO)&lt;br /&gt;
 csa103CompI1: Checkpoint service initialized (handle=0x1)&lt;br /&gt;
Mon Jul 14 00:16:50 2008   (SCNodeI0.15553 : csa103CompEO.---.---.00056 :   INFO)&lt;br /&gt;
 csa103CompI1: Checkpoint opened (handle=0x2)&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
That is the component that had been killed being restarted.  &lt;br /&gt;
&lt;br /&gt;
CompI0 is moving along just fine, and we see CompI1 come back up.  If we then kill CompI0 we see:&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffffaa;&amp;quot; align=&amp;quot;center&amp;quot;| /root/asp/var/log/csa103CompI1Log.latest&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
Mon Jul 14 00:29:44 2008   (SCNodeI0.15553 : csa103CompEO.---.---.00065 :   INFO)&lt;br /&gt;
 csa103CompI1: Active state requested from state 2&lt;br /&gt;
Mon Jul 14 00:29:44 2008   (SCNodeI0.15553 : csa103CompEO.---.---.00066 :   INFO)&lt;br /&gt;
 csa103CompI1 reading checkpoint&lt;br /&gt;
Mon Jul 14 00:29:44 2008   (SCNodeI0.15553 : csa103CompEO.---.---.00067 :   INFO)&lt;br /&gt;
 csa103CompI1 read checkpoint: seq = 1225&lt;br /&gt;
Mon Jul 14 00:29:45 2008   (SCNodeI0.15553 : csa103CompEO.---.---.00068 :   INFO)&lt;br /&gt;
 csa103CompI1: Hello World! (seq=1225)&lt;br /&gt;
Mon Jul 14 00:29:46 2008   (SCNodeI0.15553 : csa103CompEO.---.---.00069 :   INFO)&lt;br /&gt;
 csa103CompI1: Hello World! (seq=1226)&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
Where we can see the CompI0 process die, and CompI1 process read the sequence number from the checkpoint and then take over from where CompI0 left off.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;To stop csa103 use the following SAFplus Platform Console command.&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
cli[Test:SCNodeI0:CPM]-&amp;gt; amsLockAssignment sg csa103SGI0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;Now change the state of csa103SGI0 to LockInstantiation and close the SAFplus Platform Console.&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
cli[Test:SCNodeI0:CPM]-&amp;gt; amsLockInstantiation sg csa103SGI0&lt;br /&gt;
cli[Test:SCNodeI0:CPM] -&amp;gt; end&lt;br /&gt;
cli[Test:SCNodeI0] -&amp;gt; end&lt;br /&gt;
cli[Test] -&amp;gt; bye&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===csa203===&lt;br /&gt;
&lt;br /&gt;
csa203 demonstrates the usage of SA Forum's Checkpointing service. This sample application does not deviate functionally from csa103. The code differences are due to using SA Forum data types (structures) and APIs , as presented in the following two tables. (Note we have not repeated data types and APIs covered previously.)&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|+align=&amp;quot;bottom&amp;quot;| '''SA Forum Data Types with the SAFplus Platform equivalent'''&lt;br /&gt;
|- style=&amp;quot;color:black;background-color:#ffffaa;&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
!SA Forum Data Types   &lt;br /&gt;
!OpenClovis Data Types&lt;br /&gt;
|-&lt;br /&gt;
|SaCkptHandleT&lt;br /&gt;
|ClCkptSvcHdlT&lt;br /&gt;
|-&lt;br /&gt;
|SaCkptHandleT&lt;br /&gt;
|ClCkptHdlT&lt;br /&gt;
|-&lt;br /&gt;
|SaCkptSectionIdT&lt;br /&gt;
|ClCkptSectionIdT&lt;br /&gt;
|-&lt;br /&gt;
|SaCkptCheckpointCreationAttributesT&lt;br /&gt;
|ClCkptCheckpointCreationAttributesT&lt;br /&gt;
|-&lt;br /&gt;
|SaCkptSectionCreationAttributesT&lt;br /&gt;
|ClCkptSectionCreationAttributesT&lt;br /&gt;
|-&lt;br /&gt;
|SaCkptIOVectorElementT&lt;br /&gt;
|ClCkptIOVectorElementT&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|+align=&amp;quot;bottom&amp;quot;| '''SA Forum APIs with the SAFplus Platform equivalent'''&lt;br /&gt;
|- style=&amp;quot;color:black;background-color:#ffffaa;&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
!SA Forum APIs&lt;br /&gt;
!OpenClovis APIs&lt;br /&gt;
|-&lt;br /&gt;
|saCkptInitialize&lt;br /&gt;
|clCkptInitialize&lt;br /&gt;
|-&lt;br /&gt;
|saCkptCheckpointOpen&lt;br /&gt;
|clCkptCheckpointOpen&lt;br /&gt;
|-&lt;br /&gt;
|saCkptSectionCreate&lt;br /&gt;
|clCkptSectionCreate&lt;br /&gt;
|-&lt;br /&gt;
|saCkptCheckpointClose&lt;br /&gt;
|clCkptCheckpointClose&lt;br /&gt;
|-&lt;br /&gt;
|saCkptFinalize&lt;br /&gt;
|clCkptFinalize&lt;br /&gt;
|-&lt;br /&gt;
|saCkptSectionOverwrite&lt;br /&gt;
|clCkptSectionOverwrite&lt;br /&gt;
|-&lt;br /&gt;
|saCkptCheckpointSynchronize&lt;br /&gt;
|clCkptCheckpointSynchronize&lt;br /&gt;
|-&lt;br /&gt;
|saCkptCheckpointRead&lt;br /&gt;
|clCkptCheckpointRead&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===How to Run csa103 and What to Observe===&lt;br /&gt;
&lt;br /&gt;
This sample application can run on all Runtime Hardware Setups. The following, lists which node &amp;lt;code&amp;gt;csa103compI*&amp;lt;/code&amp;gt; runs on.&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;'''Runtime Hardware Setup 1.1 and 2.1'''&lt;br /&gt;
&amp;lt;br&amp;gt;csa103compI0 and csa103compI1 will run upon the single node.&lt;br /&gt;
&amp;lt;li&amp;gt;'''Runtime Hardware Setup 1.2 and 2.2'''&lt;br /&gt;
&amp;lt;br&amp;gt;csa103compI0 runs on PayloadNodeI0 and csa103compI1 runs on PayloadNodeI1&lt;br /&gt;
&amp;lt;li&amp;gt;'''Runtime Hardware Setup 1.3 and 2.3'''&lt;br /&gt;
&amp;lt;br&amp;gt;csa103compI2 and csa103compI3 run on SCNodeI0 and SCNodeI1 respectively. csa103compI0 and csa103compI1 run on PayloadNodeI0 and PayloadNodeI1 respectively.&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;In the four node set up SCNodeI0 and SCNodeI1 output data via &amp;lt;code&amp;gt;/root/asp/var/log/csa103CompI2&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;/root/asp/var/log/csa103CompI3&amp;lt;/code&amp;gt; respectively. Therefore in this case follow the below instructions replacing csa103CompI0 and csa103compI1 with csa103compI2 and csa103compI3 respectively.&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We run csa103 very much the same way we run any of the rest of the sample applications: with the SAFplus Platform Console.&lt;br /&gt;
  &lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;First, on the active System Controller move it to state LockAssignment with (Unlock csa203SGI0 instead of csa103SGI0 to run csa203)&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
cli[Test]-&amp;gt; setc 1&lt;br /&gt;
cli[Test:SCNodeI0]-&amp;gt; setc cpm&lt;br /&gt;
cli[Test:SCNodeI0:CPM]-&amp;gt; amsLockAssignment sg csa103SGI0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The following output is given when you run &amp;lt;code&amp;gt;tail -f&amp;lt;/code&amp;gt; on the csa103 log files. For example:&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
# tail -f /root/asp/var/log/csa103CompI0.log&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffffaa;&amp;quot; align=&amp;quot;center&amp;quot;| /root/asp/var/log/csa103CompI0Log.latest&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
Mon Jul 14 00:01:09 2008   (SCNodeI0.15238 : csa103CompEO.---.---.00030 :   INFO)&lt;br /&gt;
 Component [csa103CompI0] : PID [15238]. Initializing&lt;br /&gt;
Mon Jul 14 00:01:09 2008   (SCNodeI0.15238 : csa103CompEO.---.---.00031 :   INFO)&lt;br /&gt;
    IOC Address             : 0x1&lt;br /&gt;
Mon Jul 14 00:01:09 2008   (SCNodeI0.15238 : csa103CompEO.---.---.00032 :   INFO)&lt;br /&gt;
    IOC Port                : 0x81&lt;br /&gt;
Mon Jul 14 00:01:09 2008   (SCNodeI0.15238 : csa103CompEO.---.---.00033 :   INFO)&lt;br /&gt;
 csa103: Instantiated as component instance csa103CompI0.&lt;br /&gt;
Mon Jul 14 00:01:09 2008   (SCNodeI0.15238 : csa103CompEO.---.---.00034 :   INFO)&lt;br /&gt;
 csa103CompI0: Waiting for CSI assignment...&lt;br /&gt;
Mon Jul 14 00:01:09 2008   (SCNodeI0.15238 : csa103CompEO.---.---.00035 :   INFO)&lt;br /&gt;
 csa103CompI0: Waiting for CSI assignment...&lt;br /&gt;
Mon Jul 14 00:01:09 2008   (SCNodeI0.15238 : csa103CompEO.---.---.00036 :   INFO)&lt;br /&gt;
 csa103CompI0: checkpoint_initialize&lt;br /&gt;
Mon Jul 14 00:01:10 2008   (SCNodeI0.15238 : csa103CompEO.---.---.00043 :   INFO)&lt;br /&gt;
 csa103CompI0: Checkpoint service initialized (handle=0x1)&lt;br /&gt;
Mon Jul 14 00:01:10 2008   (SCNodeI0.15238 : csa103CompEO.---.---.00045 :   INFO)&lt;br /&gt;
 csa103CompI0: Checkpoint opened (handle=0x2)&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
# tail -f /root/asp/var/log/csa103CompI1.log&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffffaa;&amp;quot; align=&amp;quot;center&amp;quot;| /root/asp/var/log/csa103CompI1Log.latest&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
Mon Jul 14 00:01:09 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00030 :   INFO)&lt;br /&gt;
 Component [csa103CompI1] : PID [15234]. Initializing&lt;br /&gt;
Mon Jul 14 00:01:09 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00031 :   INFO)&lt;br /&gt;
    IOC Address             : 0x1&lt;br /&gt;
Mon Jul 14 00:01:09 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00032 :   INFO)&lt;br /&gt;
    IOC Port                : 0x80&lt;br /&gt;
Mon Jul 14 00:01:09 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00033 :   INFO)&lt;br /&gt;
 csa103: Instantiated as component instance csa103CompI1.&lt;br /&gt;
Mon Jul 14 00:01:09 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00034 :   INFO)&lt;br /&gt;
 csa103CompI1: Waiting for CSI assignment...&lt;br /&gt;
Mon Jul 14 00:01:09 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00035 :   INFO)&lt;br /&gt;
 csa103CompI1: Waiting for CSI assignment...&lt;br /&gt;
Mon Jul 14 00:01:09 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00036 :   INFO)&lt;br /&gt;
 csa103CompI1: checkpoint_initialize&lt;br /&gt;
Mon Jul 14 00:01:09 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00043 :   INFO)&lt;br /&gt;
 csa103CompI1: Checkpoint service initialized (handle=0x1)&lt;br /&gt;
Mon Jul 14 00:01:09 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00045 :   INFO)&lt;br /&gt;
 csa103CompI1: Checkpoint opened (handle=0x2)&lt;br /&gt;
Mon Jul 14 00:01:09 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00053 :   INFO)&lt;br /&gt;
 csa103CompI1: Section created&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;Then, unlock the application by running &lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
cli[Test:SCNodeI0:CPM]-&amp;gt; amsUnlock sg csa103SGI0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the application log files, you should see &lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffffaa;&amp;quot; align=&amp;quot;center&amp;quot;| /root/asp/var/log/csa103CompI0Log.latest&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
Mon Jul 14 00:09:08 2008   (SCNodeI0.15238 : csa103CompEO.---.---.00058 :   INFO)&lt;br /&gt;
  Standby state requested from state 0&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffffaa;&amp;quot; align=&amp;quot;center&amp;quot;| /root/asp/var/log/csa103CompI1Log.latest&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
Mon Jul 14 00:09:08 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00064 :   INFO)&lt;br /&gt;
 csa103CompI1: Active state requested from state 0&lt;br /&gt;
Mon Jul 14 00:09:09 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00065 :   INFO)&lt;br /&gt;
 csa103CompI1: Hello World! (seq=0)&lt;br /&gt;
Mon Jul 14 00:09:10 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00066 :   INFO)&lt;br /&gt;
 csa103CompI1: Hello World! (seq=1)&lt;br /&gt;
Mon Jul 14 00:09:11 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00067 :   INFO)&lt;br /&gt;
 csa103CompI1: Hello World! (seq=2)&lt;br /&gt;
Mon Jul 14 00:09:12 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00068 :   INFO)&lt;br /&gt;
 csa103CompI1: Hello World! (seq=3)&lt;br /&gt;
Mon Jul 14 00:09:13 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00069 :   INFO)&lt;br /&gt;
 csa103CompI1: Hello World! (seq=4)&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;Next, find the active csa103 process, the one that's printing the Hello World lines and kill it.  To find the process ID issue the following command from a bash shell.&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
 # ps -eaf | grep csa103&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
This should produce an output that looks similar to the following.&lt;br /&gt;
 root     17830 15663  0 14:21 ?        00:00:00 csa103Comp -p&lt;br /&gt;
 root     17839 15663  0 14:21 ?        00:00:00 csa103Comp -p&lt;br /&gt;
 root     18558 16145  0 14:32 pts/4    00:00:00 grep csa103&lt;br /&gt;
Notice the two entries that end with csa103Comp -p. These are our two component processes. The first one is usually the active process. This is the one that we will kill. In this case the process ID is 17830. So to kill the active component you issue the command:&lt;br /&gt;
&lt;br /&gt;
 # kill -9 17830&lt;br /&gt;
&lt;br /&gt;
[[File:OpenClovis_Note.png]]If this step does not result in the active component being killed then it is likely that the standby component was killed. In this case simply try killing the other process. &lt;br /&gt;
&lt;br /&gt;
After killing the active component you should see lines in the log files like the following:&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffffaa;&amp;quot; align=&amp;quot;center&amp;quot;| /root/asp/var/log/csa103CompI1Log.latest&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
Mon Jul 14 00:16:43 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00515 :   INFO)&lt;br /&gt;
 csa103CompI1: Hello World! (seq=452)&lt;br /&gt;
Mon Jul 14 00:16:44 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00516 :   INFO)&lt;br /&gt;
 csa103CompI1: Hello World! (seq=453)&lt;br /&gt;
Mon Jul 14 00:16:45 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00517 :   INFO)&lt;br /&gt;
 csa103CompI1: Hello World! (seq=454)&lt;br /&gt;
Mon Jul 14 00:16:46 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00518 :   INFO)&lt;br /&gt;
 csa103CompI1: Hello World! (seq=455)&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffffaa;&amp;quot; align=&amp;quot;center&amp;quot;| /var/log/csa103CompI0Log.latest&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
Mon Jul 14 00:16:48 2008   (SCNodeI0.15238 : csa103CompEO.---.---.00065 :   INFO)&lt;br /&gt;
 csa103CompI0: Active state requested from state 2&lt;br /&gt;
Mon Jul 14 00:16:48 2008   (SCNodeI0.15238 : csa103CompEO.---.---.00066 :   INFO)&lt;br /&gt;
 csa103CompI0 reading checkpoint&lt;br /&gt;
Mon Jul 14 00:16:48 2008   (SCNodeI0.15238 : csa103CompEO.---.---.00067 :   INFO)&lt;br /&gt;
 csa103CompI0 read checkpoint: seq = 456&lt;br /&gt;
Mon Jul 14 00:16:49 2008   (SCNodeI0.15238 : csa103CompEO.---.---.00068 :   INFO)&lt;br /&gt;
 csa103CompI0: Hello World! (seq=456)&lt;br /&gt;
Mon Jul 14 00:16:50 2008   (SCNodeI0.15238 : csa103CompEO.---.---.00069 :   INFO)&lt;br /&gt;
 csa103CompI0: Hello World! (seq=457)&lt;br /&gt;
Mon Jul 14 00:16:51 2008   (SCNodeI0.15238 : csa103CompEO.---.---.00070 :   INFO)&lt;br /&gt;
 csa103CompI0: Hello World! (seq=458)&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
Where we can see CompI1 printing 455 and then dieing, where upon CompI0 gets the notice to take over processing, reads the checkpoint and then takes over with seq=456 and so on.&lt;br /&gt;
&lt;br /&gt;
Then, in the CompI1 log file we see:&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffffaa;&amp;quot; align=&amp;quot;center&amp;quot;| /root/asp/var/log/csa103CompI1Log.latest&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
Mon Jul 14 00:16:49 2008   (SCNodeI0.15553 : csa103CompEO.---.---.00044 :   INFO)&lt;br /&gt;
 csa103: Instantiated as component instance csa103CompI1.&lt;br /&gt;
Mon Jul 14 00:16:49 2008   (SCNodeI0.15553 : csa103CompEO.---.---.00045 :   INFO)&lt;br /&gt;
 csa103CompI1: Waiting for CSI assignment...&lt;br /&gt;
Mon Jul 14 00:16:49 2008   (SCNodeI0.15553 : csa103CompEO.---.---.00046 :   INFO)&lt;br /&gt;
 csa103CompI1: Waiting for CSI assignment...&lt;br /&gt;
Mon Jul 14 00:16:49 2008   (SCNodeI0.15553 : csa103CompEO.---.---.00047 :   INFO)&lt;br /&gt;
 csa103CompI1: checkpoint_initialize&lt;br /&gt;
Mon Jul 14 00:16:50 2008   (SCNodeI0.15553 : csa103CompEO.---.---.00054 :   INFO)&lt;br /&gt;
 csa103CompI1: Checkpoint service initialized (handle=0x1)&lt;br /&gt;
Mon Jul 14 00:16:50 2008   (SCNodeI0.15553 : csa103CompEO.---.---.00056 :   INFO)&lt;br /&gt;
 csa103CompI1: Checkpoint opened (handle=0x2)&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
That is the component that had been killed being restarted.  &lt;br /&gt;
&lt;br /&gt;
CompI0 is moving along just fine, and we see CompI1 come back up.  If we then kill CompI0 we see:&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffffaa;&amp;quot; align=&amp;quot;center&amp;quot;| /root/asp/var/log/csa103CompI1Log.latest&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
Mon Jul 14 00:29:44 2008   (SCNodeI0.15553 : csa103CompEO.---.---.00065 :   INFO)&lt;br /&gt;
 csa103CompI1: Active state requested from state 2&lt;br /&gt;
Mon Jul 14 00:29:44 2008   (SCNodeI0.15553 : csa103CompEO.---.---.00066 :   INFO)&lt;br /&gt;
 csa103CompI1 reading checkpoint&lt;br /&gt;
Mon Jul 14 00:29:44 2008   (SCNodeI0.15553 : csa103CompEO.---.---.00067 :   INFO)&lt;br /&gt;
 csa103CompI1 read checkpoint: seq = 1225&lt;br /&gt;
Mon Jul 14 00:29:45 2008   (SCNodeI0.15553 : csa103CompEO.---.---.00068 :   INFO)&lt;br /&gt;
 csa103CompI1: Hello World! (seq=1225)&lt;br /&gt;
Mon Jul 14 00:29:46 2008   (SCNodeI0.15553 : csa103CompEO.---.---.00069 :   INFO)&lt;br /&gt;
 csa103CompI1: Hello World! (seq=1226)&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
Where we can see the CompI0 process die, and CompI1 process read the sequence number from the checkpoint and then take over from where CompI0 left off.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;To stop csa103 use the following SAFplus Platform Console command.&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
cli[Test:SCNodeI0:CPM]-&amp;gt; amsLockAssignment sg csa103SGI0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;Now change the state of csa103SGI0 to LockInstantiation and close the SAFplus Platform Console.&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
cli[Test:SCNodeI0:CPM]-&amp;gt; amsLockInstantiation sg csa103SGI0&lt;br /&gt;
cli[Test:SCNodeI0:CPM] -&amp;gt; end&lt;br /&gt;
cli[Test:SCNodeI0] -&amp;gt; end&lt;br /&gt;
cli[Test] -&amp;gt; bye&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Additional Tests for Runtime Hardware Setup 1.3 and 2.3===&lt;br /&gt;
&lt;br /&gt;
Now repeat  the experiment till the stage before we kill  the active process  and follow these steps.&lt;br /&gt;
&lt;br /&gt;
'''Step A'''&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Stop SAFplus Platform on SCNodeI0 using &amp;lt;code&amp;gt;/etc/init.d/asp stop&amp;lt;/code&amp;gt;. Observer the logs &amp;lt;code&amp;gt;/root/asp/var/log/csa103CompI3Log.latest&amp;lt;/code&amp;gt; on SCNodeI1. This will become active  and start printing the hello world logs as above. &lt;br /&gt;
Note in this case active System Controller SCNode1 is still aware of PayloadNodeI0 and PayloadNodeI1.&lt;br /&gt;
&amp;lt;li&amp;gt;Start looking at the logs  for &amp;lt;code&amp;gt;/root/asp/var/log/csa103CompI0Log.latest&amp;lt;/code&amp;gt; in PayloadNodeI0. This will print the  standby  logs as  above.&lt;br /&gt;
&amp;lt;li&amp;gt;Stop  SAFplus Platform  on PayloadNodeI0  and start observing the logs on PayloadNodeI1 in &amp;lt;code&amp;gt;/root/asp/var/log/csa103CompI1Log.latest&amp;lt;/code&amp;gt; for standby.&lt;br /&gt;
In this case, you can see, via the active System Controller logs that PayloadNodeI0 is not active whilst PayloadNodeI1 is.&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Step B'''  For Hardware Setup 1.3 only&lt;br /&gt;
#Repeat A  with the slight exception  that the  blade running SCNodeI0  is  yanked out(&amp;lt;code&amp;gt;/etc/init.d/asp zap&amp;lt;/code&amp;gt;) instead of gracefully shutting  down SAFplus Platform in step 1.&lt;br /&gt;
&lt;br /&gt;
===Summary and References===&lt;br /&gt;
We've seen :&lt;br /&gt;
&lt;br /&gt;
*how to use Clovis' checkpoint service to save some program state and recover that state from a separate process&lt;br /&gt;
*how to initialize the client checkpoint library&lt;br /&gt;
*how to create and open checkpoints &lt;br /&gt;
*how to create and use sections in an opened checkpoint&lt;br /&gt;
&lt;br /&gt;
Further information can be found within the following: ''OpenClovis API Reference Guide''.&lt;/div&gt;</summary>
		<author><name>Madhu</name></author>	</entry>

	<entry>
		<id>https://help.openclovis.com/index.php/Doc:latest/evalguide/csa103</id>
		<title>Doc:latest/evalguide/csa103</title>
		<link rel="alternate" type="text/html" href="https://help.openclovis.com/index.php/Doc:latest/evalguide/csa103"/>
				<updated>2010-10-01T05:15:34Z</updated>
		
		<summary type="html">&lt;p&gt;Madhu: /* The Code */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==csa103 Checkpointing==&lt;br /&gt;
&lt;br /&gt;
===Objective===&lt;br /&gt;
&lt;br /&gt;
csa103 demonstrates how to use the Clovis Checkpoint service to provide basic failure recovery.  csa103 builds on csa102.&lt;br /&gt;
&lt;br /&gt;
===What Will You Learn===&lt;br /&gt;
&lt;br /&gt;
*how to initialize the checkpoint client library, &lt;br /&gt;
*how to create a checkpoint and  open a checkpoint, &lt;br /&gt;
*how to create a section in the checkpoint &lt;br /&gt;
*how to save data to the checkpoint section and read data from the checkpoint section.&lt;br /&gt;
&lt;br /&gt;
===The Code===&lt;br /&gt;
&lt;br /&gt;
The code can be found within the following directory&lt;br /&gt;
 &amp;lt;project-area_dir&amp;gt;/eval/src/app/csa103Comp&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffccaa;&amp;quot; align=&amp;quot;center&amp;quot;| clCompAppMain.c&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
ClCompAppInitialize()&lt;br /&gt;
&lt;br /&gt;
        ...&lt;br /&gt;
&lt;br /&gt;
        if ((rc = checkpoint_initialize()) != CL_OK)&lt;br /&gt;
        {&lt;br /&gt;
            clprintf(CL_LOG_SEV_ERROR,&amp;quot;%s: Failed [0x%x] to initialize checkpoint&amp;quot;,&lt;br /&gt;
                    appname, rc);&lt;br /&gt;
            return rc;&lt;br /&gt;
        }&lt;br /&gt;
        if ((rc = checkpoint_read_seq(&amp;amp;seq)) != CL_OK)&lt;br /&gt;
        {&lt;br /&gt;
            clprintf(CL_LOG_SEV_ERROR,&amp;quot;%s: Failed [0x%x] to read checkpoint&amp;quot;,&lt;br /&gt;
                    appname, rc);&lt;br /&gt;
            checkpoint_finalize();&lt;br /&gt;
            return rc;&lt;br /&gt;
        }&lt;br /&gt;
    #ifdef CL_INST&lt;br /&gt;
        if ((rc = clDataTapInit(DATA_TAP_DEFAULT_FLAGS, 103)) != CL_OK)&lt;br /&gt;
        {&lt;br /&gt;
            clprintf(CL_LOG_SEV_ERROR,&amp;quot;%s: Failed [0x%x] to initialize data tap&amp;quot;,&lt;br /&gt;
                    appname, rc);&lt;br /&gt;
        }&lt;br /&gt;
    #endif&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
The above software in &amp;lt;code&amp;gt;clCompAppMain.c&amp;lt;/code&amp;gt; is new to csa103. The call to &amp;lt;code&amp;gt;checkpoint_initialize&amp;lt;/code&amp;gt; is pretty straightforward.  This function discussed in detail later within this section.  The call to &amp;lt;code&amp;gt;checkpoint_read_seq&amp;lt;/code&amp;gt; is also pretty straightforward.  It reads the current sequence value from the checkpoint (at this point it should be zero) and loads it into the variable: &amp;lt;code&amp;gt;seq&amp;lt;/code&amp;gt;.  It is important to note the call to &amp;lt;code&amp;gt;checkpont_finalize&amp;lt;/code&amp;gt; if the call to &amp;lt;code&amp;gt;checkpoint_read_seq&amp;lt;/code&amp;gt; does not return &amp;lt;code&amp;gt;CL_OK&amp;lt;/code&amp;gt;.  This call closes the checkpoint and cleanly finalizes the checkpoint library.  We'll look more at &amp;lt;code&amp;gt;checkpoint_read_seq&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;checkpoint_finalize&amp;lt;/code&amp;gt; later.&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffccaa;&amp;quot; align=&amp;quot;center&amp;quot;| clCompAppMain.c&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
        /* Checkpoint new sequence number */&lt;br /&gt;
        rc = checkpoint_write_seq(seq);&lt;br /&gt;
        if (rc != CL_OK)&lt;br /&gt;
        {&lt;br /&gt;
            clprintf(CL_LOG_SEV_ERROR,&amp;quot;%s: ERROR: Checkpoint write failed. Exiting.&amp;quot;, appname);&lt;br /&gt;
            break;&lt;br /&gt;
        }&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
The rest of the csa103's main loop is the same as the main loop in csa102, but the seven lines above are new.  Here we write the new value of the checkpoint variable to the checkpoint section and print and error if this fails.  We'll look closer at &amp;lt;code&amp;gt;checkpoint_write_seq&amp;lt;/code&amp;gt; later.&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffccaa;&amp;quot; align=&amp;quot;center&amp;quot;| clCompAppMain.c&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
    ClRcT&lt;br /&gt;
    clCompAppAMFCSISet(&lt;br /&gt;
        ClInvocationT       invocation,&lt;br /&gt;
        const ClNameT       *compName,&lt;br /&gt;
        ClAmsHAStateT       haState,&lt;br /&gt;
        ClAmsCSIDescriptorT csiDescriptor)&lt;br /&gt;
    {    &lt;br /&gt;
        /*&lt;br /&gt;
         * ---BEGIN_APPLICATION_CODE--- &lt;br /&gt;
         */&lt;br /&gt;
        ClCharT     compname[100]={0};&lt;br /&gt;
&lt;br /&gt;
        /*&lt;br /&gt;
         * ---END_APPLICATION_CODE---&lt;br /&gt;
         */&lt;br /&gt;
&lt;br /&gt;
        /*&lt;br /&gt;
         * Print information about the CSI Set&lt;br /&gt;
         */&lt;br /&gt;
        strncpy(compname, compName-&amp;gt;value, compName-&amp;gt;length);&lt;br /&gt;
&lt;br /&gt;
        clprintf (CL_LOG_SEV_INFO, &amp;quot;Component [%s] : PID [%d]. CSI Set Received&amp;quot;, &lt;br /&gt;
              compname, (int)mypid);&lt;br /&gt;
&lt;br /&gt;
        clCompAppAMFPrintCSI(csiDescriptor, haState);&lt;br /&gt;
    &lt;br /&gt;
        /*&lt;br /&gt;
          Take appropriate action based on state&lt;br /&gt;
        */&lt;br /&gt;
    &lt;br /&gt;
        switch ( haState )&lt;br /&gt;
        {&lt;br /&gt;
            case CL_AMS_HA_STATE_ACTIVE:&lt;br /&gt;
            {&lt;br /&gt;
                /*&lt;br /&gt;
                  AMF has requested application to take the active HA state&lt;br /&gt;
                  for the CSI.&lt;br /&gt;
                */&lt;br /&gt;
    &lt;br /&gt;
                /*&lt;br /&gt;
                  ---BEGIN_APPLICATION_CODE---&lt;br /&gt;
                */&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffccaa;&amp;quot; align=&amp;quot;center&amp;quot;| clCompAppMain.c&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;   &lt;br /&gt;
                clprintf(CL_LOG_SEV_INFO,&amp;quot;%s: Active state requested from state %d&amp;quot;,&lt;br /&gt;
                        appname, ha_state);&lt;br /&gt;
&lt;br /&gt;
                checkpoint_replica_activate();&lt;br /&gt;
                if (ha_state == SA_AMF_HA_STANDBY)&lt;br /&gt;
                {&lt;br /&gt;
                    /* Read checkpoint, make our replica the active replica */&lt;br /&gt;
                    clprintf(CL_LOG_SEV_INFO,&amp;quot;%s reading checkpoint&amp;quot;, appname);&lt;br /&gt;
                    checkpoint_read_seq(&amp;amp;seq);&lt;br /&gt;
                    clprintf(CL_LOG_SEV_INFO,&amp;quot;%s read checkpoint: seq = %u&amp;quot;, appname, seq);&lt;br /&gt;
                }&lt;br /&gt;
            &lt;br /&gt;
                ha_state = SA_AMF_HA_ACTIVE;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
                /*&lt;br /&gt;
                 * ---END_APPLICATION_CODE---&lt;br /&gt;
                 */&lt;br /&gt;
&lt;br /&gt;
                clCpmResponse(cpmHandle, invocation, CL_OK);&lt;br /&gt;
                break;&lt;br /&gt;
            }&lt;br /&gt;
&lt;br /&gt;
            case CL_AMS_HA_STATE_STANDBY:&lt;br /&gt;
            {&lt;br /&gt;
                /*&lt;br /&gt;
                 * AMF has requested application to take the standby HA state &lt;br /&gt;
                 * for this CSI.&lt;br /&gt;
                 */&lt;br /&gt;
&lt;br /&gt;
                /*&lt;br /&gt;
                 * ---BEGIN_APPLICATION_CODE---&lt;br /&gt;
                 */&lt;br /&gt;
&lt;br /&gt;
                 clprintf(CL_LOG_SEV_INFO,&amp;quot; Standby state requested from state %d&amp;quot;,ha_state);&lt;br /&gt;
            &lt;br /&gt;
                 ha_state = SA_AMF_HA_STANDBY;&lt;br /&gt;
&lt;br /&gt;
                /*&lt;br /&gt;
                 * ---END_APPLICATION_CODE---&lt;br /&gt;
                 */&lt;br /&gt;
&lt;br /&gt;
                clCpmResponse(cpmHandle, invocation, CL_OK);&lt;br /&gt;
                break;&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffccaa;&amp;quot; align=&amp;quot;center&amp;quot;| clCompAppMain.c&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;    &lt;br /&gt;
            case CL_AMS_HA_STATE_QUIESCED:&lt;br /&gt;
            {&lt;br /&gt;
                /*&lt;br /&gt;
                 * AMF has requested application to quiesce the CSI currently&lt;br /&gt;
                 * assigned the active or quiescing HA state. The application &lt;br /&gt;
                 * must stop work associated with the CSI immediately.&lt;br /&gt;
                 */&lt;br /&gt;
&lt;br /&gt;
                /*&lt;br /&gt;
                 * ---BEGIN_APPLICATION_CODE---&lt;br /&gt;
                 */&lt;br /&gt;
&lt;br /&gt;
                clprintf(CL_LOG_SEV_INFO,&amp;quot;%s: QUIESCED&amp;quot;, appname);&lt;br /&gt;
                ha_state = haState;&lt;br /&gt;
&lt;br /&gt;
                /*&lt;br /&gt;
                 * ---END_APPLICATION_CODE---&lt;br /&gt;
                 */&lt;br /&gt;
&lt;br /&gt;
                clCpmResponse(cpmHandle, invocation, CL_OK);&lt;br /&gt;
                break;&lt;br /&gt;
            }&lt;br /&gt;
&lt;br /&gt;
            case CL_AMS_HA_STATE_QUIESCING:&lt;br /&gt;
            { &lt;br /&gt;
                /*&lt;br /&gt;
                 * AMF has requested application to quiesce the CSI currently&lt;br /&gt;
                 * assigned the active HA state. The application must stop work&lt;br /&gt;
                 * associated with the CSI gracefully and not accept any new&lt;br /&gt;
                 * workloads while the work is being terminated.&lt;br /&gt;
                 */&lt;br /&gt;
&lt;br /&gt;
                /*&lt;br /&gt;
                 * ---BEGIN_APPLICATION_CODE---&lt;br /&gt;
                 */&lt;br /&gt;
&lt;br /&gt;
                clprintf(CL_LOG_SEV_INFO,&amp;quot;%s: QUIESCING&amp;quot;, appname);&lt;br /&gt;
                ha_state = haState;&lt;br /&gt;
&lt;br /&gt;
                /*&lt;br /&gt;
                 * ---END_APPLICATION_CODE---&lt;br /&gt;
                 */&lt;br /&gt;
&lt;br /&gt;
                clCpmCSIQuiescingComplete(cpmHandle, invocation, CL_OK);&lt;br /&gt;
                break;&lt;br /&gt;
            }&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffccaa;&amp;quot; align=&amp;quot;center&amp;quot;| clCompAppMain.c&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
            default:&lt;br /&gt;
            {&lt;br /&gt;
                break;&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
    &lt;br /&gt;
        return CL_OK;&lt;br /&gt;
    }&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now looking at csa103's implementation of &amp;lt;code&amp;gt;clCompAppAMFCSISet&amp;lt;/code&amp;gt;, we see that rather than just a few cases, we handle several cases: &amp;lt;code&amp;gt;QUIESCING&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;QUIESCED&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;ACTIVE&amp;lt;/code&amp;gt;, and  &amp;lt;code&amp;gt;STANDBY&amp;lt;/code&amp;gt;.  In each state, the global variable &amp;lt;code&amp;gt;ha_state&amp;lt;/code&amp;gt; to the new_state value that is passed in is set.  This is similar to csa102, except that we add the feature that in the &amp;lt;code&amp;gt;CL_AMS_HA_STATE_ACTIVE&amp;lt;/code&amp;gt; case if our previous state was &amp;lt;code&amp;gt;CL_AMS_HA_STATE_STANDBY&amp;lt;/code&amp;gt; we read the sequence from the checkpoint so that the main loop will pick it up.&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffccaa;&amp;quot; align=&amp;quot;center&amp;quot;| clCompAppMain.c&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
    static ClRcT&lt;br /&gt;
    checkpoint_initialize()&lt;br /&gt;
    {&lt;br /&gt;
        SaAisErrorT      rc = CL_OK;&lt;br /&gt;
        SaVersionT ckpt_version = {'B', 1, 1};&lt;br /&gt;
        SaNameT    ckpt_name = { strlen(CKPT_NAME), CKPT_NAME };&lt;br /&gt;
        ClUint32T  seq_no;&lt;br /&gt;
        SaCkptCheckpointCreationAttributesT create_atts = {&lt;br /&gt;
            .creationFlags     = SA_CKPT_WR_ACTIVE_REPLICA_WEAK |&lt;br /&gt;
                             SA_CKPT_CHECKPOINT_COLLOCATED,&lt;br /&gt;
            .checkpointSize    = sizeof(ClUint32T),&lt;br /&gt;
            .retentionDuration = (ClTimeT)10,&lt;br /&gt;
            .maxSections       = 2, // two sections &lt;br /&gt;
            .maxSectionSize    = sizeof(ClUint32T),&lt;br /&gt;
            .maxSectionIdSize  = (ClSizeT)64&lt;br /&gt;
&lt;br /&gt;
        &lt;br /&gt;
        };&lt;br /&gt;
        SaCkptSectionCreationAttributesT section_atts = {&lt;br /&gt;
        .sectionId = &amp;amp;ckpt_sid,&lt;br /&gt;
        .expirationTime = SA_TIME_END&lt;br /&gt;
&lt;br /&gt;
        };&lt;br /&gt;
 &lt;br /&gt;
        clprintf(CL_LOG_SEV_INFO,&amp;quot;%s: checkpoint_initialize&amp;quot;, appname);&lt;br /&gt;
        /* Initialize checkpointing service instance */&lt;br /&gt;
        rc = saCkptInitialize(&amp;amp;ckpt_svc_handle,	/* Checkpoint service handle */&lt;br /&gt;
						  NULL,			    /* Optional callbacks table */&lt;br /&gt;
						  &amp;amp;ckpt_version);   /* Required verison number */&lt;br /&gt;
        if (rc != SA_AIS_OK)&lt;br /&gt;
        {&lt;br /&gt;
            clprintf(CL_LOG_SEV_ERROR,&amp;quot;%s: ERROR: Failed to initialize checkpoint service&amp;quot;,&lt;br /&gt;
                    appname);&lt;br /&gt;
            return rc;&lt;br /&gt;
        }&lt;br /&gt;
        clprintf(CL_LOG_SEV_INFO,&amp;quot;%s: Checkpoint service initialized (handle=0x%llx)&amp;quot;,&lt;br /&gt;
           appname, ckpt_svc_handle);&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Here is &amp;lt;code&amp;gt;checkpoint_initialize&amp;lt;/code&amp;gt;.  Here we initialize the &amp;lt;code&amp;gt;ClNameT&amp;lt;/code&amp;gt; structure that holds the name of the checkpoint to be opened/created with the line: &amp;lt;code&amp;gt;ClNameT    ckpt_name = { strlen(CKPT_NAME), CKPT_NAME };&amp;lt;/code&amp;gt;. We then define a set of attributes to associate with the checkpoint when creating that checkpoint. The &amp;lt;code&amp;gt;creationFlags&amp;lt;/code&amp;gt; includes &amp;lt;code&amp;gt;CL_CKPT_WR_ACTIVE_REPLICA&amp;lt;/code&amp;gt;.  This means that the checkpoint to be created will be asynchronous, or once active server updation is completed, the call returns to the application, all other replica updates happens parallel. &amp;lt;code&amp;gt;CheckpointSize&amp;lt;/code&amp;gt; is set to the sizeof a 32 bit unsigned integer, which is the sequence number we print in the main loop.  The &amp;lt;code&amp;gt;retentionDuration&amp;lt;/code&amp;gt; is the time that the checkpoint service will keep the checkpoint in store after the last client has closed the checkpoint.  &amp;lt;code&amp;gt;MaxSections&amp;lt;/code&amp;gt; is 2 as this checkpoint will be used to store two sections.  &amp;lt;code&amp;gt;MaxSectionSize&amp;lt;/code&amp;gt; is the set to the sizeof a 32 bit unsigned integer, as application stores only unsigned integer. And &amp;lt;code&amp;gt;maxSectionIdSize&amp;lt;/code&amp;gt; is 64 bytes.&lt;br /&gt;
&lt;br /&gt;
We next use &amp;lt;code&amp;gt;ClCkptSectionCreationAttributesT section_atts&amp;lt;/code&amp;gt; to define the creation attributes for the sole section of the checkpoint. The &amp;lt;code&amp;gt;sectionId&amp;lt;/code&amp;gt; is just the name of the section along with the number of bytes in the name.  The &amp;lt;code&amp;gt;expirationTime&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;CL_TIME_END&amp;lt;/code&amp;gt; to imply that the section is never deleted automatically if the checkpoint itself still remains.&lt;br /&gt;
&lt;br /&gt;
The call to &amp;lt;code&amp;gt;clCkptInitialize&amp;lt;/code&amp;gt; has to be called before any other checkpoint functions.  The &amp;lt;code&amp;gt;ckpt_svc_handle&amp;lt;/code&amp;gt; is where the handle is returned.  The handle must be passed to some future checkpoint api calls, namely the &amp;lt;code&amp;gt;clCkptCheckpointOpen&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;clCkptFinalize&amp;lt;/code&amp;gt; calls.  The callbacks table is passed as &amp;lt;code&amp;gt;NULL&amp;lt;/code&amp;gt; which implies that our application doesn't provide any callbacks.  Finally the &amp;lt;code&amp;gt;ckpt_version&amp;lt;/code&amp;gt; identifies what version of the api this application is written to.&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffccaa;&amp;quot; align=&amp;quot;center&amp;quot;| clCompAppMain.c&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
        //&lt;br /&gt;
        // Create the checkpoint for read and write.            &lt;br /&gt;
&lt;br /&gt;
        rc = saCkptCheckpointOpen(ckpt_svc_handle,      // Service handle&lt;br /&gt;
                              &amp;amp;ckpt_name,         // Checkpoint name&lt;br /&gt;
                              &amp;amp;create_atts,       // Optional creation attr.&lt;br /&gt;
                              (SA_CKPT_CHECKPOINT_READ |&lt;br /&gt;
                               SA_CKPT_CHECKPOINT_WRITE |&lt;br /&gt;
                               SA_CKPT_CHECKPOINT_CREATE),&lt;br /&gt;
                              (SaTimeT)-1,        // No timeout&lt;br /&gt;
                              &amp;amp;ckpt_handle);      // Checkpoint handle&lt;br /&gt;
&lt;br /&gt;
        if (rc != SA_AIS_OK)&lt;br /&gt;
&lt;br /&gt;
        {&lt;br /&gt;
            clprintf(CL_LOG_SEV_ERROR,&amp;quot;%s: ERROR: Failed [0x%x] to open checkpoint&amp;quot;,&lt;br /&gt;
                    appname, rc);&lt;br /&gt;
            (void)saCkptFinalize(ckpt_svc_handle);&lt;br /&gt;
            return rc;&lt;br /&gt;
        }&lt;br /&gt;
        clprintf(CL_LOG_SEV_INFO,&amp;quot;%s: Checkpoint opened (handle=0x%llx)&amp;quot;, appname, ckpt_handle);&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
 &lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffccaa;&amp;quot; align=&amp;quot;center&amp;quot;| clCompAppMain.c&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
        /*&lt;br /&gt;
         * Try to create a section so that updates can operate by overwriting&lt;br /&gt;
         * the section over and over again.&lt;br /&gt;
         * If subsequent processes come through here, they will fail to create&lt;br /&gt;
         * the section.  That is OK, even though it will cause an error message&lt;br /&gt;
         * If the section create fails because the section is already there, then&lt;br /&gt;
         * read the sequence number&lt;br /&gt;
         */&lt;br /&gt;
        // Put data in network byte order&lt;br /&gt;
        seq_no = htonl(seq);&lt;br /&gt;
&lt;br /&gt;
        // Creating the section&lt;br /&gt;
        checkpoint_replica_activate();&lt;br /&gt;
        rc = saCkptSectionCreate(ckpt_handle,           // Checkpoint handle&lt;br /&gt;
                             &amp;amp;section_atts,         // Section attributes&lt;br /&gt;
                             (SaUint8T*)&amp;amp;seq_no,    // Initial data&lt;br /&gt;
                             (SaSizeT)sizeof(seq_no)); // Size of data&lt;br /&gt;
        if (rc != SA_AIS_OK &amp;amp;&amp;amp; (CL_GET_ERROR_CODE(rc) != SA_AIS_ERR_EXIST))&lt;br /&gt;
        {&lt;br /&gt;
            clprintf(CL_LOG_SEV_ERROR,&amp;quot;%s: ERROR: Failed to create checkpoint section&amp;quot;, appname);&lt;br /&gt;
            (void)saCkptCheckpointClose(ckpt_handle);&lt;br /&gt;
            (void)saCkptFinalize(ckpt_svc_handle);&lt;br /&gt;
            return rc;&lt;br /&gt;
        }&lt;br /&gt;
        else if (rc != SA_AIS_OK &amp;amp;&amp;amp; (CL_GET_ERROR_CODE(rc) == SA_AIS_ERR_EXIST))&lt;br /&gt;
        {&lt;br /&gt;
            rc = checkpoint_read_seq(&amp;amp;seq);&lt;br /&gt;
            if (rc != CL_OK)&lt;br /&gt;
            {&lt;br /&gt;
                clprintf(CL_LOG_SEV_ERROR,&amp;quot;%s: ERROR: Failed [0x%x] to read checkpoint section&amp;quot;,&lt;br /&gt;
                            appname, rc);&lt;br /&gt;
                (void)saCkptCheckpointClose(ckpt_handle);&lt;br /&gt;
                (void)saCkptFinalize(ckpt_svc_handle);&lt;br /&gt;
                return rc;&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
        else&lt;br /&gt;
        {&lt;br /&gt;
            clprintf(CL_LOG_SEV_INFO,&amp;quot;%s: Section created&amp;quot;, appname);&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        return CL_OK;&lt;br /&gt;
    }&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
With &amp;lt;code&amp;gt;rc = clCkptCheckpointOpen&amp;lt;/code&amp;gt; we attempt to open the specified checkpoint.  When &amp;lt;code&amp;gt;checkpoint_initialize&amp;lt;/code&amp;gt; is called the checkpoint may or may not exist.  We attempt to open the checkpoint for READ/WRITE access. &lt;br /&gt;
&lt;br /&gt;
Next we check if we created the checkpoint and then we need to create the section with a call to &amp;lt;code&amp;gt;clCkptSectionCreate&amp;lt;/code&amp;gt;.  We pass the checkpoint handle obtained from &amp;lt;code&amp;gt;clCkptCheckpointOpen&amp;lt;/code&amp;gt;, the section attributes declared earlier, and the address of the initial value along with the size in bytes of the initial value.&lt;br /&gt;
&lt;br /&gt;
We convert the initial value to network byte order by the code &amp;lt;code&amp;gt;seq_no = htonl(seq)&amp;lt;/code&amp;gt;, before passing it to &amp;lt;code&amp;gt;clCkptSectionCreate&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If we do not create the section, then we read the current value in the checkpoint into our global seq variable.&lt;br /&gt;
&lt;br /&gt;
Note that whenever we return an error return code from the function that we have either not opened the checkpoint/initialized the checkpoint service, or we have closed the checkpoint and finalized the checkpoint service with calls to &amp;lt;code&amp;gt;clCkptCheckpointClose&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;clCkptFinalize&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffccaa;&amp;quot; align=&amp;quot;center&amp;quot;| clCompAppMain.c&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
    static ClRcT &lt;br /&gt;
    checkpoint_finalize(void)&lt;br /&gt;
    {&lt;br /&gt;
        SaAisErrorT rc;&lt;br /&gt;
&lt;br /&gt;
        rc = saCkptCheckpointClose(ckpt_handle);&lt;br /&gt;
        if (rc != SA_AIS_OK)&lt;br /&gt;
        {&lt;br /&gt;
            clprintf(CL_LOG_SEV_ERROR,&amp;quot;%s: failed: [0x%x] to close checkpoint handle 0x%llx&amp;quot;,&lt;br /&gt;
                        appname, rc, ckpt_handle);&lt;br /&gt;
        }&lt;br /&gt;
        rc = saCkptFinalize(ckpt_svc_handle);&lt;br /&gt;
        if (rc != SA_AIS_OK)&lt;br /&gt;
        {&lt;br /&gt;
            clprintf(CL_LOG_SEV_ERROR,&amp;quot;%s: failed: [0x%x] to finalize checkpoint&amp;quot;,&lt;br /&gt;
                    appname, rc);&lt;br /&gt;
        }&lt;br /&gt;
        return CL_OK;&lt;br /&gt;
&lt;br /&gt;
    }&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
The above code snippet presents &amp;lt;code&amp;gt;checkpoint_finalize&amp;lt;/code&amp;gt;.  It's quite simple.  First it closes the checkpoint handle with a call to &amp;lt;code&amp;gt;clCkptCheckpointClose&amp;lt;/code&amp;gt;.  Next it finalizes the checkpoint library with a call to &amp;lt;code&amp;gt;clCkptFinalize&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffccaa;&amp;quot; align=&amp;quot;center&amp;quot;| clCompAppMain.c&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
    static ClRcT&lt;br /&gt;
    checkpoint_write_seq(ClUint32T seq)&lt;br /&gt;
    {&lt;br /&gt;
        SaAisErrorT rc = SA_AIS_OK;&lt;br /&gt;
        ClUint32T seq_no;&lt;br /&gt;
&lt;br /&gt;
        /* Putting data in network byte order */&lt;br /&gt;
        seq_no = htonl(seq);&lt;br /&gt;
&lt;br /&gt;
        /* Write checkpoint */&lt;br /&gt;
        retry:&lt;br /&gt;
        rc = saCkptSectionOverwrite(ckpt_handle,&lt;br /&gt;
                                &amp;amp;ckpt_sid,&lt;br /&gt;
                                &amp;amp;seq_no,&lt;br /&gt;
                                sizeof(ClUint32T));&lt;br /&gt;
        if (rc != SA_AIS_OK)&lt;br /&gt;
        {&lt;br /&gt;
            clprintf(CL_LOG_SEV_ERROR,&amp;quot;Failed [0x%x] to write to section&amp;quot;, rc);&lt;br /&gt;
            if(rc == SA_AIS_ERR_NOT_EXIST)&lt;br /&gt;
                rc = checkpoint_replica_activate();&lt;br /&gt;
            if(rc == CL_OK) goto retry;&lt;br /&gt;
        }&lt;br /&gt;
        else&lt;br /&gt;
        {&lt;br /&gt;
            /*&lt;br /&gt;
            * Synchronize the checkpoint to all the replicas.&lt;br /&gt;
            */&lt;br /&gt;
            rc = saCkptCheckpointSynchronize(ckpt_handle, SA_TIME_END );&lt;br /&gt;
            if (rc != SA_AIS_OK)&lt;br /&gt;
            {&lt;br /&gt;
                clprintf(CL_LOG_SEV_ERROR,&amp;quot;Failed [0x%x] to synchronize the checkpoint&amp;quot;, rc);&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        return CL_OK;&lt;br /&gt;
     }&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
With &amp;lt;code&amp;gt;checkpoint_write_seq&amp;lt;/code&amp;gt; we first convert the sequence number passed into network byte order.  Then we pass it to &amp;lt;code&amp;gt;clCKptSectionOverwrite&amp;lt;/code&amp;gt; which writes it to the checkpoint section created in &amp;lt;code&amp;gt;checkpoint_initialize&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffccaa;&amp;quot; align=&amp;quot;center&amp;quot;| clCompAppMain.c&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
    static ClRcT&lt;br /&gt;
    checkpoint_read_seq(ClUint32T *seq)&lt;br /&gt;
    {&lt;br /&gt;
        ClRcT rc = CL_OK;&lt;br /&gt;
        ClUint32T err_idx; /* Error index in ioVector */&lt;br /&gt;
        ClUint32T seq_no = 0xffffffff;&lt;br /&gt;
        SaCkptIOVectorElementT iov = {&lt;br /&gt;
            .sectionId  = ckpt_sid,&lt;br /&gt;
            .dataBuffer = (ClPtrT)&amp;amp;seq_no,&lt;br /&gt;
            .dataSize   = sizeof(ClUint32T),&lt;br /&gt;
            .dataOffset = (ClOffsetT)0,&lt;br /&gt;
            .readSize   = sizeof(ClUint32T)&lt;br /&gt;
        };&lt;br /&gt;
&lt;br /&gt;
        rc = saCkptCheckpointRead(ckpt_handle, &amp;amp;iov, 1, &amp;amp;err_idx);&lt;br /&gt;
        if (rc != SA_AIS_OK)&lt;br /&gt;
        {&lt;br /&gt;
           clprintf(CL_LOG_SEV_ERROR,&amp;quot;Error: [0x%x] from checkpoint read, err_idx = %u&amp;quot;,&lt;br /&gt;
                    rc, err_idx);&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        /* FIXME: How to process this err_idx? */&lt;br /&gt;
        *seq = ntohl(seq_no);&lt;br /&gt;
&lt;br /&gt;
        return CL_OK;&lt;br /&gt;
&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
With &amp;lt;code&amp;gt;checkpoint_read_seq&amp;lt;/code&amp;gt; we initialize &amp;lt;code&amp;gt;seq_no&amp;lt;/code&amp;gt; to all ones just so it will be more obvious if the &amp;lt;code&amp;gt;clCkptCheckpointRead&amp;lt;/code&amp;gt; call fails and the value of &amp;lt;code&amp;gt;seq_no&amp;lt;/code&amp;gt; doesn't get overwritten.  Then, we set up the &amp;lt;code&amp;gt;iov&amp;lt;/code&amp;gt; variable.  We set the &amp;lt;code&amp;gt;sectionID&amp;lt;/code&amp;gt;  field to &amp;lt;code&amp;gt;ckpt_sid&amp;lt;/code&amp;gt; which is the id of the section created in &amp;lt;code&amp;gt;checkpoint_initialize&amp;lt;/code&amp;gt;.  The &amp;lt;code&amp;gt;dataBuffer&amp;lt;/code&amp;gt; gets set to the address of the &amp;lt;code&amp;gt;seq_no&amp;lt;/code&amp;gt; variable which is where we want the checkpoint data loaded.  The &amp;lt;code&amp;gt;dataSize&amp;lt;/code&amp;gt; field is set to the the size of the &amp;lt;code&amp;gt;seq_no&amp;lt;/code&amp;gt; variable.  &amp;lt;code&amp;gt;DataOfset&amp;lt;/code&amp;gt; is set to zero since the sequence number is the only thing stored in the section, so it resides at the front of the section.  &amp;lt;code&amp;gt;readSize&amp;lt;/code&amp;gt; is set to the size of the sequence number variable.&lt;br /&gt;
&lt;br /&gt;
Within &amp;lt;code&amp;gt;checkpoint_read_seq&amp;lt;/code&amp;gt; we pass the iovector to &amp;lt;code&amp;gt;clCkptCheckpointRead&amp;lt;/code&amp;gt; along with the &amp;lt;code&amp;gt;ckpt_handle&amp;lt;/code&amp;gt;, the constant 1, and the address of the &amp;lt;code&amp;gt;err_idx&amp;lt;/code&amp;gt; variable.  The constant 1 is the number of elements in the array of &amp;lt;code&amp;gt;ClCkptIOVectorElementT structs&amp;lt;/code&amp;gt; that we're passing.  That is, we're passing the address of a single &amp;lt;code&amp;gt;ClCkptIOVectorElementT struct&amp;lt;/code&amp;gt;.  The &amp;lt;code&amp;gt;err_idx&amp;lt;/code&amp;gt; will hold the index in that array where &amp;lt;code&amp;gt;clCkptCheckpointRead&amp;lt;/code&amp;gt; found an error.  That is, if there is going to be an error, it will be at index 0 since we're only passing on entry in the &amp;lt;code&amp;gt;iovector&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffccaa;&amp;quot; align=&amp;quot;center&amp;quot;| clCompAppMain.c&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    static ClRcT&lt;br /&gt;
    checkpoint_replica_activate(void)&lt;br /&gt;
    {&lt;br /&gt;
        SaAisErrorT rc = SA_AIS_OK;&lt;br /&gt;
&lt;br /&gt;
        if ((rc = saCkptActiveReplicaSet(ckpt_handle)) != SA_AIS_OK)&lt;br /&gt;
        {&lt;br /&gt;
            clprintf(CL_LOG_SEV_ERROR,&lt;br /&gt;
                    &amp;quot;checkpoint_replica_activate failed [0x%x] in ActiveReplicaSet&amp;quot;,&lt;br /&gt;
                    rc);&lt;br /&gt;
        }&lt;br /&gt;
        else rc = CL_OK;&lt;br /&gt;
&lt;br /&gt;
        return rc;&lt;br /&gt;
    }&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
===csa203===&lt;br /&gt;
&lt;br /&gt;
csa203 demonstrates the usage of SA Forum's Checkpointing service. This sample application does not deviate functionally from csa103. The code differences are due to using SA Forum data types (structures) and APIs , as presented in the following two tables. (Note we have not repeated data types and APIs covered previously.)&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|+align=&amp;quot;bottom&amp;quot;| '''SA Forum Data Types with the SAFplus Platform equivalent'''&lt;br /&gt;
|- style=&amp;quot;color:black;background-color:#ffffaa;&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
!SA Forum Data Types   &lt;br /&gt;
!OpenClovis Data Types&lt;br /&gt;
|-&lt;br /&gt;
|SaCkptHandleT&lt;br /&gt;
|ClCkptSvcHdlT&lt;br /&gt;
|-&lt;br /&gt;
|SaCkptHandleT&lt;br /&gt;
|ClCkptHdlT&lt;br /&gt;
|-&lt;br /&gt;
|SaCkptSectionIdT&lt;br /&gt;
|ClCkptSectionIdT&lt;br /&gt;
|-&lt;br /&gt;
|SaCkptCheckpointCreationAttributesT&lt;br /&gt;
|ClCkptCheckpointCreationAttributesT&lt;br /&gt;
|-&lt;br /&gt;
|SaCkptSectionCreationAttributesT&lt;br /&gt;
|ClCkptSectionCreationAttributesT&lt;br /&gt;
|-&lt;br /&gt;
|SaCkptIOVectorElementT&lt;br /&gt;
|ClCkptIOVectorElementT&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|+align=&amp;quot;bottom&amp;quot;| '''SA Forum APIs with the SAFplus Platform equivalent'''&lt;br /&gt;
|- style=&amp;quot;color:black;background-color:#ffffaa;&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
!SA Forum APIs&lt;br /&gt;
!OpenClovis APIs&lt;br /&gt;
|-&lt;br /&gt;
|saCkptInitialize&lt;br /&gt;
|clCkptInitialize&lt;br /&gt;
|-&lt;br /&gt;
|saCkptCheckpointOpen&lt;br /&gt;
|clCkptCheckpointOpen&lt;br /&gt;
|-&lt;br /&gt;
|saCkptSectionCreate&lt;br /&gt;
|clCkptSectionCreate&lt;br /&gt;
|-&lt;br /&gt;
|saCkptCheckpointClose&lt;br /&gt;
|clCkptCheckpointClose&lt;br /&gt;
|-&lt;br /&gt;
|saCkptFinalize&lt;br /&gt;
|clCkptFinalize&lt;br /&gt;
|-&lt;br /&gt;
|saCkptSectionOverwrite&lt;br /&gt;
|clCkptSectionOverwrite&lt;br /&gt;
|-&lt;br /&gt;
|saCkptCheckpointSynchronize&lt;br /&gt;
|clCkptCheckpointSynchronize&lt;br /&gt;
|-&lt;br /&gt;
|saCkptCheckpointRead&lt;br /&gt;
|clCkptCheckpointRead&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===How to Run csa103 and What to Observe===&lt;br /&gt;
&lt;br /&gt;
This sample application can run on all Runtime Hardware Setups. The following, lists which node &amp;lt;code&amp;gt;csa103compI*&amp;lt;/code&amp;gt; runs on.&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;'''Runtime Hardware Setup 1.1 and 2.1'''&lt;br /&gt;
&amp;lt;br&amp;gt;csa103compI0 and csa103compI1 will run upon the single node.&lt;br /&gt;
&amp;lt;li&amp;gt;'''Runtime Hardware Setup 1.2 and 2.2'''&lt;br /&gt;
&amp;lt;br&amp;gt;csa103compI0 runs on PayloadNodeI0 and csa103compI1 runs on PayloadNodeI1&lt;br /&gt;
&amp;lt;li&amp;gt;'''Runtime Hardware Setup 1.3 and 2.3'''&lt;br /&gt;
&amp;lt;br&amp;gt;csa103compI2 and csa103compI3 run on SCNodeI0 and SCNodeI1 respectively. csa103compI0 and csa103compI1 run on PayloadNodeI0 and PayloadNodeI1 respectively.&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;In the four node set up SCNodeI0 and SCNodeI1 output data via &amp;lt;code&amp;gt;/root/asp/var/log/csa103CompI2&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;/root/asp/var/log/csa103CompI3&amp;lt;/code&amp;gt; respectively. Therefore in this case follow the below instructions replacing csa103CompI0 and csa103compI1 with csa103compI2 and csa103compI3 respectively.&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We run csa103 very much the same way we run any of the rest of the sample applications: with the SAFplus Platform Console.&lt;br /&gt;
  &lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;First, on the active System Controller move it to state LockAssignment with (Unlock csa203SGI0 instead of csa103SGI0 to run csa203)&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
cli[Test]-&amp;gt; setc 1&lt;br /&gt;
cli[Test:SCNodeI0]-&amp;gt; setc cpm&lt;br /&gt;
cli[Test:SCNodeI0:CPM]-&amp;gt; amsLockAssignment sg csa103SGI0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The following output is given when you run &amp;lt;code&amp;gt;tail -f&amp;lt;/code&amp;gt; on the csa103 log files. For example:&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
# tail -f /root/asp/var/log/csa103CompI0.log&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffffaa;&amp;quot; align=&amp;quot;center&amp;quot;| /root/asp/var/log/csa103CompI0Log.latest&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
Mon Jul 14 00:01:09 2008   (SCNodeI0.15238 : csa103CompEO.---.---.00030 :   INFO)&lt;br /&gt;
 Component [csa103CompI0] : PID [15238]. Initializing&lt;br /&gt;
Mon Jul 14 00:01:09 2008   (SCNodeI0.15238 : csa103CompEO.---.---.00031 :   INFO)&lt;br /&gt;
    IOC Address             : 0x1&lt;br /&gt;
Mon Jul 14 00:01:09 2008   (SCNodeI0.15238 : csa103CompEO.---.---.00032 :   INFO)&lt;br /&gt;
    IOC Port                : 0x81&lt;br /&gt;
Mon Jul 14 00:01:09 2008   (SCNodeI0.15238 : csa103CompEO.---.---.00033 :   INFO)&lt;br /&gt;
 csa103: Instantiated as component instance csa103CompI0.&lt;br /&gt;
Mon Jul 14 00:01:09 2008   (SCNodeI0.15238 : csa103CompEO.---.---.00034 :   INFO)&lt;br /&gt;
 csa103CompI0: Waiting for CSI assignment...&lt;br /&gt;
Mon Jul 14 00:01:09 2008   (SCNodeI0.15238 : csa103CompEO.---.---.00035 :   INFO)&lt;br /&gt;
 csa103CompI0: Waiting for CSI assignment...&lt;br /&gt;
Mon Jul 14 00:01:09 2008   (SCNodeI0.15238 : csa103CompEO.---.---.00036 :   INFO)&lt;br /&gt;
 csa103CompI0: checkpoint_initialize&lt;br /&gt;
Mon Jul 14 00:01:10 2008   (SCNodeI0.15238 : csa103CompEO.---.---.00043 :   INFO)&lt;br /&gt;
 csa103CompI0: Checkpoint service initialized (handle=0x1)&lt;br /&gt;
Mon Jul 14 00:01:10 2008   (SCNodeI0.15238 : csa103CompEO.---.---.00045 :   INFO)&lt;br /&gt;
 csa103CompI0: Checkpoint opened (handle=0x2)&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
# tail -f /root/asp/var/log/csa103CompI1.log&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffffaa;&amp;quot; align=&amp;quot;center&amp;quot;| /root/asp/var/log/csa103CompI1Log.latest&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
Mon Jul 14 00:01:09 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00030 :   INFO)&lt;br /&gt;
 Component [csa103CompI1] : PID [15234]. Initializing&lt;br /&gt;
Mon Jul 14 00:01:09 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00031 :   INFO)&lt;br /&gt;
    IOC Address             : 0x1&lt;br /&gt;
Mon Jul 14 00:01:09 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00032 :   INFO)&lt;br /&gt;
    IOC Port                : 0x80&lt;br /&gt;
Mon Jul 14 00:01:09 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00033 :   INFO)&lt;br /&gt;
 csa103: Instantiated as component instance csa103CompI1.&lt;br /&gt;
Mon Jul 14 00:01:09 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00034 :   INFO)&lt;br /&gt;
 csa103CompI1: Waiting for CSI assignment...&lt;br /&gt;
Mon Jul 14 00:01:09 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00035 :   INFO)&lt;br /&gt;
 csa103CompI1: Waiting for CSI assignment...&lt;br /&gt;
Mon Jul 14 00:01:09 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00036 :   INFO)&lt;br /&gt;
 csa103CompI1: checkpoint_initialize&lt;br /&gt;
Mon Jul 14 00:01:09 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00043 :   INFO)&lt;br /&gt;
 csa103CompI1: Checkpoint service initialized (handle=0x1)&lt;br /&gt;
Mon Jul 14 00:01:09 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00045 :   INFO)&lt;br /&gt;
 csa103CompI1: Checkpoint opened (handle=0x2)&lt;br /&gt;
Mon Jul 14 00:01:09 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00053 :   INFO)&lt;br /&gt;
 csa103CompI1: Section created&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;Then, unlock the application by running &lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
cli[Test:SCNodeI0:CPM]-&amp;gt; amsUnlock sg csa103SGI0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the application log files, you should see &lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffffaa;&amp;quot; align=&amp;quot;center&amp;quot;| /root/asp/var/log/csa103CompI0Log.latest&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
Mon Jul 14 00:09:08 2008   (SCNodeI0.15238 : csa103CompEO.---.---.00058 :   INFO)&lt;br /&gt;
  Standby state requested from state 0&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffffaa;&amp;quot; align=&amp;quot;center&amp;quot;| /root/asp/var/log/csa103CompI1Log.latest&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
Mon Jul 14 00:09:08 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00064 :   INFO)&lt;br /&gt;
 csa103CompI1: Active state requested from state 0&lt;br /&gt;
Mon Jul 14 00:09:09 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00065 :   INFO)&lt;br /&gt;
 csa103CompI1: Hello World! (seq=0)&lt;br /&gt;
Mon Jul 14 00:09:10 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00066 :   INFO)&lt;br /&gt;
 csa103CompI1: Hello World! (seq=1)&lt;br /&gt;
Mon Jul 14 00:09:11 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00067 :   INFO)&lt;br /&gt;
 csa103CompI1: Hello World! (seq=2)&lt;br /&gt;
Mon Jul 14 00:09:12 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00068 :   INFO)&lt;br /&gt;
 csa103CompI1: Hello World! (seq=3)&lt;br /&gt;
Mon Jul 14 00:09:13 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00069 :   INFO)&lt;br /&gt;
 csa103CompI1: Hello World! (seq=4)&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;Next, find the active csa103 process, the one that's printing the Hello World lines and kill it.  To find the process ID issue the following command from a bash shell.&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
 # ps -eaf | grep csa103&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
This should produce an output that looks similar to the following.&lt;br /&gt;
 root     17830 15663  0 14:21 ?        00:00:00 csa103Comp -p&lt;br /&gt;
 root     17839 15663  0 14:21 ?        00:00:00 csa103Comp -p&lt;br /&gt;
 root     18558 16145  0 14:32 pts/4    00:00:00 grep csa103&lt;br /&gt;
Notice the two entries that end with csa103Comp -p. These are our two component processes. The first one is usually the active process. This is the one that we will kill. In this case the process ID is 17830. So to kill the active component you issue the command:&lt;br /&gt;
&lt;br /&gt;
 # kill -9 17830&lt;br /&gt;
&lt;br /&gt;
[[File:OpenClovis_Note.png]]If this step does not result in the active component being killed then it is likely that the standby component was killed. In this case simply try killing the other process. &lt;br /&gt;
&lt;br /&gt;
After killing the active component you should see lines in the log files like the following:&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffffaa;&amp;quot; align=&amp;quot;center&amp;quot;| /root/asp/var/log/csa103CompI1Log.latest&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
Mon Jul 14 00:16:43 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00515 :   INFO)&lt;br /&gt;
 csa103CompI1: Hello World! (seq=452)&lt;br /&gt;
Mon Jul 14 00:16:44 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00516 :   INFO)&lt;br /&gt;
 csa103CompI1: Hello World! (seq=453)&lt;br /&gt;
Mon Jul 14 00:16:45 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00517 :   INFO)&lt;br /&gt;
 csa103CompI1: Hello World! (seq=454)&lt;br /&gt;
Mon Jul 14 00:16:46 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00518 :   INFO)&lt;br /&gt;
 csa103CompI1: Hello World! (seq=455)&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffffaa;&amp;quot; align=&amp;quot;center&amp;quot;| /var/log/csa103CompI0Log.latest&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
Mon Jul 14 00:16:48 2008   (SCNodeI0.15238 : csa103CompEO.---.---.00065 :   INFO)&lt;br /&gt;
 csa103CompI0: Active state requested from state 2&lt;br /&gt;
Mon Jul 14 00:16:48 2008   (SCNodeI0.15238 : csa103CompEO.---.---.00066 :   INFO)&lt;br /&gt;
 csa103CompI0 reading checkpoint&lt;br /&gt;
Mon Jul 14 00:16:48 2008   (SCNodeI0.15238 : csa103CompEO.---.---.00067 :   INFO)&lt;br /&gt;
 csa103CompI0 read checkpoint: seq = 456&lt;br /&gt;
Mon Jul 14 00:16:49 2008   (SCNodeI0.15238 : csa103CompEO.---.---.00068 :   INFO)&lt;br /&gt;
 csa103CompI0: Hello World! (seq=456)&lt;br /&gt;
Mon Jul 14 00:16:50 2008   (SCNodeI0.15238 : csa103CompEO.---.---.00069 :   INFO)&lt;br /&gt;
 csa103CompI0: Hello World! (seq=457)&lt;br /&gt;
Mon Jul 14 00:16:51 2008   (SCNodeI0.15238 : csa103CompEO.---.---.00070 :   INFO)&lt;br /&gt;
 csa103CompI0: Hello World! (seq=458)&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
Where we can see CompI1 printing 455 and then dieing, where upon CompI0 gets the notice to take over processing, reads the checkpoint and then takes over with seq=456 and so on.&lt;br /&gt;
&lt;br /&gt;
Then, in the CompI1 log file we see:&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffffaa;&amp;quot; align=&amp;quot;center&amp;quot;| /root/asp/var/log/csa103CompI1Log.latest&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
Mon Jul 14 00:16:49 2008   (SCNodeI0.15553 : csa103CompEO.---.---.00044 :   INFO)&lt;br /&gt;
 csa103: Instantiated as component instance csa103CompI1.&lt;br /&gt;
Mon Jul 14 00:16:49 2008   (SCNodeI0.15553 : csa103CompEO.---.---.00045 :   INFO)&lt;br /&gt;
 csa103CompI1: Waiting for CSI assignment...&lt;br /&gt;
Mon Jul 14 00:16:49 2008   (SCNodeI0.15553 : csa103CompEO.---.---.00046 :   INFO)&lt;br /&gt;
 csa103CompI1: Waiting for CSI assignment...&lt;br /&gt;
Mon Jul 14 00:16:49 2008   (SCNodeI0.15553 : csa103CompEO.---.---.00047 :   INFO)&lt;br /&gt;
 csa103CompI1: checkpoint_initialize&lt;br /&gt;
Mon Jul 14 00:16:50 2008   (SCNodeI0.15553 : csa103CompEO.---.---.00054 :   INFO)&lt;br /&gt;
 csa103CompI1: Checkpoint service initialized (handle=0x1)&lt;br /&gt;
Mon Jul 14 00:16:50 2008   (SCNodeI0.15553 : csa103CompEO.---.---.00056 :   INFO)&lt;br /&gt;
 csa103CompI1: Checkpoint opened (handle=0x2)&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
That is the component that had been killed being restarted.  &lt;br /&gt;
&lt;br /&gt;
CompI0 is moving along just fine, and we see CompI1 come back up.  If we then kill CompI0 we see:&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffffaa;&amp;quot; align=&amp;quot;center&amp;quot;| /root/asp/var/log/csa103CompI1Log.latest&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
Mon Jul 14 00:29:44 2008   (SCNodeI0.15553 : csa103CompEO.---.---.00065 :   INFO)&lt;br /&gt;
 csa103CompI1: Active state requested from state 2&lt;br /&gt;
Mon Jul 14 00:29:44 2008   (SCNodeI0.15553 : csa103CompEO.---.---.00066 :   INFO)&lt;br /&gt;
 csa103CompI1 reading checkpoint&lt;br /&gt;
Mon Jul 14 00:29:44 2008   (SCNodeI0.15553 : csa103CompEO.---.---.00067 :   INFO)&lt;br /&gt;
 csa103CompI1 read checkpoint: seq = 1225&lt;br /&gt;
Mon Jul 14 00:29:45 2008   (SCNodeI0.15553 : csa103CompEO.---.---.00068 :   INFO)&lt;br /&gt;
 csa103CompI1: Hello World! (seq=1225)&lt;br /&gt;
Mon Jul 14 00:29:46 2008   (SCNodeI0.15553 : csa103CompEO.---.---.00069 :   INFO)&lt;br /&gt;
 csa103CompI1: Hello World! (seq=1226)&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
Where we can see the CompI0 process die, and CompI1 process read the sequence number from the checkpoint and then take over from where CompI0 left off.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;To stop csa103 use the following SAFplus Platform Console command.&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
cli[Test:SCNodeI0:CPM]-&amp;gt; amsLockAssignment sg csa103SGI0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;Now change the state of csa103SGI0 to LockInstantiation and close the SAFplus Platform Console.&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
cli[Test:SCNodeI0:CPM]-&amp;gt; amsLockInstantiation sg csa103SGI0&lt;br /&gt;
cli[Test:SCNodeI0:CPM] -&amp;gt; end&lt;br /&gt;
cli[Test:SCNodeI0] -&amp;gt; end&lt;br /&gt;
cli[Test] -&amp;gt; bye&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===csa203===&lt;br /&gt;
&lt;br /&gt;
csa203 demonstrates the usage of SA Forum's Checkpointing service. This sample application does not deviate functionally from csa103. The code differences are due to using SA Forum data types (structures) and APIs , as presented in the following two tables. (Note we have not repeated data types and APIs covered previously.)&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|+align=&amp;quot;bottom&amp;quot;| '''SA Forum Data Types with the SAFplus Platform equivalent'''&lt;br /&gt;
|- style=&amp;quot;color:black;background-color:#ffffaa;&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
!SA Forum Data Types   &lt;br /&gt;
!OpenClovis Data Types&lt;br /&gt;
|-&lt;br /&gt;
|SaCkptHandleT&lt;br /&gt;
|ClCkptSvcHdlT&lt;br /&gt;
|-&lt;br /&gt;
|SaCkptHandleT&lt;br /&gt;
|ClCkptHdlT&lt;br /&gt;
|-&lt;br /&gt;
|SaCkptSectionIdT&lt;br /&gt;
|ClCkptSectionIdT&lt;br /&gt;
|-&lt;br /&gt;
|SaCkptCheckpointCreationAttributesT&lt;br /&gt;
|ClCkptCheckpointCreationAttributesT&lt;br /&gt;
|-&lt;br /&gt;
|SaCkptSectionCreationAttributesT&lt;br /&gt;
|ClCkptSectionCreationAttributesT&lt;br /&gt;
|-&lt;br /&gt;
|SaCkptIOVectorElementT&lt;br /&gt;
|ClCkptIOVectorElementT&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|+align=&amp;quot;bottom&amp;quot;| '''SA Forum APIs with the SAFplus Platform equivalent'''&lt;br /&gt;
|- style=&amp;quot;color:black;background-color:#ffffaa;&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
!SA Forum APIs&lt;br /&gt;
!OpenClovis APIs&lt;br /&gt;
|-&lt;br /&gt;
|saCkptInitialize&lt;br /&gt;
|clCkptInitialize&lt;br /&gt;
|-&lt;br /&gt;
|saCkptCheckpointOpen&lt;br /&gt;
|clCkptCheckpointOpen&lt;br /&gt;
|-&lt;br /&gt;
|saCkptSectionCreate&lt;br /&gt;
|clCkptSectionCreate&lt;br /&gt;
|-&lt;br /&gt;
|saCkptCheckpointClose&lt;br /&gt;
|clCkptCheckpointClose&lt;br /&gt;
|-&lt;br /&gt;
|saCkptFinalize&lt;br /&gt;
|clCkptFinalize&lt;br /&gt;
|-&lt;br /&gt;
|saCkptSectionOverwrite&lt;br /&gt;
|clCkptSectionOverwrite&lt;br /&gt;
|-&lt;br /&gt;
|saCkptCheckpointSynchronize&lt;br /&gt;
|clCkptCheckpointSynchronize&lt;br /&gt;
|-&lt;br /&gt;
|saCkptCheckpointRead&lt;br /&gt;
|clCkptCheckpointRead&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===How to Run csa103 and What to Observe===&lt;br /&gt;
&lt;br /&gt;
This sample application can run on all Runtime Hardware Setups. The following, lists which node &amp;lt;code&amp;gt;csa103compI*&amp;lt;/code&amp;gt; runs on.&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;'''Runtime Hardware Setup 1.1 and 2.1'''&lt;br /&gt;
&amp;lt;br&amp;gt;csa103compI0 and csa103compI1 will run upon the single node.&lt;br /&gt;
&amp;lt;li&amp;gt;'''Runtime Hardware Setup 1.2 and 2.2'''&lt;br /&gt;
&amp;lt;br&amp;gt;csa103compI0 runs on PayloadNodeI0 and csa103compI1 runs on PayloadNodeI1&lt;br /&gt;
&amp;lt;li&amp;gt;'''Runtime Hardware Setup 1.3 and 2.3'''&lt;br /&gt;
&amp;lt;br&amp;gt;csa103compI2 and csa103compI3 run on SCNodeI0 and SCNodeI1 respectively. csa103compI0 and csa103compI1 run on PayloadNodeI0 and PayloadNodeI1 respectively.&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;In the four node set up SCNodeI0 and SCNodeI1 output data via &amp;lt;code&amp;gt;/root/asp/var/log/csa103CompI2&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;/root/asp/var/log/csa103CompI3&amp;lt;/code&amp;gt; respectively. Therefore in this case follow the below instructions replacing csa103CompI0 and csa103compI1 with csa103compI2 and csa103compI3 respectively.&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We run csa103 very much the same way we run any of the rest of the sample applications: with the SAFplus Platform Console.&lt;br /&gt;
  &lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;First, on the active System Controller move it to state LockAssignment with (Unlock csa203SGI0 instead of csa103SGI0 to run csa203)&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
cli[Test]-&amp;gt; setc 1&lt;br /&gt;
cli[Test:SCNodeI0]-&amp;gt; setc cpm&lt;br /&gt;
cli[Test:SCNodeI0:CPM]-&amp;gt; amsLockAssignment sg csa103SGI0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The following output is given when you run &amp;lt;code&amp;gt;tail -f&amp;lt;/code&amp;gt; on the csa103 log files. For example:&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
# tail -f /root/asp/var/log/csa103CompI0.log&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffffaa;&amp;quot; align=&amp;quot;center&amp;quot;| /root/asp/var/log/csa103CompI0Log.latest&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
Mon Jul 14 00:01:09 2008   (SCNodeI0.15238 : csa103CompEO.---.---.00030 :   INFO)&lt;br /&gt;
 Component [csa103CompI0] : PID [15238]. Initializing&lt;br /&gt;
Mon Jul 14 00:01:09 2008   (SCNodeI0.15238 : csa103CompEO.---.---.00031 :   INFO)&lt;br /&gt;
    IOC Address             : 0x1&lt;br /&gt;
Mon Jul 14 00:01:09 2008   (SCNodeI0.15238 : csa103CompEO.---.---.00032 :   INFO)&lt;br /&gt;
    IOC Port                : 0x81&lt;br /&gt;
Mon Jul 14 00:01:09 2008   (SCNodeI0.15238 : csa103CompEO.---.---.00033 :   INFO)&lt;br /&gt;
 csa103: Instantiated as component instance csa103CompI0.&lt;br /&gt;
Mon Jul 14 00:01:09 2008   (SCNodeI0.15238 : csa103CompEO.---.---.00034 :   INFO)&lt;br /&gt;
 csa103CompI0: Waiting for CSI assignment...&lt;br /&gt;
Mon Jul 14 00:01:09 2008   (SCNodeI0.15238 : csa103CompEO.---.---.00035 :   INFO)&lt;br /&gt;
 csa103CompI0: Waiting for CSI assignment...&lt;br /&gt;
Mon Jul 14 00:01:09 2008   (SCNodeI0.15238 : csa103CompEO.---.---.00036 :   INFO)&lt;br /&gt;
 csa103CompI0: checkpoint_initialize&lt;br /&gt;
Mon Jul 14 00:01:10 2008   (SCNodeI0.15238 : csa103CompEO.---.---.00043 :   INFO)&lt;br /&gt;
 csa103CompI0: Checkpoint service initialized (handle=0x1)&lt;br /&gt;
Mon Jul 14 00:01:10 2008   (SCNodeI0.15238 : csa103CompEO.---.---.00045 :   INFO)&lt;br /&gt;
 csa103CompI0: Checkpoint opened (handle=0x2)&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
# tail -f /root/asp/var/log/csa103CompI1.log&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffffaa;&amp;quot; align=&amp;quot;center&amp;quot;| /root/asp/var/log/csa103CompI1Log.latest&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
Mon Jul 14 00:01:09 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00030 :   INFO)&lt;br /&gt;
 Component [csa103CompI1] : PID [15234]. Initializing&lt;br /&gt;
Mon Jul 14 00:01:09 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00031 :   INFO)&lt;br /&gt;
    IOC Address             : 0x1&lt;br /&gt;
Mon Jul 14 00:01:09 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00032 :   INFO)&lt;br /&gt;
    IOC Port                : 0x80&lt;br /&gt;
Mon Jul 14 00:01:09 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00033 :   INFO)&lt;br /&gt;
 csa103: Instantiated as component instance csa103CompI1.&lt;br /&gt;
Mon Jul 14 00:01:09 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00034 :   INFO)&lt;br /&gt;
 csa103CompI1: Waiting for CSI assignment...&lt;br /&gt;
Mon Jul 14 00:01:09 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00035 :   INFO)&lt;br /&gt;
 csa103CompI1: Waiting for CSI assignment...&lt;br /&gt;
Mon Jul 14 00:01:09 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00036 :   INFO)&lt;br /&gt;
 csa103CompI1: checkpoint_initialize&lt;br /&gt;
Mon Jul 14 00:01:09 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00043 :   INFO)&lt;br /&gt;
 csa103CompI1: Checkpoint service initialized (handle=0x1)&lt;br /&gt;
Mon Jul 14 00:01:09 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00045 :   INFO)&lt;br /&gt;
 csa103CompI1: Checkpoint opened (handle=0x2)&lt;br /&gt;
Mon Jul 14 00:01:09 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00053 :   INFO)&lt;br /&gt;
 csa103CompI1: Section created&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;Then, unlock the application by running &lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
cli[Test:SCNodeI0:CPM]-&amp;gt; amsUnlock sg csa103SGI0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the application log files, you should see &lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffffaa;&amp;quot; align=&amp;quot;center&amp;quot;| /root/asp/var/log/csa103CompI0Log.latest&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
Mon Jul 14 00:09:08 2008   (SCNodeI0.15238 : csa103CompEO.---.---.00058 :   INFO)&lt;br /&gt;
  Standby state requested from state 0&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffffaa;&amp;quot; align=&amp;quot;center&amp;quot;| /root/asp/var/log/csa103CompI1Log.latest&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
Mon Jul 14 00:09:08 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00064 :   INFO)&lt;br /&gt;
 csa103CompI1: Active state requested from state 0&lt;br /&gt;
Mon Jul 14 00:09:09 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00065 :   INFO)&lt;br /&gt;
 csa103CompI1: Hello World! (seq=0)&lt;br /&gt;
Mon Jul 14 00:09:10 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00066 :   INFO)&lt;br /&gt;
 csa103CompI1: Hello World! (seq=1)&lt;br /&gt;
Mon Jul 14 00:09:11 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00067 :   INFO)&lt;br /&gt;
 csa103CompI1: Hello World! (seq=2)&lt;br /&gt;
Mon Jul 14 00:09:12 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00068 :   INFO)&lt;br /&gt;
 csa103CompI1: Hello World! (seq=3)&lt;br /&gt;
Mon Jul 14 00:09:13 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00069 :   INFO)&lt;br /&gt;
 csa103CompI1: Hello World! (seq=4)&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;Next, find the active csa103 process, the one that's printing the Hello World lines and kill it.  To find the process ID issue the following command from a bash shell.&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
 # ps -eaf | grep csa103&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
This should produce an output that looks similar to the following.&lt;br /&gt;
 root     17830 15663  0 14:21 ?        00:00:00 csa103Comp -p&lt;br /&gt;
 root     17839 15663  0 14:21 ?        00:00:00 csa103Comp -p&lt;br /&gt;
 root     18558 16145  0 14:32 pts/4    00:00:00 grep csa103&lt;br /&gt;
Notice the two entries that end with csa103Comp -p. These are our two component processes. The first one is usually the active process. This is the one that we will kill. In this case the process ID is 17830. So to kill the active component you issue the command:&lt;br /&gt;
&lt;br /&gt;
 # kill -9 17830&lt;br /&gt;
&lt;br /&gt;
[[File:OpenClovis_Note.png]]If this step does not result in the active component being killed then it is likely that the standby component was killed. In this case simply try killing the other process. &lt;br /&gt;
&lt;br /&gt;
After killing the active component you should see lines in the log files like the following:&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffffaa;&amp;quot; align=&amp;quot;center&amp;quot;| /root/asp/var/log/csa103CompI1Log.latest&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
Mon Jul 14 00:16:43 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00515 :   INFO)&lt;br /&gt;
 csa103CompI1: Hello World! (seq=452)&lt;br /&gt;
Mon Jul 14 00:16:44 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00516 :   INFO)&lt;br /&gt;
 csa103CompI1: Hello World! (seq=453)&lt;br /&gt;
Mon Jul 14 00:16:45 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00517 :   INFO)&lt;br /&gt;
 csa103CompI1: Hello World! (seq=454)&lt;br /&gt;
Mon Jul 14 00:16:46 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00518 :   INFO)&lt;br /&gt;
 csa103CompI1: Hello World! (seq=455)&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffffaa;&amp;quot; align=&amp;quot;center&amp;quot;| /var/log/csa103CompI0Log.latest&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
Mon Jul 14 00:16:48 2008   (SCNodeI0.15238 : csa103CompEO.---.---.00065 :   INFO)&lt;br /&gt;
 csa103CompI0: Active state requested from state 2&lt;br /&gt;
Mon Jul 14 00:16:48 2008   (SCNodeI0.15238 : csa103CompEO.---.---.00066 :   INFO)&lt;br /&gt;
 csa103CompI0 reading checkpoint&lt;br /&gt;
Mon Jul 14 00:16:48 2008   (SCNodeI0.15238 : csa103CompEO.---.---.00067 :   INFO)&lt;br /&gt;
 csa103CompI0 read checkpoint: seq = 456&lt;br /&gt;
Mon Jul 14 00:16:49 2008   (SCNodeI0.15238 : csa103CompEO.---.---.00068 :   INFO)&lt;br /&gt;
 csa103CompI0: Hello World! (seq=456)&lt;br /&gt;
Mon Jul 14 00:16:50 2008   (SCNodeI0.15238 : csa103CompEO.---.---.00069 :   INFO)&lt;br /&gt;
 csa103CompI0: Hello World! (seq=457)&lt;br /&gt;
Mon Jul 14 00:16:51 2008   (SCNodeI0.15238 : csa103CompEO.---.---.00070 :   INFO)&lt;br /&gt;
 csa103CompI0: Hello World! (seq=458)&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
Where we can see CompI1 printing 455 and then dieing, where upon CompI0 gets the notice to take over processing, reads the checkpoint and then takes over with seq=456 and so on.&lt;br /&gt;
&lt;br /&gt;
Then, in the CompI1 log file we see:&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffffaa;&amp;quot; align=&amp;quot;center&amp;quot;| /root/asp/var/log/csa103CompI1Log.latest&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
Mon Jul 14 00:16:49 2008   (SCNodeI0.15553 : csa103CompEO.---.---.00044 :   INFO)&lt;br /&gt;
 csa103: Instantiated as component instance csa103CompI1.&lt;br /&gt;
Mon Jul 14 00:16:49 2008   (SCNodeI0.15553 : csa103CompEO.---.---.00045 :   INFO)&lt;br /&gt;
 csa103CompI1: Waiting for CSI assignment...&lt;br /&gt;
Mon Jul 14 00:16:49 2008   (SCNodeI0.15553 : csa103CompEO.---.---.00046 :   INFO)&lt;br /&gt;
 csa103CompI1: Waiting for CSI assignment...&lt;br /&gt;
Mon Jul 14 00:16:49 2008   (SCNodeI0.15553 : csa103CompEO.---.---.00047 :   INFO)&lt;br /&gt;
 csa103CompI1: checkpoint_initialize&lt;br /&gt;
Mon Jul 14 00:16:50 2008   (SCNodeI0.15553 : csa103CompEO.---.---.00054 :   INFO)&lt;br /&gt;
 csa103CompI1: Checkpoint service initialized (handle=0x1)&lt;br /&gt;
Mon Jul 14 00:16:50 2008   (SCNodeI0.15553 : csa103CompEO.---.---.00056 :   INFO)&lt;br /&gt;
 csa103CompI1: Checkpoint opened (handle=0x2)&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
That is the component that had been killed being restarted.  &lt;br /&gt;
&lt;br /&gt;
CompI0 is moving along just fine, and we see CompI1 come back up.  If we then kill CompI0 we see:&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffffaa;&amp;quot; align=&amp;quot;center&amp;quot;| /root/asp/var/log/csa103CompI1Log.latest&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
Mon Jul 14 00:29:44 2008   (SCNodeI0.15553 : csa103CompEO.---.---.00065 :   INFO)&lt;br /&gt;
 csa103CompI1: Active state requested from state 2&lt;br /&gt;
Mon Jul 14 00:29:44 2008   (SCNodeI0.15553 : csa103CompEO.---.---.00066 :   INFO)&lt;br /&gt;
 csa103CompI1 reading checkpoint&lt;br /&gt;
Mon Jul 14 00:29:44 2008   (SCNodeI0.15553 : csa103CompEO.---.---.00067 :   INFO)&lt;br /&gt;
 csa103CompI1 read checkpoint: seq = 1225&lt;br /&gt;
Mon Jul 14 00:29:45 2008   (SCNodeI0.15553 : csa103CompEO.---.---.00068 :   INFO)&lt;br /&gt;
 csa103CompI1: Hello World! (seq=1225)&lt;br /&gt;
Mon Jul 14 00:29:46 2008   (SCNodeI0.15553 : csa103CompEO.---.---.00069 :   INFO)&lt;br /&gt;
 csa103CompI1: Hello World! (seq=1226)&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
Where we can see the CompI0 process die, and CompI1 process read the sequence number from the checkpoint and then take over from where CompI0 left off.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;To stop csa103 use the following SAFplus Platform Console command.&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
cli[Test:SCNodeI0:CPM]-&amp;gt; amsLockAssignment sg csa103SGI0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;Now change the state of csa103SGI0 to LockInstantiation and close the SAFplus Platform Console.&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
cli[Test:SCNodeI0:CPM]-&amp;gt; amsLockInstantiation sg csa103SGI0&lt;br /&gt;
cli[Test:SCNodeI0:CPM] -&amp;gt; end&lt;br /&gt;
cli[Test:SCNodeI0] -&amp;gt; end&lt;br /&gt;
cli[Test] -&amp;gt; bye&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Additional Tests for Runtime Hardware Setup 1.3 and 2.3===&lt;br /&gt;
&lt;br /&gt;
Now repeat  the experiment till the stage before we kill  the active process  and follow these steps.&lt;br /&gt;
&lt;br /&gt;
'''Step A'''&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Stop SAFplus Platform on SCNodeI0 using &amp;lt;code&amp;gt;/etc/init.d/asp stop&amp;lt;/code&amp;gt;. Observer the logs &amp;lt;code&amp;gt;/root/asp/var/log/csa103CompI3Log.latest&amp;lt;/code&amp;gt; on SCNodeI1. This will become active  and start printing the hello world logs as above. &lt;br /&gt;
Note in this case active System Controller SCNode1 is still aware of PayloadNodeI0 and PayloadNodeI1.&lt;br /&gt;
&amp;lt;li&amp;gt;Start looking at the logs  for &amp;lt;code&amp;gt;/root/asp/var/log/csa103CompI0Log.latest&amp;lt;/code&amp;gt; in PayloadNodeI0. This will print the  standby  logs as  above.&lt;br /&gt;
&amp;lt;li&amp;gt;Stop  SAFplus Platform  on PayloadNodeI0  and start observing the logs on PayloadNodeI1 in &amp;lt;code&amp;gt;/root/asp/var/log/csa103CompI1Log.latest&amp;lt;/code&amp;gt; for standby.&lt;br /&gt;
In this case, you can see, via the active System Controller logs that PayloadNodeI0 is not active whilst PayloadNodeI1 is.&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Step B'''  For Hardware Setup 1.3 only&lt;br /&gt;
#Repeat A  with the slight exception  that the  blade running SCNodeI0  is  yanked out(&amp;lt;code&amp;gt;/etc/init.d/asp zap&amp;lt;/code&amp;gt;) instead of gracefully shutting  down SAFplus Platform in step 1.&lt;br /&gt;
&lt;br /&gt;
===Summary and References===&lt;br /&gt;
We've seen :&lt;br /&gt;
&lt;br /&gt;
*how to use Clovis' checkpoint service to save some program state and recover that state from a separate process&lt;br /&gt;
*how to initialize the client checkpoint library&lt;br /&gt;
*how to create and open checkpoints &lt;br /&gt;
*how to create and use sections in an opened checkpoint&lt;br /&gt;
&lt;br /&gt;
Further information can be found within the following: ''OpenClovis API Reference Guide''.&lt;/div&gt;</summary>
		<author><name>Madhu</name></author>	</entry>

	<entry>
		<id>https://help.openclovis.com/index.php/Doc:latest/evalguide/csa103</id>
		<title>Doc:latest/evalguide/csa103</title>
		<link rel="alternate" type="text/html" href="https://help.openclovis.com/index.php/Doc:latest/evalguide/csa103"/>
				<updated>2010-10-01T05:02:25Z</updated>
		
		<summary type="html">&lt;p&gt;Madhu: /* The Code */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==csa103 Checkpointing==&lt;br /&gt;
&lt;br /&gt;
===Objective===&lt;br /&gt;
&lt;br /&gt;
csa103 demonstrates how to use the Clovis Checkpoint service to provide basic failure recovery.  csa103 builds on csa102.&lt;br /&gt;
&lt;br /&gt;
===What Will You Learn===&lt;br /&gt;
&lt;br /&gt;
*how to initialize the checkpoint client library, &lt;br /&gt;
*how to create a checkpoint and  open a checkpoint, &lt;br /&gt;
*how to create a section in the checkpoint &lt;br /&gt;
*how to save data to the checkpoint section and read data from the checkpoint section.&lt;br /&gt;
&lt;br /&gt;
===The Code===&lt;br /&gt;
&lt;br /&gt;
The code can be found within the following directory&lt;br /&gt;
 &amp;lt;project-area_dir&amp;gt;/eval/src/app/csa103Comp&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffccaa;&amp;quot; align=&amp;quot;center&amp;quot;| clCompAppMain.c&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
ClCompAppInitialize()&lt;br /&gt;
&lt;br /&gt;
        ...&lt;br /&gt;
&lt;br /&gt;
        if ((rc = checkpoint_initialize()) != CL_OK)&lt;br /&gt;
        {&lt;br /&gt;
            clprintf(CL_LOG_SEV_ERROR,&amp;quot;%s: Failed [0x%x] to initialize checkpoint&amp;quot;,&lt;br /&gt;
                    appname, rc);&lt;br /&gt;
            return rc;&lt;br /&gt;
        }&lt;br /&gt;
        if ((rc = checkpoint_read_seq(&amp;amp;seq)) != CL_OK)&lt;br /&gt;
        {&lt;br /&gt;
            clprintf(CL_LOG_SEV_ERROR,&amp;quot;%s: Failed [0x%x] to read checkpoint&amp;quot;,&lt;br /&gt;
                    appname, rc);&lt;br /&gt;
            checkpoint_finalize();&lt;br /&gt;
            return rc;&lt;br /&gt;
        }&lt;br /&gt;
    #ifdef CL_INST&lt;br /&gt;
        if ((rc = clDataTapInit(DATA_TAP_DEFAULT_FLAGS, 103)) != CL_OK)&lt;br /&gt;
        {&lt;br /&gt;
            clprintf(CL_LOG_SEV_ERROR,&amp;quot;%s: Failed [0x%x] to initialize data tap&amp;quot;,&lt;br /&gt;
                    appname, rc);&lt;br /&gt;
        }&lt;br /&gt;
    #endif&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
The above software in &amp;lt;code&amp;gt;clCompAppMain.c&amp;lt;/code&amp;gt; is new to csa103. The call to &amp;lt;code&amp;gt;checkpoint_initialize&amp;lt;/code&amp;gt; is pretty straightforward.  This function discussed in detail later within this section.  The call to &amp;lt;code&amp;gt;checkpoint_read_seq&amp;lt;/code&amp;gt; is also pretty straightforward.  It reads the current sequence value from the checkpoint (at this point it should be zero) and loads it into the variable: &amp;lt;code&amp;gt;seq&amp;lt;/code&amp;gt;.  It is important to note the call to &amp;lt;code&amp;gt;checkpont_finalize&amp;lt;/code&amp;gt; if the call to &amp;lt;code&amp;gt;checkpoint_read_seq&amp;lt;/code&amp;gt; does not return &amp;lt;code&amp;gt;CL_OK&amp;lt;/code&amp;gt;.  This call closes the checkpoint and cleanly finalizes the checkpoint library.  We'll look more at &amp;lt;code&amp;gt;checkpoint_read_seq&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;checkpoint_finalize&amp;lt;/code&amp;gt; later.&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffccaa;&amp;quot; align=&amp;quot;center&amp;quot;| clCompAppMain.c&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
        /* Checkpoint new sequence number */&lt;br /&gt;
        rc = checkpoint_write_seq(seq);&lt;br /&gt;
        if (rc != CL_OK)&lt;br /&gt;
        {&lt;br /&gt;
            clprintf(CL_LOG_SEV_ERROR,&amp;quot;%s: ERROR: Checkpoint write failed. Exiting.&amp;quot;, appname);&lt;br /&gt;
            break;&lt;br /&gt;
        }&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
The rest of the csa103's main loop is the same as the main loop in csa102, but the seven lines above are new.  Here we write the new value of the checkpoint variable to the checkpoint section and print and error if this fails.  We'll look closer at &amp;lt;code&amp;gt;checkpoint_write_seq&amp;lt;/code&amp;gt; later.&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffccaa;&amp;quot; align=&amp;quot;center&amp;quot;| clCompAppMain.c&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
    ClRcT&lt;br /&gt;
    clCompAppAMFCSISet(&lt;br /&gt;
        ClInvocationT       invocation,&lt;br /&gt;
        const ClNameT       *compName,&lt;br /&gt;
        ClAmsHAStateT       haState,&lt;br /&gt;
        ClAmsCSIDescriptorT csiDescriptor)&lt;br /&gt;
    {    &lt;br /&gt;
        /*&lt;br /&gt;
         * ---BEGIN_APPLICATION_CODE--- &lt;br /&gt;
         */&lt;br /&gt;
        ClCharT     compname[100]={0};&lt;br /&gt;
&lt;br /&gt;
        /*&lt;br /&gt;
         * ---END_APPLICATION_CODE---&lt;br /&gt;
         */&lt;br /&gt;
&lt;br /&gt;
        /*&lt;br /&gt;
         * Print information about the CSI Set&lt;br /&gt;
         */&lt;br /&gt;
        strncpy(compname, compName-&amp;gt;value, compName-&amp;gt;length);&lt;br /&gt;
&lt;br /&gt;
        clprintf (CL_LOG_SEV_INFO, &amp;quot;Component [%s] : PID [%d]. CSI Set Received&amp;quot;, &lt;br /&gt;
              compname, (int)mypid);&lt;br /&gt;
&lt;br /&gt;
        clCompAppAMFPrintCSI(csiDescriptor, haState);&lt;br /&gt;
    &lt;br /&gt;
        /*&lt;br /&gt;
          Take appropriate action based on state&lt;br /&gt;
        */&lt;br /&gt;
    &lt;br /&gt;
        switch ( haState )&lt;br /&gt;
        {&lt;br /&gt;
            case CL_AMS_HA_STATE_ACTIVE:&lt;br /&gt;
            {&lt;br /&gt;
                /*&lt;br /&gt;
                  AMF has requested application to take the active HA state&lt;br /&gt;
                  for the CSI.&lt;br /&gt;
                */&lt;br /&gt;
    &lt;br /&gt;
                /*&lt;br /&gt;
                  ---BEGIN_APPLICATION_CODE---&lt;br /&gt;
                */&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffccaa;&amp;quot; align=&amp;quot;center&amp;quot;| clCompAppMain.c&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;   &lt;br /&gt;
                clprintf(CL_LOG_SEV_INFO,&amp;quot;%s: Active state requested from state %d&amp;quot;,&lt;br /&gt;
                        appname, ha_state);&lt;br /&gt;
&lt;br /&gt;
                checkpoint_replica_activate();&lt;br /&gt;
                if (ha_state == SA_AMF_HA_STANDBY)&lt;br /&gt;
                {&lt;br /&gt;
                    /* Read checkpoint, make our replica the active replica */&lt;br /&gt;
                    clprintf(CL_LOG_SEV_INFO,&amp;quot;%s reading checkpoint&amp;quot;, appname);&lt;br /&gt;
                    checkpoint_read_seq(&amp;amp;seq);&lt;br /&gt;
                    clprintf(CL_LOG_SEV_INFO,&amp;quot;%s read checkpoint: seq = %u&amp;quot;, appname, seq);&lt;br /&gt;
                }&lt;br /&gt;
            &lt;br /&gt;
                ha_state = SA_AMF_HA_ACTIVE;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
                /*&lt;br /&gt;
                 * ---END_APPLICATION_CODE---&lt;br /&gt;
                 */&lt;br /&gt;
&lt;br /&gt;
                clCpmResponse(cpmHandle, invocation, CL_OK);&lt;br /&gt;
                break;&lt;br /&gt;
            }&lt;br /&gt;
&lt;br /&gt;
            case CL_AMS_HA_STATE_STANDBY:&lt;br /&gt;
            {&lt;br /&gt;
                /*&lt;br /&gt;
                 * AMF has requested application to take the standby HA state &lt;br /&gt;
                 * for this CSI.&lt;br /&gt;
                 */&lt;br /&gt;
&lt;br /&gt;
                /*&lt;br /&gt;
                 * ---BEGIN_APPLICATION_CODE---&lt;br /&gt;
                 */&lt;br /&gt;
&lt;br /&gt;
                 clprintf(CL_LOG_SEV_INFO,&amp;quot; Standby state requested from state %d&amp;quot;,ha_state);&lt;br /&gt;
            &lt;br /&gt;
                 ha_state = SA_AMF_HA_STANDBY;&lt;br /&gt;
&lt;br /&gt;
                /*&lt;br /&gt;
                 * ---END_APPLICATION_CODE---&lt;br /&gt;
                 */&lt;br /&gt;
&lt;br /&gt;
                clCpmResponse(cpmHandle, invocation, CL_OK);&lt;br /&gt;
                break;&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffccaa;&amp;quot; align=&amp;quot;center&amp;quot;| clCompAppMain.c&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;    &lt;br /&gt;
            case CL_AMS_HA_STATE_QUIESCED:&lt;br /&gt;
            {&lt;br /&gt;
                /*&lt;br /&gt;
                 * AMF has requested application to quiesce the CSI currently&lt;br /&gt;
                 * assigned the active or quiescing HA state. The application &lt;br /&gt;
                 * must stop work associated with the CSI immediately.&lt;br /&gt;
                 */&lt;br /&gt;
&lt;br /&gt;
                /*&lt;br /&gt;
                 * ---BEGIN_APPLICATION_CODE---&lt;br /&gt;
                 */&lt;br /&gt;
&lt;br /&gt;
                clprintf(CL_LOG_SEV_INFO,&amp;quot;%s: QUIESCED&amp;quot;, appname);&lt;br /&gt;
                ha_state = haState;&lt;br /&gt;
&lt;br /&gt;
                /*&lt;br /&gt;
                 * ---END_APPLICATION_CODE---&lt;br /&gt;
                 */&lt;br /&gt;
&lt;br /&gt;
                clCpmResponse(cpmHandle, invocation, CL_OK);&lt;br /&gt;
                break;&lt;br /&gt;
            }&lt;br /&gt;
&lt;br /&gt;
            case CL_AMS_HA_STATE_QUIESCING:&lt;br /&gt;
            { &lt;br /&gt;
                /*&lt;br /&gt;
                 * AMF has requested application to quiesce the CSI currently&lt;br /&gt;
                 * assigned the active HA state. The application must stop work&lt;br /&gt;
                 * associated with the CSI gracefully and not accept any new&lt;br /&gt;
                 * workloads while the work is being terminated.&lt;br /&gt;
                 */&lt;br /&gt;
&lt;br /&gt;
                /*&lt;br /&gt;
                 * ---BEGIN_APPLICATION_CODE---&lt;br /&gt;
                 */&lt;br /&gt;
&lt;br /&gt;
                clprintf(CL_LOG_SEV_INFO,&amp;quot;%s: QUIESCING&amp;quot;, appname);&lt;br /&gt;
                ha_state = haState;&lt;br /&gt;
&lt;br /&gt;
                /*&lt;br /&gt;
                 * ---END_APPLICATION_CODE---&lt;br /&gt;
                 */&lt;br /&gt;
&lt;br /&gt;
                clCpmCSIQuiescingComplete(cpmHandle, invocation, CL_OK);&lt;br /&gt;
                break;&lt;br /&gt;
            }&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffccaa;&amp;quot; align=&amp;quot;center&amp;quot;| clCompAppMain.c&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
            default:&lt;br /&gt;
            {&lt;br /&gt;
                break;&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
    &lt;br /&gt;
        return CL_OK;&lt;br /&gt;
    }&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now looking at csa103's implementation of &amp;lt;code&amp;gt;clCompAppAMFCSISet&amp;lt;/code&amp;gt;, we see that rather than just a few cases, we handle several cases: &amp;lt;code&amp;gt;QUIESCING&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;QUIESCED&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;ACTIVE&amp;lt;/code&amp;gt;, and  &amp;lt;code&amp;gt;STANDBY&amp;lt;/code&amp;gt;.  In each state, the global variable &amp;lt;code&amp;gt;ha_state&amp;lt;/code&amp;gt; to the new_state value that is passed in is set.  This is similar to csa102, except that we add the feature that in the &amp;lt;code&amp;gt;CL_AMS_HA_STATE_ACTIVE&amp;lt;/code&amp;gt; case if our previous state was &amp;lt;code&amp;gt;CL_AMS_HA_STATE_STANDBY&amp;lt;/code&amp;gt; we read the sequence from the checkpoint so that the main loop will pick it up.&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffccaa;&amp;quot; align=&amp;quot;center&amp;quot;| clCompAppMain.c&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
    static ClRcT&lt;br /&gt;
    checkpoint_initialize()&lt;br /&gt;
    {&lt;br /&gt;
        SaAisErrorT      rc = CL_OK;&lt;br /&gt;
        SaVersionT ckpt_version = {'B', 1, 1};&lt;br /&gt;
        SaNameT    ckpt_name = { strlen(CKPT_NAME), CKPT_NAME };&lt;br /&gt;
        ClUint32T  seq_no;&lt;br /&gt;
        SaCkptCheckpointCreationAttributesT create_atts = {&lt;br /&gt;
            .creationFlags     = SA_CKPT_WR_ACTIVE_REPLICA_WEAK |&lt;br /&gt;
                             SA_CKPT_CHECKPOINT_COLLOCATED,&lt;br /&gt;
            .checkpointSize    = sizeof(ClUint32T),&lt;br /&gt;
            .retentionDuration = (ClTimeT)10,&lt;br /&gt;
            .maxSections       = 2, // two sections &lt;br /&gt;
            .maxSectionSize    = sizeof(ClUint32T),&lt;br /&gt;
            .maxSectionIdSize  = (ClSizeT)64&lt;br /&gt;
&lt;br /&gt;
        &lt;br /&gt;
        };&lt;br /&gt;
        SaCkptSectionCreationAttributesT section_atts = {&lt;br /&gt;
        .sectionId = &amp;amp;ckpt_sid,&lt;br /&gt;
        .expirationTime = SA_TIME_END&lt;br /&gt;
&lt;br /&gt;
        };&lt;br /&gt;
 &lt;br /&gt;
        clprintf(CL_LOG_SEV_INFO,&amp;quot;%s: checkpoint_initialize&amp;quot;, appname);&lt;br /&gt;
        /* Initialize checkpointing service instance */&lt;br /&gt;
        rc = saCkptInitialize(&amp;amp;ckpt_svc_handle,	/* Checkpoint service handle */&lt;br /&gt;
						  NULL,			    /* Optional callbacks table */&lt;br /&gt;
						  &amp;amp;ckpt_version);   /* Required verison number */&lt;br /&gt;
        if (rc != SA_AIS_OK)&lt;br /&gt;
        {&lt;br /&gt;
            clprintf(CL_LOG_SEV_ERROR,&amp;quot;%s: ERROR: Failed to initialize checkpoint service&amp;quot;,&lt;br /&gt;
                    appname);&lt;br /&gt;
            return rc;&lt;br /&gt;
        }&lt;br /&gt;
        clprintf(CL_LOG_SEV_INFO,&amp;quot;%s: Checkpoint service initialized (handle=0x%llx)&amp;quot;,&lt;br /&gt;
           appname, ckpt_svc_handle);&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Here is &amp;lt;code&amp;gt;checkpoint_initialize&amp;lt;/code&amp;gt;.  Here we initialize the &amp;lt;code&amp;gt;ClNameT&amp;lt;/code&amp;gt; structure that holds the name of the checkpoint to be opened/created with the line: &amp;lt;code&amp;gt;ClNameT    ckpt_name = { strlen(CKPT_NAME), CKPT_NAME };&amp;lt;/code&amp;gt;. We then define a set of attributes to associate with the checkpoint when creating that checkpoint. The &amp;lt;code&amp;gt;creationFlags&amp;lt;/code&amp;gt; includes &amp;lt;code&amp;gt;CL_CKPT_WR_ACTIVE_REPLICA&amp;lt;/code&amp;gt;.  This means that the checkpoint to be created will be asynchronous, or once active server updation is completed, the call returns to the application, all other replica updates happens parallel. &amp;lt;code&amp;gt;CheckpointSize&amp;lt;/code&amp;gt; is set to the sizeof a 32 bit unsigned integer, which is the sequence number we print in the main loop.  The &amp;lt;code&amp;gt;retentionDuration&amp;lt;/code&amp;gt; is the time that the checkpoint service will keep the checkpoint in store after the last client has closed the checkpoint.  &amp;lt;code&amp;gt;MaxSections&amp;lt;/code&amp;gt; is 2 as this checkpoint will be used to store two sections.  &amp;lt;code&amp;gt;MaxSectionSize&amp;lt;/code&amp;gt; is the set to the sizeof a 32 bit unsigned integer, as application stores only unsigned integer. And &amp;lt;code&amp;gt;maxSectionIdSize&amp;lt;/code&amp;gt; is 64 bytes.&lt;br /&gt;
&lt;br /&gt;
We next use &amp;lt;code&amp;gt;ClCkptSectionCreationAttributesT section_atts&amp;lt;/code&amp;gt; to define the creation attributes for the sole section of the checkpoint. The &amp;lt;code&amp;gt;sectionId&amp;lt;/code&amp;gt; is just the name of the section along with the number of bytes in the name.  The &amp;lt;code&amp;gt;expirationTime&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;CL_TIME_END&amp;lt;/code&amp;gt; to imply that the section is never deleted automatically if the checkpoint itself still remains.&lt;br /&gt;
&lt;br /&gt;
The call to &amp;lt;code&amp;gt;clCkptInitialize&amp;lt;/code&amp;gt; has to be called before any other checkpoint functions.  The &amp;lt;code&amp;gt;ckpt_svc_handle&amp;lt;/code&amp;gt; is where the handle is returned.  The handle must be passed to some future checkpoint api calls, namely the &amp;lt;code&amp;gt;clCkptCheckpointOpen&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;clCkptFinalize&amp;lt;/code&amp;gt; calls.  The callbacks table is passed as &amp;lt;code&amp;gt;NULL&amp;lt;/code&amp;gt; which implies that our application doesn't provide any callbacks.  Finally the &amp;lt;code&amp;gt;ckpt_version&amp;lt;/code&amp;gt; identifies what version of the api this application is written to.&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffccaa;&amp;quot; align=&amp;quot;center&amp;quot;| clCompAppMain.c&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
        //&lt;br /&gt;
        // Create the checkpoint for read and write.            &lt;br /&gt;
&lt;br /&gt;
        rc = saCkptCheckpointOpen(ckpt_svc_handle,      // Service handle&lt;br /&gt;
                              &amp;amp;ckpt_name,         // Checkpoint name&lt;br /&gt;
                              &amp;amp;create_atts,       // Optional creation attr.&lt;br /&gt;
                              (SA_CKPT_CHECKPOINT_READ |&lt;br /&gt;
                               SA_CKPT_CHECKPOINT_WRITE |&lt;br /&gt;
                               SA_CKPT_CHECKPOINT_CREATE),&lt;br /&gt;
                              (SaTimeT)-1,        // No timeout&lt;br /&gt;
                              &amp;amp;ckpt_handle);      // Checkpoint handle&lt;br /&gt;
&lt;br /&gt;
        if (rc != SA_AIS_OK)&lt;br /&gt;
&lt;br /&gt;
        {&lt;br /&gt;
            clprintf(CL_LOG_SEV_ERROR,&amp;quot;%s: ERROR: Failed [0x%x] to open checkpoint&amp;quot;,&lt;br /&gt;
                    appname, rc);&lt;br /&gt;
            (void)saCkptFinalize(ckpt_svc_handle);&lt;br /&gt;
            return rc;&lt;br /&gt;
        }&lt;br /&gt;
        clprintf(CL_LOG_SEV_INFO,&amp;quot;%s: Checkpoint opened (handle=0x%llx)&amp;quot;, appname, ckpt_handle);&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
 &lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffccaa;&amp;quot; align=&amp;quot;center&amp;quot;| clCompAppMain.c&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
        /*&lt;br /&gt;
         * Try to create a section so that updates can operate by overwriting&lt;br /&gt;
         * the section over and over again.&lt;br /&gt;
         * If subsequent processes come through here, they will fail to create&lt;br /&gt;
         * the section.  That is OK, even though it will cause an error message&lt;br /&gt;
         * If the section create fails because the section is already there, then&lt;br /&gt;
         * read the sequence number&lt;br /&gt;
         */&lt;br /&gt;
        // Put data in network byte order&lt;br /&gt;
        seq_no = htonl(seq);&lt;br /&gt;
&lt;br /&gt;
        // Creating the section&lt;br /&gt;
        checkpoint_replica_activate();&lt;br /&gt;
        rc = saCkptSectionCreate(ckpt_handle,           // Checkpoint handle&lt;br /&gt;
                             &amp;amp;section_atts,         // Section attributes&lt;br /&gt;
                             (SaUint8T*)&amp;amp;seq_no,    // Initial data&lt;br /&gt;
                             (SaSizeT)sizeof(seq_no)); // Size of data&lt;br /&gt;
        if (rc != SA_AIS_OK &amp;amp;&amp;amp; (CL_GET_ERROR_CODE(rc) != SA_AIS_ERR_EXIST))&lt;br /&gt;
        {&lt;br /&gt;
            clprintf(CL_LOG_SEV_ERROR,&amp;quot;%s: ERROR: Failed to create checkpoint section&amp;quot;, appname);&lt;br /&gt;
            (void)saCkptCheckpointClose(ckpt_handle);&lt;br /&gt;
            (void)saCkptFinalize(ckpt_svc_handle);&lt;br /&gt;
            return rc;&lt;br /&gt;
        }&lt;br /&gt;
        else if (rc != SA_AIS_OK &amp;amp;&amp;amp; (CL_GET_ERROR_CODE(rc) == SA_AIS_ERR_EXIST))&lt;br /&gt;
        {&lt;br /&gt;
            rc = checkpoint_read_seq(&amp;amp;seq);&lt;br /&gt;
            if (rc != CL_OK)&lt;br /&gt;
            {&lt;br /&gt;
                clprintf(CL_LOG_SEV_ERROR,&amp;quot;%s: ERROR: Failed [0x%x] to read checkpoint section&amp;quot;,&lt;br /&gt;
                            appname, rc);&lt;br /&gt;
                (void)saCkptCheckpointClose(ckpt_handle);&lt;br /&gt;
                (void)saCkptFinalize(ckpt_svc_handle);&lt;br /&gt;
                return rc;&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
        else&lt;br /&gt;
        {&lt;br /&gt;
            clprintf(CL_LOG_SEV_INFO,&amp;quot;%s: Section created&amp;quot;, appname);&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        return CL_OK;&lt;br /&gt;
    }&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
With &amp;lt;code&amp;gt;rc = clCkptCheckpointOpen&amp;lt;/code&amp;gt; we attempt to open the specified checkpoint.  When &amp;lt;code&amp;gt;checkpoint_initialize&amp;lt;/code&amp;gt; is called the checkpoint may or may not exist.  We attempt to open the checkpoint for READ/WRITE access. &lt;br /&gt;
&lt;br /&gt;
Next we check if we created the checkpoint and then we need to create the section with a call to &amp;lt;code&amp;gt;clCkptSectionCreate&amp;lt;/code&amp;gt;.  We pass the checkpoint handle obtained from &amp;lt;code&amp;gt;clCkptCheckpointOpen&amp;lt;/code&amp;gt;, the section attributes declared earlier, and the address of the initial value along with the size in bytes of the initial value.&lt;br /&gt;
&lt;br /&gt;
We convert the initial value to network byte order by the code &amp;lt;code&amp;gt;seq_no = htonl(seq)&amp;lt;/code&amp;gt;, before passing it to &amp;lt;code&amp;gt;clCkptSectionCreate&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If we do not create the section, then we read the current value in the checkpoint into our global seq variable.&lt;br /&gt;
&lt;br /&gt;
Note that whenever we return an error return code from the function that we have either not opened the checkpoint/initialized the checkpoint service, or we have closed the checkpoint and finalized the checkpoint service with calls to &amp;lt;code&amp;gt;clCkptCheckpointClose&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;clCkptFinalize&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffccaa;&amp;quot; align=&amp;quot;center&amp;quot;| clCompAppMain.c&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
    static ClRcT &lt;br /&gt;
    checkpoint_finalize(void)&lt;br /&gt;
    {&lt;br /&gt;
        SaAisErrorT rc;&lt;br /&gt;
&lt;br /&gt;
        rc = saCkptCheckpointClose(ckpt_handle);&lt;br /&gt;
        if (rc != SA_AIS_OK)&lt;br /&gt;
        {&lt;br /&gt;
            clprintf(CL_LOG_SEV_ERROR,&amp;quot;%s: failed: [0x%x] to close checkpoint handle 0x%llx&amp;quot;,&lt;br /&gt;
                        appname, rc, ckpt_handle);&lt;br /&gt;
        }&lt;br /&gt;
        rc = saCkptFinalize(ckpt_svc_handle);&lt;br /&gt;
        if (rc != SA_AIS_OK)&lt;br /&gt;
        {&lt;br /&gt;
            clprintf(CL_LOG_SEV_ERROR,&amp;quot;%s: failed: [0x%x] to finalize checkpoint&amp;quot;,&lt;br /&gt;
                    appname, rc);&lt;br /&gt;
        }&lt;br /&gt;
        return CL_OK;&lt;br /&gt;
&lt;br /&gt;
    }&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
The above code snippet presents &amp;lt;code&amp;gt;checkpoint_finalize&amp;lt;/code&amp;gt;.  It's quite simple.  First it closes the checkpoint handle with a call to &amp;lt;code&amp;gt;clCkptCheckpointClose&amp;lt;/code&amp;gt;.  Next it finalizes the checkpoint library with a call to &amp;lt;code&amp;gt;clCkptFinalize&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffccaa;&amp;quot; align=&amp;quot;center&amp;quot;| clCompAppMain.c&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
    static ClRcT&lt;br /&gt;
    checkpoint_write_seq(ClUint32T seq)&lt;br /&gt;
    {&lt;br /&gt;
        SaAisErrorT rc = SA_AIS_OK;&lt;br /&gt;
        ClUint32T seq_no;&lt;br /&gt;
&lt;br /&gt;
        /* Putting data in network byte order */&lt;br /&gt;
        seq_no = htonl(seq);&lt;br /&gt;
&lt;br /&gt;
        /* Write checkpoint */&lt;br /&gt;
        retry:&lt;br /&gt;
        rc = saCkptSectionOverwrite(ckpt_handle,&lt;br /&gt;
                                &amp;amp;ckpt_sid,&lt;br /&gt;
                                &amp;amp;seq_no,&lt;br /&gt;
                                sizeof(ClUint32T));&lt;br /&gt;
        if (rc != SA_AIS_OK)&lt;br /&gt;
        {&lt;br /&gt;
            clprintf(CL_LOG_SEV_ERROR,&amp;quot;Failed [0x%x] to write to section&amp;quot;, rc);&lt;br /&gt;
            if(rc == SA_AIS_ERR_NOT_EXIST)&lt;br /&gt;
                rc = checkpoint_replica_activate();&lt;br /&gt;
            if(rc == CL_OK) goto retry;&lt;br /&gt;
        }&lt;br /&gt;
        else&lt;br /&gt;
        {&lt;br /&gt;
            /*&lt;br /&gt;
            * Synchronize the checkpoint to all the replicas.&lt;br /&gt;
            */&lt;br /&gt;
            rc = saCkptCheckpointSynchronize(ckpt_handle, SA_TIME_END );&lt;br /&gt;
            if (rc != SA_AIS_OK)&lt;br /&gt;
            {&lt;br /&gt;
                clprintf(CL_LOG_SEV_ERROR,&amp;quot;Failed [0x%x] to synchronize the checkpoint&amp;quot;, rc);&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        return CL_OK;&lt;br /&gt;
     }&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
With &amp;lt;code&amp;gt;checkpoint_write_seq&amp;lt;/code&amp;gt; we first convert the sequence number passed into network byte order.  Then we pass it to &amp;lt;code&amp;gt;clCKptSectionOverwrite&amp;lt;/code&amp;gt; which writes it to the checkpoint section created in &amp;lt;code&amp;gt;checkpoint_initialize&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffccaa;&amp;quot; align=&amp;quot;center&amp;quot;| clCompAppMain.c&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
    static ClRcT&lt;br /&gt;
    checkpoint_read_seq(ClUint32T *seq)&lt;br /&gt;
    {&lt;br /&gt;
        ClRcT rc = CL_OK;&lt;br /&gt;
        ClUint32T err_idx; /* Error index in ioVector */&lt;br /&gt;
        ClUint32T seq_no = 0xffffffff;&lt;br /&gt;
        SaCkptIOVectorElementT iov = {&lt;br /&gt;
            .sectionId  = ckpt_sid,&lt;br /&gt;
            .dataBuffer = (ClPtrT)&amp;amp;seq_no,&lt;br /&gt;
            .dataSize   = sizeof(ClUint32T),&lt;br /&gt;
            .dataOffset = (ClOffsetT)0,&lt;br /&gt;
            .readSize   = sizeof(ClUint32T)&lt;br /&gt;
        };&lt;br /&gt;
&lt;br /&gt;
        rc = saCkptCheckpointRead(ckpt_handle, &amp;amp;iov, 1, &amp;amp;err_idx);&lt;br /&gt;
        if (rc != SA_AIS_OK)&lt;br /&gt;
        {&lt;br /&gt;
           clprintf(CL_LOG_SEV_ERROR,&amp;quot;Error: [0x%x] from checkpoint read, err_idx = %u&amp;quot;,&lt;br /&gt;
                    rc, err_idx);&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        /* FIXME: How to process this err_idx? */&lt;br /&gt;
        *seq = ntohl(seq_no);&lt;br /&gt;
&lt;br /&gt;
        return CL_OK;&lt;br /&gt;
&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
With &amp;lt;code&amp;gt;checkpoint_read_seq&amp;lt;/code&amp;gt; we initialize &amp;lt;code&amp;gt;seq_no&amp;lt;/code&amp;gt; to all ones just so it will be more obvious if the &amp;lt;code&amp;gt;clCkptCheckpointRead&amp;lt;/code&amp;gt; call fails and the value of &amp;lt;code&amp;gt;seq_no&amp;lt;/code&amp;gt; doesn't get overwritten.  Then, we set up the &amp;lt;code&amp;gt;iov&amp;lt;/code&amp;gt; variable.  We set the &amp;lt;code&amp;gt;sectionID&amp;lt;/code&amp;gt;  field to &amp;lt;code&amp;gt;ckpt_sid&amp;lt;/code&amp;gt; which is the id of the section created in &amp;lt;code&amp;gt;checkpoint_initialize&amp;lt;/code&amp;gt;.  The &amp;lt;code&amp;gt;dataBuffer&amp;lt;/code&amp;gt; gets set to the address of the &amp;lt;code&amp;gt;seq_no&amp;lt;/code&amp;gt; variable which is where we want the checkpoint data loaded.  The &amp;lt;code&amp;gt;dataSize&amp;lt;/code&amp;gt; field is set to the the size of the &amp;lt;code&amp;gt;seq_no&amp;lt;/code&amp;gt; variable.  &amp;lt;code&amp;gt;DataOfset&amp;lt;/code&amp;gt; is set to zero since the sequence number is the only thing stored in the section, so it resides at the front of the section.  &amp;lt;code&amp;gt;readSize&amp;lt;/code&amp;gt; is set to the size of the sequence number variable.&lt;br /&gt;
&lt;br /&gt;
Within &amp;lt;code&amp;gt;checkpoint_read_seq&amp;lt;/code&amp;gt; we pass the iovector to &amp;lt;code&amp;gt;clCkptCheckpointRead&amp;lt;/code&amp;gt; along with the &amp;lt;code&amp;gt;ckpt_handle&amp;lt;/code&amp;gt;, the constant 1, and the address of the &amp;lt;code&amp;gt;err_idx&amp;lt;/code&amp;gt; variable.  The constant 1 is the number of elements in the array of &amp;lt;code&amp;gt;ClCkptIOVectorElementT structs&amp;lt;/code&amp;gt; that we're passing.  That is, we're passing the address of a single &amp;lt;code&amp;gt;ClCkptIOVectorElementT struct&amp;lt;/code&amp;gt;.  The &amp;lt;code&amp;gt;err_idx&amp;lt;/code&amp;gt; will hold the index in that array where &amp;lt;code&amp;gt;clCkptCheckpointRead&amp;lt;/code&amp;gt; found an error.  That is, if there is going to be an error, it will be at index 0 since we're only passing on entry in the &amp;lt;code&amp;gt;iovector&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffccaa;&amp;quot; align=&amp;quot;center&amp;quot;| clCompAppMain.c&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    static ClRcT&lt;br /&gt;
    checkpoint_replica_activate(void)&lt;br /&gt;
    {&lt;br /&gt;
        SaAisErrorT rc = SA_AIS_OK;&lt;br /&gt;
&lt;br /&gt;
        if ((rc = saCkptActiveReplicaSet(ckpt_handle)) != SA_AIS_OK)&lt;br /&gt;
        {&lt;br /&gt;
            clprintf(CL_LOG_SEV_ERROR,&lt;br /&gt;
                    &amp;quot;checkpoint_replica_activate failed [0x%x] in ActiveReplicaSet&amp;quot;,&lt;br /&gt;
                    rc);&lt;br /&gt;
        }&lt;br /&gt;
        else rc = CL_OK;&lt;br /&gt;
&lt;br /&gt;
        return rc;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
===csa203===&lt;br /&gt;
&lt;br /&gt;
csa203 demonstrates the usage of SA Forum's Checkpointing service. This sample application does not deviate functionally from csa103. The code differences are due to using SA Forum data types (structures) and APIs , as presented in the following two tables. (Note we have not repeated data types and APIs covered previously.)&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|+align=&amp;quot;bottom&amp;quot;| '''SA Forum Data Types with the SAFplus Platform equivalent'''&lt;br /&gt;
|- style=&amp;quot;color:black;background-color:#ffffaa;&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
!SA Forum Data Types   &lt;br /&gt;
!OpenClovis Data Types&lt;br /&gt;
|-&lt;br /&gt;
|SaCkptHandleT&lt;br /&gt;
|ClCkptSvcHdlT&lt;br /&gt;
|-&lt;br /&gt;
|SaCkptHandleT&lt;br /&gt;
|ClCkptHdlT&lt;br /&gt;
|-&lt;br /&gt;
|SaCkptSectionIdT&lt;br /&gt;
|ClCkptSectionIdT&lt;br /&gt;
|-&lt;br /&gt;
|SaCkptCheckpointCreationAttributesT&lt;br /&gt;
|ClCkptCheckpointCreationAttributesT&lt;br /&gt;
|-&lt;br /&gt;
|SaCkptSectionCreationAttributesT&lt;br /&gt;
|ClCkptSectionCreationAttributesT&lt;br /&gt;
|-&lt;br /&gt;
|SaCkptIOVectorElementT&lt;br /&gt;
|ClCkptIOVectorElementT&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|+align=&amp;quot;bottom&amp;quot;| '''SA Forum APIs with the SAFplus Platform equivalent'''&lt;br /&gt;
|- style=&amp;quot;color:black;background-color:#ffffaa;&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
!SA Forum APIs&lt;br /&gt;
!OpenClovis APIs&lt;br /&gt;
|-&lt;br /&gt;
|saCkptInitialize&lt;br /&gt;
|clCkptInitialize&lt;br /&gt;
|-&lt;br /&gt;
|saCkptCheckpointOpen&lt;br /&gt;
|clCkptCheckpointOpen&lt;br /&gt;
|-&lt;br /&gt;
|saCkptSectionCreate&lt;br /&gt;
|clCkptSectionCreate&lt;br /&gt;
|-&lt;br /&gt;
|saCkptCheckpointClose&lt;br /&gt;
|clCkptCheckpointClose&lt;br /&gt;
|-&lt;br /&gt;
|saCkptFinalize&lt;br /&gt;
|clCkptFinalize&lt;br /&gt;
|-&lt;br /&gt;
|saCkptSectionOverwrite&lt;br /&gt;
|clCkptSectionOverwrite&lt;br /&gt;
|-&lt;br /&gt;
|saCkptCheckpointSynchronize&lt;br /&gt;
|clCkptCheckpointSynchronize&lt;br /&gt;
|-&lt;br /&gt;
|saCkptCheckpointRead&lt;br /&gt;
|clCkptCheckpointRead&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===How to Run csa103 and What to Observe===&lt;br /&gt;
&lt;br /&gt;
This sample application can run on all Runtime Hardware Setups. The following, lists which node &amp;lt;code&amp;gt;csa103compI*&amp;lt;/code&amp;gt; runs on.&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;'''Runtime Hardware Setup 1.1 and 2.1'''&lt;br /&gt;
&amp;lt;br&amp;gt;csa103compI0 and csa103compI1 will run upon the single node.&lt;br /&gt;
&amp;lt;li&amp;gt;'''Runtime Hardware Setup 1.2 and 2.2'''&lt;br /&gt;
&amp;lt;br&amp;gt;csa103compI0 runs on PayloadNodeI0 and csa103compI1 runs on PayloadNodeI1&lt;br /&gt;
&amp;lt;li&amp;gt;'''Runtime Hardware Setup 1.3 and 2.3'''&lt;br /&gt;
&amp;lt;br&amp;gt;csa103compI2 and csa103compI3 run on SCNodeI0 and SCNodeI1 respectively. csa103compI0 and csa103compI1 run on PayloadNodeI0 and PayloadNodeI1 respectively.&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;In the four node set up SCNodeI0 and SCNodeI1 output data via &amp;lt;code&amp;gt;/root/asp/var/log/csa103CompI2&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;/root/asp/var/log/csa103CompI3&amp;lt;/code&amp;gt; respectively. Therefore in this case follow the below instructions replacing csa103CompI0 and csa103compI1 with csa103compI2 and csa103compI3 respectively.&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We run csa103 very much the same way we run any of the rest of the sample applications: with the SAFplus Platform Console.&lt;br /&gt;
  &lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;First, on the active System Controller move it to state LockAssignment with (Unlock csa203SGI0 instead of csa103SGI0 to run csa203)&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
cli[Test]-&amp;gt; setc 1&lt;br /&gt;
cli[Test:SCNodeI0]-&amp;gt; setc cpm&lt;br /&gt;
cli[Test:SCNodeI0:CPM]-&amp;gt; amsLockAssignment sg csa103SGI0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The following output is given when you run &amp;lt;code&amp;gt;tail -f&amp;lt;/code&amp;gt; on the csa103 log files. For example:&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
# tail -f /root/asp/var/log/csa103CompI0.log&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffffaa;&amp;quot; align=&amp;quot;center&amp;quot;| /root/asp/var/log/csa103CompI0Log.latest&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
Mon Jul 14 00:01:09 2008   (SCNodeI0.15238 : csa103CompEO.---.---.00030 :   INFO)&lt;br /&gt;
 Component [csa103CompI0] : PID [15238]. Initializing&lt;br /&gt;
Mon Jul 14 00:01:09 2008   (SCNodeI0.15238 : csa103CompEO.---.---.00031 :   INFO)&lt;br /&gt;
    IOC Address             : 0x1&lt;br /&gt;
Mon Jul 14 00:01:09 2008   (SCNodeI0.15238 : csa103CompEO.---.---.00032 :   INFO)&lt;br /&gt;
    IOC Port                : 0x81&lt;br /&gt;
Mon Jul 14 00:01:09 2008   (SCNodeI0.15238 : csa103CompEO.---.---.00033 :   INFO)&lt;br /&gt;
 csa103: Instantiated as component instance csa103CompI0.&lt;br /&gt;
Mon Jul 14 00:01:09 2008   (SCNodeI0.15238 : csa103CompEO.---.---.00034 :   INFO)&lt;br /&gt;
 csa103CompI0: Waiting for CSI assignment...&lt;br /&gt;
Mon Jul 14 00:01:09 2008   (SCNodeI0.15238 : csa103CompEO.---.---.00035 :   INFO)&lt;br /&gt;
 csa103CompI0: Waiting for CSI assignment...&lt;br /&gt;
Mon Jul 14 00:01:09 2008   (SCNodeI0.15238 : csa103CompEO.---.---.00036 :   INFO)&lt;br /&gt;
 csa103CompI0: checkpoint_initialize&lt;br /&gt;
Mon Jul 14 00:01:10 2008   (SCNodeI0.15238 : csa103CompEO.---.---.00043 :   INFO)&lt;br /&gt;
 csa103CompI0: Checkpoint service initialized (handle=0x1)&lt;br /&gt;
Mon Jul 14 00:01:10 2008   (SCNodeI0.15238 : csa103CompEO.---.---.00045 :   INFO)&lt;br /&gt;
 csa103CompI0: Checkpoint opened (handle=0x2)&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
# tail -f /root/asp/var/log/csa103CompI1.log&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffffaa;&amp;quot; align=&amp;quot;center&amp;quot;| /root/asp/var/log/csa103CompI1Log.latest&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
Mon Jul 14 00:01:09 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00030 :   INFO)&lt;br /&gt;
 Component [csa103CompI1] : PID [15234]. Initializing&lt;br /&gt;
Mon Jul 14 00:01:09 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00031 :   INFO)&lt;br /&gt;
    IOC Address             : 0x1&lt;br /&gt;
Mon Jul 14 00:01:09 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00032 :   INFO)&lt;br /&gt;
    IOC Port                : 0x80&lt;br /&gt;
Mon Jul 14 00:01:09 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00033 :   INFO)&lt;br /&gt;
 csa103: Instantiated as component instance csa103CompI1.&lt;br /&gt;
Mon Jul 14 00:01:09 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00034 :   INFO)&lt;br /&gt;
 csa103CompI1: Waiting for CSI assignment...&lt;br /&gt;
Mon Jul 14 00:01:09 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00035 :   INFO)&lt;br /&gt;
 csa103CompI1: Waiting for CSI assignment...&lt;br /&gt;
Mon Jul 14 00:01:09 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00036 :   INFO)&lt;br /&gt;
 csa103CompI1: checkpoint_initialize&lt;br /&gt;
Mon Jul 14 00:01:09 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00043 :   INFO)&lt;br /&gt;
 csa103CompI1: Checkpoint service initialized (handle=0x1)&lt;br /&gt;
Mon Jul 14 00:01:09 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00045 :   INFO)&lt;br /&gt;
 csa103CompI1: Checkpoint opened (handle=0x2)&lt;br /&gt;
Mon Jul 14 00:01:09 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00053 :   INFO)&lt;br /&gt;
 csa103CompI1: Section created&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;Then, unlock the application by running &lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
cli[Test:SCNodeI0:CPM]-&amp;gt; amsUnlock sg csa103SGI0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the application log files, you should see &lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffffaa;&amp;quot; align=&amp;quot;center&amp;quot;| /root/asp/var/log/csa103CompI0Log.latest&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
Mon Jul 14 00:09:08 2008   (SCNodeI0.15238 : csa103CompEO.---.---.00058 :   INFO)&lt;br /&gt;
  Standby state requested from state 0&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffffaa;&amp;quot; align=&amp;quot;center&amp;quot;| /root/asp/var/log/csa103CompI1Log.latest&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
Mon Jul 14 00:09:08 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00064 :   INFO)&lt;br /&gt;
 csa103CompI1: Active state requested from state 0&lt;br /&gt;
Mon Jul 14 00:09:09 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00065 :   INFO)&lt;br /&gt;
 csa103CompI1: Hello World! (seq=0)&lt;br /&gt;
Mon Jul 14 00:09:10 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00066 :   INFO)&lt;br /&gt;
 csa103CompI1: Hello World! (seq=1)&lt;br /&gt;
Mon Jul 14 00:09:11 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00067 :   INFO)&lt;br /&gt;
 csa103CompI1: Hello World! (seq=2)&lt;br /&gt;
Mon Jul 14 00:09:12 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00068 :   INFO)&lt;br /&gt;
 csa103CompI1: Hello World! (seq=3)&lt;br /&gt;
Mon Jul 14 00:09:13 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00069 :   INFO)&lt;br /&gt;
 csa103CompI1: Hello World! (seq=4)&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;Next, find the active csa103 process, the one that's printing the Hello World lines and kill it.  To find the process ID issue the following command from a bash shell.&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
 # ps -eaf | grep csa103&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
This should produce an output that looks similar to the following.&lt;br /&gt;
 root     17830 15663  0 14:21 ?        00:00:00 csa103Comp -p&lt;br /&gt;
 root     17839 15663  0 14:21 ?        00:00:00 csa103Comp -p&lt;br /&gt;
 root     18558 16145  0 14:32 pts/4    00:00:00 grep csa103&lt;br /&gt;
Notice the two entries that end with csa103Comp -p. These are our two component processes. The first one is usually the active process. This is the one that we will kill. In this case the process ID is 17830. So to kill the active component you issue the command:&lt;br /&gt;
&lt;br /&gt;
 # kill -9 17830&lt;br /&gt;
&lt;br /&gt;
[[File:OpenClovis_Note.png]]If this step does not result in the active component being killed then it is likely that the standby component was killed. In this case simply try killing the other process. &lt;br /&gt;
&lt;br /&gt;
After killing the active component you should see lines in the log files like the following:&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffffaa;&amp;quot; align=&amp;quot;center&amp;quot;| /root/asp/var/log/csa103CompI1Log.latest&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
Mon Jul 14 00:16:43 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00515 :   INFO)&lt;br /&gt;
 csa103CompI1: Hello World! (seq=452)&lt;br /&gt;
Mon Jul 14 00:16:44 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00516 :   INFO)&lt;br /&gt;
 csa103CompI1: Hello World! (seq=453)&lt;br /&gt;
Mon Jul 14 00:16:45 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00517 :   INFO)&lt;br /&gt;
 csa103CompI1: Hello World! (seq=454)&lt;br /&gt;
Mon Jul 14 00:16:46 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00518 :   INFO)&lt;br /&gt;
 csa103CompI1: Hello World! (seq=455)&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffffaa;&amp;quot; align=&amp;quot;center&amp;quot;| /var/log/csa103CompI0Log.latest&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
Mon Jul 14 00:16:48 2008   (SCNodeI0.15238 : csa103CompEO.---.---.00065 :   INFO)&lt;br /&gt;
 csa103CompI0: Active state requested from state 2&lt;br /&gt;
Mon Jul 14 00:16:48 2008   (SCNodeI0.15238 : csa103CompEO.---.---.00066 :   INFO)&lt;br /&gt;
 csa103CompI0 reading checkpoint&lt;br /&gt;
Mon Jul 14 00:16:48 2008   (SCNodeI0.15238 : csa103CompEO.---.---.00067 :   INFO)&lt;br /&gt;
 csa103CompI0 read checkpoint: seq = 456&lt;br /&gt;
Mon Jul 14 00:16:49 2008   (SCNodeI0.15238 : csa103CompEO.---.---.00068 :   INFO)&lt;br /&gt;
 csa103CompI0: Hello World! (seq=456)&lt;br /&gt;
Mon Jul 14 00:16:50 2008   (SCNodeI0.15238 : csa103CompEO.---.---.00069 :   INFO)&lt;br /&gt;
 csa103CompI0: Hello World! (seq=457)&lt;br /&gt;
Mon Jul 14 00:16:51 2008   (SCNodeI0.15238 : csa103CompEO.---.---.00070 :   INFO)&lt;br /&gt;
 csa103CompI0: Hello World! (seq=458)&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
Where we can see CompI1 printing 455 and then dieing, where upon CompI0 gets the notice to take over processing, reads the checkpoint and then takes over with seq=456 and so on.&lt;br /&gt;
&lt;br /&gt;
Then, in the CompI1 log file we see:&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffffaa;&amp;quot; align=&amp;quot;center&amp;quot;| /root/asp/var/log/csa103CompI1Log.latest&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
Mon Jul 14 00:16:49 2008   (SCNodeI0.15553 : csa103CompEO.---.---.00044 :   INFO)&lt;br /&gt;
 csa103: Instantiated as component instance csa103CompI1.&lt;br /&gt;
Mon Jul 14 00:16:49 2008   (SCNodeI0.15553 : csa103CompEO.---.---.00045 :   INFO)&lt;br /&gt;
 csa103CompI1: Waiting for CSI assignment...&lt;br /&gt;
Mon Jul 14 00:16:49 2008   (SCNodeI0.15553 : csa103CompEO.---.---.00046 :   INFO)&lt;br /&gt;
 csa103CompI1: Waiting for CSI assignment...&lt;br /&gt;
Mon Jul 14 00:16:49 2008   (SCNodeI0.15553 : csa103CompEO.---.---.00047 :   INFO)&lt;br /&gt;
 csa103CompI1: checkpoint_initialize&lt;br /&gt;
Mon Jul 14 00:16:50 2008   (SCNodeI0.15553 : csa103CompEO.---.---.00054 :   INFO)&lt;br /&gt;
 csa103CompI1: Checkpoint service initialized (handle=0x1)&lt;br /&gt;
Mon Jul 14 00:16:50 2008   (SCNodeI0.15553 : csa103CompEO.---.---.00056 :   INFO)&lt;br /&gt;
 csa103CompI1: Checkpoint opened (handle=0x2)&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
That is the component that had been killed being restarted.  &lt;br /&gt;
&lt;br /&gt;
CompI0 is moving along just fine, and we see CompI1 come back up.  If we then kill CompI0 we see:&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffffaa;&amp;quot; align=&amp;quot;center&amp;quot;| /root/asp/var/log/csa103CompI1Log.latest&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
Mon Jul 14 00:29:44 2008   (SCNodeI0.15553 : csa103CompEO.---.---.00065 :   INFO)&lt;br /&gt;
 csa103CompI1: Active state requested from state 2&lt;br /&gt;
Mon Jul 14 00:29:44 2008   (SCNodeI0.15553 : csa103CompEO.---.---.00066 :   INFO)&lt;br /&gt;
 csa103CompI1 reading checkpoint&lt;br /&gt;
Mon Jul 14 00:29:44 2008   (SCNodeI0.15553 : csa103CompEO.---.---.00067 :   INFO)&lt;br /&gt;
 csa103CompI1 read checkpoint: seq = 1225&lt;br /&gt;
Mon Jul 14 00:29:45 2008   (SCNodeI0.15553 : csa103CompEO.---.---.00068 :   INFO)&lt;br /&gt;
 csa103CompI1: Hello World! (seq=1225)&lt;br /&gt;
Mon Jul 14 00:29:46 2008   (SCNodeI0.15553 : csa103CompEO.---.---.00069 :   INFO)&lt;br /&gt;
 csa103CompI1: Hello World! (seq=1226)&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
Where we can see the CompI0 process die, and CompI1 process read the sequence number from the checkpoint and then take over from where CompI0 left off.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;To stop csa103 use the following SAFplus Platform Console command.&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
cli[Test:SCNodeI0:CPM]-&amp;gt; amsLockAssignment sg csa103SGI0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;Now change the state of csa103SGI0 to LockInstantiation and close the SAFplus Platform Console.&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
cli[Test:SCNodeI0:CPM]-&amp;gt; amsLockInstantiation sg csa103SGI0&lt;br /&gt;
cli[Test:SCNodeI0:CPM] -&amp;gt; end&lt;br /&gt;
cli[Test:SCNodeI0] -&amp;gt; end&lt;br /&gt;
cli[Test] -&amp;gt; bye&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Additional Tests for Runtime Hardware Setup 1.3 and 2.3===&lt;br /&gt;
&lt;br /&gt;
Now repeat  the experiment till the stage before we kill  the active process  and follow these steps.&lt;br /&gt;
&lt;br /&gt;
'''Step A'''&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Stop SAFplus Platform on SCNodeI0 using &amp;lt;code&amp;gt;/etc/init.d/asp stop&amp;lt;/code&amp;gt;. Observer the logs &amp;lt;code&amp;gt;/root/asp/var/log/csa103CompI3Log.latest&amp;lt;/code&amp;gt; on SCNodeI1. This will become active  and start printing the hello world logs as above. &lt;br /&gt;
Note in this case active System Controller SCNode1 is still aware of PayloadNodeI0 and PayloadNodeI1.&lt;br /&gt;
&amp;lt;li&amp;gt;Start looking at the logs  for &amp;lt;code&amp;gt;/root/asp/var/log/csa103CompI0Log.latest&amp;lt;/code&amp;gt; in PayloadNodeI0. This will print the  standby  logs as  above.&lt;br /&gt;
&amp;lt;li&amp;gt;Stop  SAFplus Platform  on PayloadNodeI0  and start observing the logs on PayloadNodeI1 in &amp;lt;code&amp;gt;/root/asp/var/log/csa103CompI1Log.latest&amp;lt;/code&amp;gt; for standby.&lt;br /&gt;
In this case, you can see, via the active System Controller logs that PayloadNodeI0 is not active whilst PayloadNodeI1 is.&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Step B'''  For Hardware Setup 1.3 only&lt;br /&gt;
#Repeat A  with the slight exception  that the  blade running SCNodeI0  is  yanked out(&amp;lt;code&amp;gt;/etc/init.d/asp zap&amp;lt;/code&amp;gt;) instead of gracefully shutting  down SAFplus Platform in step 1.&lt;br /&gt;
&lt;br /&gt;
===Summary and References===&lt;br /&gt;
We've seen :&lt;br /&gt;
&lt;br /&gt;
*how to use Clovis' checkpoint service to save some program state and recover that state from a separate process&lt;br /&gt;
*how to initialize the client checkpoint library&lt;br /&gt;
*how to create and open checkpoints &lt;br /&gt;
*how to create and use sections in an opened checkpoint&lt;br /&gt;
&lt;br /&gt;
Further information can be found within the following: ''OpenClovis API Reference Guide''.&lt;/div&gt;</summary>
		<author><name>Madhu</name></author>	</entry>

	<entry>
		<id>https://help.openclovis.com/index.php/Doc:latest/evalguide/csa103</id>
		<title>Doc:latest/evalguide/csa103</title>
		<link rel="alternate" type="text/html" href="https://help.openclovis.com/index.php/Doc:latest/evalguide/csa103"/>
				<updated>2010-10-01T04:58:21Z</updated>
		
		<summary type="html">&lt;p&gt;Madhu: /* The Code */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==csa103 Checkpointing==&lt;br /&gt;
&lt;br /&gt;
===Objective===&lt;br /&gt;
&lt;br /&gt;
csa103 demonstrates how to use the Clovis Checkpoint service to provide basic failure recovery.  csa103 builds on csa102.&lt;br /&gt;
&lt;br /&gt;
===What Will You Learn===&lt;br /&gt;
&lt;br /&gt;
*how to initialize the checkpoint client library, &lt;br /&gt;
*how to create a checkpoint and  open a checkpoint, &lt;br /&gt;
*how to create a section in the checkpoint &lt;br /&gt;
*how to save data to the checkpoint section and read data from the checkpoint section.&lt;br /&gt;
&lt;br /&gt;
===The Code===&lt;br /&gt;
&lt;br /&gt;
The code can be found within the following directory&lt;br /&gt;
 &amp;lt;project-area_dir&amp;gt;/eval/src/app/csa103Comp&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffccaa;&amp;quot; align=&amp;quot;center&amp;quot;| clCompAppMain.c&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
ClCompAppInitialize()&lt;br /&gt;
&lt;br /&gt;
        ...&lt;br /&gt;
&lt;br /&gt;
        if ((rc = checkpoint_initialize()) != CL_OK)&lt;br /&gt;
        {&lt;br /&gt;
            clprintf(CL_LOG_SEV_ERROR,&amp;quot;%s: Failed [0x%x] to initialize checkpoint&amp;quot;,&lt;br /&gt;
                    appname, rc);&lt;br /&gt;
            return rc;&lt;br /&gt;
        }&lt;br /&gt;
        if ((rc = checkpoint_read_seq(&amp;amp;seq)) != CL_OK)&lt;br /&gt;
        {&lt;br /&gt;
            clprintf(CL_LOG_SEV_ERROR,&amp;quot;%s: Failed [0x%x] to read checkpoint&amp;quot;,&lt;br /&gt;
                    appname, rc);&lt;br /&gt;
            checkpoint_finalize();&lt;br /&gt;
            return rc;&lt;br /&gt;
        }&lt;br /&gt;
    #ifdef CL_INST&lt;br /&gt;
        if ((rc = clDataTapInit(DATA_TAP_DEFAULT_FLAGS, 103)) != CL_OK)&lt;br /&gt;
        {&lt;br /&gt;
            clprintf(CL_LOG_SEV_ERROR,&amp;quot;%s: Failed [0x%x] to initialize data tap&amp;quot;,&lt;br /&gt;
                    appname, rc);&lt;br /&gt;
        }&lt;br /&gt;
    #endif&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
The above software in &amp;lt;code&amp;gt;clCompAppMain.c&amp;lt;/code&amp;gt; is new to csa103. The call to &amp;lt;code&amp;gt;checkpoint_initialize&amp;lt;/code&amp;gt; is pretty straightforward.  This function discussed in detail later within this section.  The call to &amp;lt;code&amp;gt;checkpoint_read_seq&amp;lt;/code&amp;gt; is also pretty straightforward.  It reads the current sequence value from the checkpoint (at this point it should be zero) and loads it into the variable: &amp;lt;code&amp;gt;seq&amp;lt;/code&amp;gt;.  It is important to note the call to &amp;lt;code&amp;gt;checkpont_finalize&amp;lt;/code&amp;gt; if the call to &amp;lt;code&amp;gt;checkpoint_read_seq&amp;lt;/code&amp;gt; does not return &amp;lt;code&amp;gt;CL_OK&amp;lt;/code&amp;gt;.  This call closes the checkpoint and cleanly finalizes the checkpoint library.  We'll look more at &amp;lt;code&amp;gt;checkpoint_read_seq&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;checkpoint_finalize&amp;lt;/code&amp;gt; later.&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffccaa;&amp;quot; align=&amp;quot;center&amp;quot;| clCompAppMain.c&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
        /* Checkpoint new sequence number */&lt;br /&gt;
        rc = checkpoint_write_seq(seq);&lt;br /&gt;
        if (rc != CL_OK)&lt;br /&gt;
        {&lt;br /&gt;
            clprintf(CL_LOG_SEV_ERROR,&amp;quot;%s: ERROR: Checkpoint write failed. Exiting.&amp;quot;, appname);&lt;br /&gt;
            break;&lt;br /&gt;
        }&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
The rest of the csa103's main loop is the same as the main loop in csa102, but the seven lines above are new.  Here we write the new value of the checkpoint variable to the checkpoint section and print and error if this fails.  We'll look closer at &amp;lt;code&amp;gt;checkpoint_write_seq&amp;lt;/code&amp;gt; later.&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffccaa;&amp;quot; align=&amp;quot;center&amp;quot;| clCompAppMain.c&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
    ClRcT&lt;br /&gt;
    clCompAppAMFCSISet(&lt;br /&gt;
        ClInvocationT       invocation,&lt;br /&gt;
        const ClNameT       *compName,&lt;br /&gt;
        ClAmsHAStateT       haState,&lt;br /&gt;
        ClAmsCSIDescriptorT csiDescriptor)&lt;br /&gt;
    {    &lt;br /&gt;
        /*&lt;br /&gt;
         * ---BEGIN_APPLICATION_CODE--- &lt;br /&gt;
         */&lt;br /&gt;
        ClCharT     compname[100]={0};&lt;br /&gt;
&lt;br /&gt;
        /*&lt;br /&gt;
         * ---END_APPLICATION_CODE---&lt;br /&gt;
         */&lt;br /&gt;
&lt;br /&gt;
        /*&lt;br /&gt;
         * Print information about the CSI Set&lt;br /&gt;
         */&lt;br /&gt;
        strncpy(compname, compName-&amp;gt;value, compName-&amp;gt;length);&lt;br /&gt;
&lt;br /&gt;
        clprintf (CL_LOG_SEV_INFO, &amp;quot;Component [%s] : PID [%d]. CSI Set Received&amp;quot;, &lt;br /&gt;
              compname, (int)mypid);&lt;br /&gt;
&lt;br /&gt;
        clCompAppAMFPrintCSI(csiDescriptor, haState);&lt;br /&gt;
    &lt;br /&gt;
        /*&lt;br /&gt;
          Take appropriate action based on state&lt;br /&gt;
        */&lt;br /&gt;
    &lt;br /&gt;
        switch ( haState )&lt;br /&gt;
        {&lt;br /&gt;
            case CL_AMS_HA_STATE_ACTIVE:&lt;br /&gt;
            {&lt;br /&gt;
                /*&lt;br /&gt;
                  AMF has requested application to take the active HA state&lt;br /&gt;
                  for the CSI.&lt;br /&gt;
                */&lt;br /&gt;
    &lt;br /&gt;
                /*&lt;br /&gt;
                  ---BEGIN_APPLICATION_CODE---&lt;br /&gt;
                */&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffccaa;&amp;quot; align=&amp;quot;center&amp;quot;| clCompAppMain.c&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;   &lt;br /&gt;
                clprintf(CL_LOG_SEV_INFO,&amp;quot;%s: Active state requested from state %d&amp;quot;,&lt;br /&gt;
                        appname, ha_state);&lt;br /&gt;
&lt;br /&gt;
                checkpoint_replica_activate();&lt;br /&gt;
                if (ha_state == SA_AMF_HA_STANDBY)&lt;br /&gt;
                {&lt;br /&gt;
                    /* Read checkpoint, make our replica the active replica */&lt;br /&gt;
                    clprintf(CL_LOG_SEV_INFO,&amp;quot;%s reading checkpoint&amp;quot;, appname);&lt;br /&gt;
                    checkpoint_read_seq(&amp;amp;seq);&lt;br /&gt;
                    clprintf(CL_LOG_SEV_INFO,&amp;quot;%s read checkpoint: seq = %u&amp;quot;, appname, seq);&lt;br /&gt;
                }&lt;br /&gt;
            &lt;br /&gt;
                ha_state = SA_AMF_HA_ACTIVE;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
                /*&lt;br /&gt;
                 * ---END_APPLICATION_CODE---&lt;br /&gt;
                 */&lt;br /&gt;
&lt;br /&gt;
                clCpmResponse(cpmHandle, invocation, CL_OK);&lt;br /&gt;
                break;&lt;br /&gt;
            }&lt;br /&gt;
&lt;br /&gt;
            case CL_AMS_HA_STATE_STANDBY:&lt;br /&gt;
            {&lt;br /&gt;
                /*&lt;br /&gt;
                 * AMF has requested application to take the standby HA state &lt;br /&gt;
                 * for this CSI.&lt;br /&gt;
                 */&lt;br /&gt;
&lt;br /&gt;
                /*&lt;br /&gt;
                 * ---BEGIN_APPLICATION_CODE---&lt;br /&gt;
                 */&lt;br /&gt;
&lt;br /&gt;
                 clprintf(CL_LOG_SEV_INFO,&amp;quot; Standby state requested from state %d&amp;quot;,ha_state);&lt;br /&gt;
            &lt;br /&gt;
                 ha_state = SA_AMF_HA_STANDBY;&lt;br /&gt;
&lt;br /&gt;
                /*&lt;br /&gt;
                 * ---END_APPLICATION_CODE---&lt;br /&gt;
                 */&lt;br /&gt;
&lt;br /&gt;
                clCpmResponse(cpmHandle, invocation, CL_OK);&lt;br /&gt;
                break;&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffccaa;&amp;quot; align=&amp;quot;center&amp;quot;| clCompAppMain.c&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;    &lt;br /&gt;
            case CL_AMS_HA_STATE_QUIESCED:&lt;br /&gt;
            {&lt;br /&gt;
                /*&lt;br /&gt;
                 * AMF has requested application to quiesce the CSI currently&lt;br /&gt;
                 * assigned the active or quiescing HA state. The application &lt;br /&gt;
                 * must stop work associated with the CSI immediately.&lt;br /&gt;
                 */&lt;br /&gt;
&lt;br /&gt;
                /*&lt;br /&gt;
                 * ---BEGIN_APPLICATION_CODE---&lt;br /&gt;
                 */&lt;br /&gt;
&lt;br /&gt;
                clprintf(CL_LOG_SEV_INFO,&amp;quot;%s: QUIESCED&amp;quot;, appname);&lt;br /&gt;
                ha_state = haState;&lt;br /&gt;
&lt;br /&gt;
                /*&lt;br /&gt;
                 * ---END_APPLICATION_CODE---&lt;br /&gt;
                 */&lt;br /&gt;
&lt;br /&gt;
                clCpmResponse(cpmHandle, invocation, CL_OK);&lt;br /&gt;
                break;&lt;br /&gt;
            }&lt;br /&gt;
&lt;br /&gt;
            case CL_AMS_HA_STATE_QUIESCING:&lt;br /&gt;
            { &lt;br /&gt;
                /*&lt;br /&gt;
                 * AMF has requested application to quiesce the CSI currently&lt;br /&gt;
                 * assigned the active HA state. The application must stop work&lt;br /&gt;
                 * associated with the CSI gracefully and not accept any new&lt;br /&gt;
                 * workloads while the work is being terminated.&lt;br /&gt;
                 */&lt;br /&gt;
&lt;br /&gt;
                /*&lt;br /&gt;
                 * ---BEGIN_APPLICATION_CODE---&lt;br /&gt;
                 */&lt;br /&gt;
&lt;br /&gt;
                clprintf(CL_LOG_SEV_INFO,&amp;quot;%s: QUIESCING&amp;quot;, appname);&lt;br /&gt;
                ha_state = haState;&lt;br /&gt;
&lt;br /&gt;
                /*&lt;br /&gt;
                 * ---END_APPLICATION_CODE---&lt;br /&gt;
                 */&lt;br /&gt;
&lt;br /&gt;
                clCpmCSIQuiescingComplete(cpmHandle, invocation, CL_OK);&lt;br /&gt;
                break;&lt;br /&gt;
            }&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffccaa;&amp;quot; align=&amp;quot;center&amp;quot;| clCompAppMain.c&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
            default:&lt;br /&gt;
            {&lt;br /&gt;
                break;&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
    &lt;br /&gt;
        return CL_OK;&lt;br /&gt;
    }&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now looking at csa103's implementation of &amp;lt;code&amp;gt;clCompAppAMFCSISet&amp;lt;/code&amp;gt;, we see that rather than just a few cases, we handle several cases: &amp;lt;code&amp;gt;QUIESCING&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;QUIESCED&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;ACTIVE&amp;lt;/code&amp;gt;, and  &amp;lt;code&amp;gt;STANDBY&amp;lt;/code&amp;gt;.  In each state, the global variable &amp;lt;code&amp;gt;ha_state&amp;lt;/code&amp;gt; to the new_state value that is passed in is set.  This is similar to csa102, except that we add the feature that in the &amp;lt;code&amp;gt;CL_AMS_HA_STATE_ACTIVE&amp;lt;/code&amp;gt; case if our previous state was &amp;lt;code&amp;gt;CL_AMS_HA_STATE_STANDBY&amp;lt;/code&amp;gt; we read the sequence from the checkpoint so that the main loop will pick it up.&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffccaa;&amp;quot; align=&amp;quot;center&amp;quot;| clCompAppMain.c&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
    static ClRcT&lt;br /&gt;
    checkpoint_initialize()&lt;br /&gt;
    {&lt;br /&gt;
        SaAisErrorT      rc = CL_OK;&lt;br /&gt;
        SaVersionT ckpt_version = {'B', 1, 1};&lt;br /&gt;
        SaNameT    ckpt_name = { strlen(CKPT_NAME), CKPT_NAME };&lt;br /&gt;
        ClUint32T  seq_no;&lt;br /&gt;
        SaCkptCheckpointCreationAttributesT create_atts = {&lt;br /&gt;
            .creationFlags     = SA_CKPT_WR_ACTIVE_REPLICA_WEAK |&lt;br /&gt;
                             SA_CKPT_CHECKPOINT_COLLOCATED,&lt;br /&gt;
            .checkpointSize    = sizeof(ClUint32T),&lt;br /&gt;
            .retentionDuration = (ClTimeT)10,&lt;br /&gt;
            .maxSections       = 2, // two sections &lt;br /&gt;
            .maxSectionSize    = sizeof(ClUint32T),&lt;br /&gt;
            .maxSectionIdSize  = (ClSizeT)64&lt;br /&gt;
&lt;br /&gt;
        &lt;br /&gt;
        };&lt;br /&gt;
        SaCkptSectionCreationAttributesT section_atts = {&lt;br /&gt;
        .sectionId = &amp;amp;ckpt_sid,&lt;br /&gt;
        .expirationTime = SA_TIME_END&lt;br /&gt;
&lt;br /&gt;
        };&lt;br /&gt;
 &lt;br /&gt;
        clprintf(CL_LOG_SEV_INFO,&amp;quot;%s: checkpoint_initialize&amp;quot;, appname);&lt;br /&gt;
        /* Initialize checkpointing service instance */&lt;br /&gt;
        rc = saCkptInitialize(&amp;amp;ckpt_svc_handle,	/* Checkpoint service handle */&lt;br /&gt;
						  NULL,			    /* Optional callbacks table */&lt;br /&gt;
						  &amp;amp;ckpt_version);   /* Required verison number */&lt;br /&gt;
        if (rc != SA_AIS_OK)&lt;br /&gt;
        {&lt;br /&gt;
            clprintf(CL_LOG_SEV_ERROR,&amp;quot;%s: ERROR: Failed to initialize checkpoint service&amp;quot;,&lt;br /&gt;
                    appname);&lt;br /&gt;
            return rc;&lt;br /&gt;
        }&lt;br /&gt;
        clprintf(CL_LOG_SEV_INFO,&amp;quot;%s: Checkpoint service initialized (handle=0x%llx)&amp;quot;,&lt;br /&gt;
           appname, ckpt_svc_handle);&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Here is &amp;lt;code&amp;gt;checkpoint_initialize&amp;lt;/code&amp;gt;.  Here we initialize the &amp;lt;code&amp;gt;ClNameT&amp;lt;/code&amp;gt; structure that holds the name of the checkpoint to be opened/created with the line: &amp;lt;code&amp;gt;ClNameT    ckpt_name = { strlen(CKPT_NAME), CKPT_NAME };&amp;lt;/code&amp;gt;. We then define a set of attributes to associate with the checkpoint when creating that checkpoint. The &amp;lt;code&amp;gt;creationFlags&amp;lt;/code&amp;gt; includes &amp;lt;code&amp;gt;CL_CKPT_WR_ACTIVE_REPLICA&amp;lt;/code&amp;gt;.  This means that the checkpoint to be created will be asynchronous, or once active server updation is completed, the call returns to the application, all other replica updates happens parallel. &amp;lt;code&amp;gt;CheckpointSize&amp;lt;/code&amp;gt; is set to the sizeof a 32 bit unsigned integer, which is the sequence number we print in the main loop.  The &amp;lt;code&amp;gt;retentionDuration&amp;lt;/code&amp;gt; is the time that the checkpoint service will keep the checkpoint in store after the last client has closed the checkpoint.  &amp;lt;code&amp;gt;MaxSections&amp;lt;/code&amp;gt; is 2 as this checkpoint will be used to store two sections.  &amp;lt;code&amp;gt;MaxSectionSize&amp;lt;/code&amp;gt; is the set to the sizeof a 32 bit unsigned integer, as application stores only unsigned integer. And &amp;lt;code&amp;gt;maxSectionIdSize&amp;lt;/code&amp;gt; is 64 bytes.&lt;br /&gt;
&lt;br /&gt;
We next use &amp;lt;code&amp;gt;ClCkptSectionCreationAttributesT section_atts&amp;lt;/code&amp;gt; to define the creation attributes for the sole section of the checkpoint. The &amp;lt;code&amp;gt;sectionId&amp;lt;/code&amp;gt; is just the name of the section along with the number of bytes in the name.  The &amp;lt;code&amp;gt;expirationTime&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;CL_TIME_END&amp;lt;/code&amp;gt; to imply that the section is never deleted automatically if the checkpoint itself still remains.&lt;br /&gt;
&lt;br /&gt;
The call to &amp;lt;code&amp;gt;clCkptInitialize&amp;lt;/code&amp;gt; has to be called before any other checkpoint functions.  The &amp;lt;code&amp;gt;ckpt_svc_handle&amp;lt;/code&amp;gt; is where the handle is returned.  The handle must be passed to some future checkpoint api calls, namely the &amp;lt;code&amp;gt;clCkptCheckpointOpen&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;clCkptFinalize&amp;lt;/code&amp;gt; calls.  The callbacks table is passed as &amp;lt;code&amp;gt;NULL&amp;lt;/code&amp;gt; which implies that our application doesn't provide any callbacks.  Finally the &amp;lt;code&amp;gt;ckpt_version&amp;lt;/code&amp;gt; identifies what version of the api this application is written to.&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffccaa;&amp;quot; align=&amp;quot;center&amp;quot;| clCompAppMain.c&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
        //&lt;br /&gt;
        // Create the checkpoint for read and write.            &lt;br /&gt;
&lt;br /&gt;
        rc = saCkptCheckpointOpen(ckpt_svc_handle,      // Service handle&lt;br /&gt;
                              &amp;amp;ckpt_name,         // Checkpoint name&lt;br /&gt;
                              &amp;amp;create_atts,       // Optional creation attr.&lt;br /&gt;
                              (SA_CKPT_CHECKPOINT_READ |&lt;br /&gt;
                               SA_CKPT_CHECKPOINT_WRITE |&lt;br /&gt;
                               SA_CKPT_CHECKPOINT_CREATE),&lt;br /&gt;
                              (SaTimeT)-1,        // No timeout&lt;br /&gt;
                              &amp;amp;ckpt_handle);      // Checkpoint handle&lt;br /&gt;
&lt;br /&gt;
        if (rc != SA_AIS_OK)&lt;br /&gt;
&lt;br /&gt;
        {&lt;br /&gt;
            clprintf(CL_LOG_SEV_ERROR,&amp;quot;%s: ERROR: Failed [0x%x] to open checkpoint&amp;quot;,&lt;br /&gt;
                    appname, rc);&lt;br /&gt;
            (void)saCkptFinalize(ckpt_svc_handle);&lt;br /&gt;
            return rc;&lt;br /&gt;
        }&lt;br /&gt;
        clprintf(CL_LOG_SEV_INFO,&amp;quot;%s: Checkpoint opened (handle=0x%llx)&amp;quot;, appname, ckpt_handle);&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
 &lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffccaa;&amp;quot; align=&amp;quot;center&amp;quot;| clCompAppMain.c&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
        /*&lt;br /&gt;
         * Try to create a section so that updates can operate by overwriting&lt;br /&gt;
         * the section over and over again.&lt;br /&gt;
         * If subsequent processes come through here, they will fail to create&lt;br /&gt;
         * the section.  That is OK, even though it will cause an error message&lt;br /&gt;
         * If the section create fails because the section is already there, then&lt;br /&gt;
         * read the sequence number&lt;br /&gt;
         */&lt;br /&gt;
        // Put data in network byte order&lt;br /&gt;
        seq_no = htonl(seq);&lt;br /&gt;
&lt;br /&gt;
        // Creating the section&lt;br /&gt;
        checkpoint_replica_activate();&lt;br /&gt;
        rc = saCkptSectionCreate(ckpt_handle,           // Checkpoint handle&lt;br /&gt;
                             &amp;amp;section_atts,         // Section attributes&lt;br /&gt;
                             (SaUint8T*)&amp;amp;seq_no,    // Initial data&lt;br /&gt;
                             (SaSizeT)sizeof(seq_no)); // Size of data&lt;br /&gt;
        if (rc != SA_AIS_OK &amp;amp;&amp;amp; (CL_GET_ERROR_CODE(rc) != SA_AIS_ERR_EXIST))&lt;br /&gt;
        {&lt;br /&gt;
            clprintf(CL_LOG_SEV_ERROR,&amp;quot;%s: ERROR: Failed to create checkpoint section&amp;quot;, appname);&lt;br /&gt;
            (void)saCkptCheckpointClose(ckpt_handle);&lt;br /&gt;
            (void)saCkptFinalize(ckpt_svc_handle);&lt;br /&gt;
            return rc;&lt;br /&gt;
        }&lt;br /&gt;
        else if (rc != SA_AIS_OK &amp;amp;&amp;amp; (CL_GET_ERROR_CODE(rc) == SA_AIS_ERR_EXIST))&lt;br /&gt;
        {&lt;br /&gt;
            rc = checkpoint_read_seq(&amp;amp;seq);&lt;br /&gt;
            if (rc != CL_OK)&lt;br /&gt;
            {&lt;br /&gt;
                clprintf(CL_LOG_SEV_ERROR,&amp;quot;%s: ERROR: Failed [0x%x] to read checkpoint section&amp;quot;,&lt;br /&gt;
                            appname, rc);&lt;br /&gt;
                (void)saCkptCheckpointClose(ckpt_handle);&lt;br /&gt;
                (void)saCkptFinalize(ckpt_svc_handle);&lt;br /&gt;
                return rc;&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
        else&lt;br /&gt;
        {&lt;br /&gt;
            clprintf(CL_LOG_SEV_INFO,&amp;quot;%s: Section created&amp;quot;, appname);&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        return CL_OK;&lt;br /&gt;
    }&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
With &amp;lt;code&amp;gt;rc = clCkptCheckpointOpen&amp;lt;/code&amp;gt; we attempt to open the specified checkpoint.  When &amp;lt;code&amp;gt;checkpoint_initialize&amp;lt;/code&amp;gt; is called the checkpoint may or may not exist.  We attempt to open the checkpoint for READ/WRITE access. &lt;br /&gt;
&lt;br /&gt;
Next we check if we created the checkpoint and then we need to create the section with a call to &amp;lt;code&amp;gt;clCkptSectionCreate&amp;lt;/code&amp;gt;.  We pass the checkpoint handle obtained from &amp;lt;code&amp;gt;clCkptCheckpointOpen&amp;lt;/code&amp;gt;, the section attributes declared earlier, and the address of the initial value along with the size in bytes of the initial value.&lt;br /&gt;
&lt;br /&gt;
We convert the initial value to network byte order by the code &amp;lt;code&amp;gt;seq_no = htonl(seq)&amp;lt;/code&amp;gt;, before passing it to &amp;lt;code&amp;gt;clCkptSectionCreate&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If we do not create the section, then we read the current value in the checkpoint into our global seq variable.&lt;br /&gt;
&lt;br /&gt;
Note that whenever we return an error return code from the function that we have either not opened the checkpoint/initialized the checkpoint service, or we have closed the checkpoint and finalized the checkpoint service with calls to &amp;lt;code&amp;gt;clCkptCheckpointClose&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;clCkptFinalize&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffccaa;&amp;quot; align=&amp;quot;center&amp;quot;| clCompAppMain.c&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
    static ClRcT &lt;br /&gt;
    checkpoint_finalize(void)&lt;br /&gt;
    {&lt;br /&gt;
        SaAisErrorT rc;&lt;br /&gt;
&lt;br /&gt;
        rc = saCkptCheckpointClose(ckpt_handle);&lt;br /&gt;
        if (rc != SA_AIS_OK)&lt;br /&gt;
        {&lt;br /&gt;
            clprintf(CL_LOG_SEV_ERROR,&amp;quot;%s: failed: [0x%x] to close checkpoint handle 0x%llx&amp;quot;,&lt;br /&gt;
                        appname, rc, ckpt_handle);&lt;br /&gt;
        }&lt;br /&gt;
        rc = saCkptFinalize(ckpt_svc_handle);&lt;br /&gt;
        if (rc != SA_AIS_OK)&lt;br /&gt;
        {&lt;br /&gt;
            clprintf(CL_LOG_SEV_ERROR,&amp;quot;%s: failed: [0x%x] to finalize checkpoint&amp;quot;,&lt;br /&gt;
                    appname, rc);&lt;br /&gt;
        }&lt;br /&gt;
        return CL_OK;&lt;br /&gt;
&lt;br /&gt;
    }&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
The above code snippet presents &amp;lt;code&amp;gt;checkpoint_finalize&amp;lt;/code&amp;gt;.  It's quite simple.  First it closes the checkpoint handle with a call to &amp;lt;code&amp;gt;clCkptCheckpointClose&amp;lt;/code&amp;gt;.  Next it finalizes the checkpoint library with a call to &amp;lt;code&amp;gt;clCkptFinalize&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffccaa;&amp;quot; align=&amp;quot;center&amp;quot;| clCompAppMain.c&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
    static ClRcT&lt;br /&gt;
    checkpoint_write_seq(ClUint32T seq)&lt;br /&gt;
    {&lt;br /&gt;
        SaAisErrorT rc = SA_AIS_OK;&lt;br /&gt;
        ClUint32T seq_no;&lt;br /&gt;
&lt;br /&gt;
        /* Putting data in network byte order */&lt;br /&gt;
        seq_no = htonl(seq);&lt;br /&gt;
&lt;br /&gt;
        /* Write checkpoint */&lt;br /&gt;
        retry:&lt;br /&gt;
        rc = saCkptSectionOverwrite(ckpt_handle,&lt;br /&gt;
                                &amp;amp;ckpt_sid,&lt;br /&gt;
                                &amp;amp;seq_no,&lt;br /&gt;
                                sizeof(ClUint32T));&lt;br /&gt;
        if (rc != SA_AIS_OK)&lt;br /&gt;
        {&lt;br /&gt;
            clprintf(CL_LOG_SEV_ERROR,&amp;quot;Failed [0x%x] to write to section&amp;quot;, rc);&lt;br /&gt;
            if(rc == SA_AIS_ERR_NOT_EXIST)&lt;br /&gt;
                rc = checkpoint_replica_activate();&lt;br /&gt;
            if(rc == CL_OK) goto retry;&lt;br /&gt;
        }&lt;br /&gt;
        else&lt;br /&gt;
        {&lt;br /&gt;
            /*&lt;br /&gt;
            * Synchronize the checkpoint to all the replicas.&lt;br /&gt;
            */&lt;br /&gt;
            rc = saCkptCheckpointSynchronize(ckpt_handle, SA_TIME_END );&lt;br /&gt;
            if (rc != SA_AIS_OK)&lt;br /&gt;
            {&lt;br /&gt;
                clprintf(CL_LOG_SEV_ERROR,&amp;quot;Failed [0x%x] to synchronize the checkpoint&amp;quot;, rc);&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        return CL_OK;&lt;br /&gt;
     }&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
With &amp;lt;code&amp;gt;checkpoint_write_seq&amp;lt;/code&amp;gt; we first convert the sequence number passed into network byte order.  Then we pass it to &amp;lt;code&amp;gt;clCKptSectionOverwrite&amp;lt;/code&amp;gt; which writes it to the checkpoint section created in &amp;lt;code&amp;gt;checkpoint_initialize&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffccaa;&amp;quot; align=&amp;quot;center&amp;quot;| clCompAppMain.c&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
    static ClRcT&lt;br /&gt;
    checkpoint_read_seq(ClUint32T *seq)&lt;br /&gt;
    {&lt;br /&gt;
        ClRcT rc = CL_OK;&lt;br /&gt;
        ClUint32T err_idx; /* Error index in ioVector */&lt;br /&gt;
        ClUint32T seq_no = 0xffffffff;&lt;br /&gt;
        SaCkptIOVectorElementT iov = {&lt;br /&gt;
            .sectionId  = ckpt_sid,&lt;br /&gt;
            .dataBuffer = (ClPtrT)&amp;amp;seq_no,&lt;br /&gt;
            .dataSize   = sizeof(ClUint32T),&lt;br /&gt;
            .dataOffset = (ClOffsetT)0,&lt;br /&gt;
            .readSize   = sizeof(ClUint32T)&lt;br /&gt;
        };&lt;br /&gt;
&lt;br /&gt;
        rc = saCkptCheckpointRead(ckpt_handle, &amp;amp;iov, 1, &amp;amp;err_idx);&lt;br /&gt;
        if (rc != SA_AIS_OK)&lt;br /&gt;
        {&lt;br /&gt;
           clprintf(CL_LOG_SEV_ERROR,&amp;quot;Error: [0x%x] from checkpoint read, err_idx = %u&amp;quot;,&lt;br /&gt;
                    rc, err_idx);&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        /* FIXME: How to process this err_idx? */&lt;br /&gt;
        *seq = ntohl(seq_no);&lt;br /&gt;
&lt;br /&gt;
        return CL_OK;&lt;br /&gt;
&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
With &amp;lt;code&amp;gt;checkpoint_read_seq&amp;lt;/code&amp;gt; we initialize &amp;lt;code&amp;gt;seq_no&amp;lt;/code&amp;gt; to all ones just so it will be more obvious if the &amp;lt;code&amp;gt;clCkptCheckpointRead&amp;lt;/code&amp;gt; call fails and the value of &amp;lt;code&amp;gt;seq_no&amp;lt;/code&amp;gt; doesn't get overwritten.  Then, we set up the &amp;lt;code&amp;gt;iov&amp;lt;/code&amp;gt; variable.  We set the &amp;lt;code&amp;gt;sectionID&amp;lt;/code&amp;gt;  field to &amp;lt;code&amp;gt;ckpt_sid&amp;lt;/code&amp;gt; which is the id of the section created in &amp;lt;code&amp;gt;checkpoint_initialize&amp;lt;/code&amp;gt;.  The &amp;lt;code&amp;gt;dataBuffer&amp;lt;/code&amp;gt; gets set to the address of the &amp;lt;code&amp;gt;seq_no&amp;lt;/code&amp;gt; variable which is where we want the checkpoint data loaded.  The &amp;lt;code&amp;gt;dataSize&amp;lt;/code&amp;gt; field is set to the the size of the &amp;lt;code&amp;gt;seq_no&amp;lt;/code&amp;gt; variable.  &amp;lt;code&amp;gt;DataOfset&amp;lt;/code&amp;gt; is set to zero since the sequence number is the only thing stored in the section, so it resides at the front of the section.  &amp;lt;code&amp;gt;readSize&amp;lt;/code&amp;gt; is set to the size of the sequence number variable.&lt;br /&gt;
&lt;br /&gt;
Within &amp;lt;code&amp;gt;checkpoint_read_seq&amp;lt;/code&amp;gt; we pass the iovector to &amp;lt;code&amp;gt;clCkptCheckpointRead&amp;lt;/code&amp;gt; along with the &amp;lt;code&amp;gt;ckpt_handle&amp;lt;/code&amp;gt;, the constant 1, and the address of the &amp;lt;code&amp;gt;err_idx&amp;lt;/code&amp;gt; variable.  The constant 1 is the number of elements in the array of &amp;lt;code&amp;gt;ClCkptIOVectorElementT structs&amp;lt;/code&amp;gt; that we're passing.  That is, we're passing the address of a single &amp;lt;code&amp;gt;ClCkptIOVectorElementT struct&amp;lt;/code&amp;gt;.  The &amp;lt;code&amp;gt;err_idx&amp;lt;/code&amp;gt; will hold the index in that array where &amp;lt;code&amp;gt;clCkptCheckpointRead&amp;lt;/code&amp;gt; found an error.  That is, if there is going to be an error, it will be at index 0 since we're only passing on entry in the &amp;lt;code&amp;gt;iovector&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
static ClRcT&lt;br /&gt;
checkpoint_replica_activate(void)&lt;br /&gt;
{&lt;br /&gt;
    SaAisErrorT rc = SA_AIS_OK;&lt;br /&gt;
&lt;br /&gt;
    if ((rc = saCkptActiveReplicaSet(ckpt_handle)) != SA_AIS_OK)&lt;br /&gt;
    {&lt;br /&gt;
        clprintf(CL_LOG_SEV_ERROR,&lt;br /&gt;
                &amp;quot;checkpoint_replica_activate failed [0x%x] in ActiveReplicaSet&amp;quot;,&lt;br /&gt;
                rc);&lt;br /&gt;
    }&lt;br /&gt;
    else rc = CL_OK;&lt;br /&gt;
&lt;br /&gt;
    return rc;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
===csa203===&lt;br /&gt;
&lt;br /&gt;
csa203 demonstrates the usage of SA Forum's Checkpointing service. This sample application does not deviate functionally from csa103. The code differences are due to using SA Forum data types (structures) and APIs , as presented in the following two tables. (Note we have not repeated data types and APIs covered previously.)&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|+align=&amp;quot;bottom&amp;quot;| '''SA Forum Data Types with the SAFplus Platform equivalent'''&lt;br /&gt;
|- style=&amp;quot;color:black;background-color:#ffffaa;&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
!SA Forum Data Types   &lt;br /&gt;
!OpenClovis Data Types&lt;br /&gt;
|-&lt;br /&gt;
|SaCkptHandleT&lt;br /&gt;
|ClCkptSvcHdlT&lt;br /&gt;
|-&lt;br /&gt;
|SaCkptHandleT&lt;br /&gt;
|ClCkptHdlT&lt;br /&gt;
|-&lt;br /&gt;
|SaCkptSectionIdT&lt;br /&gt;
|ClCkptSectionIdT&lt;br /&gt;
|-&lt;br /&gt;
|SaCkptCheckpointCreationAttributesT&lt;br /&gt;
|ClCkptCheckpointCreationAttributesT&lt;br /&gt;
|-&lt;br /&gt;
|SaCkptSectionCreationAttributesT&lt;br /&gt;
|ClCkptSectionCreationAttributesT&lt;br /&gt;
|-&lt;br /&gt;
|SaCkptIOVectorElementT&lt;br /&gt;
|ClCkptIOVectorElementT&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|+align=&amp;quot;bottom&amp;quot;| '''SA Forum APIs with the SAFplus Platform equivalent'''&lt;br /&gt;
|- style=&amp;quot;color:black;background-color:#ffffaa;&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
!SA Forum APIs&lt;br /&gt;
!OpenClovis APIs&lt;br /&gt;
|-&lt;br /&gt;
|saCkptInitialize&lt;br /&gt;
|clCkptInitialize&lt;br /&gt;
|-&lt;br /&gt;
|saCkptCheckpointOpen&lt;br /&gt;
|clCkptCheckpointOpen&lt;br /&gt;
|-&lt;br /&gt;
|saCkptSectionCreate&lt;br /&gt;
|clCkptSectionCreate&lt;br /&gt;
|-&lt;br /&gt;
|saCkptCheckpointClose&lt;br /&gt;
|clCkptCheckpointClose&lt;br /&gt;
|-&lt;br /&gt;
|saCkptFinalize&lt;br /&gt;
|clCkptFinalize&lt;br /&gt;
|-&lt;br /&gt;
|saCkptSectionOverwrite&lt;br /&gt;
|clCkptSectionOverwrite&lt;br /&gt;
|-&lt;br /&gt;
|saCkptCheckpointSynchronize&lt;br /&gt;
|clCkptCheckpointSynchronize&lt;br /&gt;
|-&lt;br /&gt;
|saCkptCheckpointRead&lt;br /&gt;
|clCkptCheckpointRead&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===How to Run csa103 and What to Observe===&lt;br /&gt;
&lt;br /&gt;
This sample application can run on all Runtime Hardware Setups. The following, lists which node &amp;lt;code&amp;gt;csa103compI*&amp;lt;/code&amp;gt; runs on.&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;'''Runtime Hardware Setup 1.1 and 2.1'''&lt;br /&gt;
&amp;lt;br&amp;gt;csa103compI0 and csa103compI1 will run upon the single node.&lt;br /&gt;
&amp;lt;li&amp;gt;'''Runtime Hardware Setup 1.2 and 2.2'''&lt;br /&gt;
&amp;lt;br&amp;gt;csa103compI0 runs on PayloadNodeI0 and csa103compI1 runs on PayloadNodeI1&lt;br /&gt;
&amp;lt;li&amp;gt;'''Runtime Hardware Setup 1.3 and 2.3'''&lt;br /&gt;
&amp;lt;br&amp;gt;csa103compI2 and csa103compI3 run on SCNodeI0 and SCNodeI1 respectively. csa103compI0 and csa103compI1 run on PayloadNodeI0 and PayloadNodeI1 respectively.&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;In the four node set up SCNodeI0 and SCNodeI1 output data via &amp;lt;code&amp;gt;/root/asp/var/log/csa103CompI2&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;/root/asp/var/log/csa103CompI3&amp;lt;/code&amp;gt; respectively. Therefore in this case follow the below instructions replacing csa103CompI0 and csa103compI1 with csa103compI2 and csa103compI3 respectively.&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We run csa103 very much the same way we run any of the rest of the sample applications: with the SAFplus Platform Console.&lt;br /&gt;
  &lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;First, on the active System Controller move it to state LockAssignment with (Unlock csa203SGI0 instead of csa103SGI0 to run csa203)&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
cli[Test]-&amp;gt; setc 1&lt;br /&gt;
cli[Test:SCNodeI0]-&amp;gt; setc cpm&lt;br /&gt;
cli[Test:SCNodeI0:CPM]-&amp;gt; amsLockAssignment sg csa103SGI0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The following output is given when you run &amp;lt;code&amp;gt;tail -f&amp;lt;/code&amp;gt; on the csa103 log files. For example:&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
# tail -f /root/asp/var/log/csa103CompI0.log&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffffaa;&amp;quot; align=&amp;quot;center&amp;quot;| /root/asp/var/log/csa103CompI0Log.latest&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
Mon Jul 14 00:01:09 2008   (SCNodeI0.15238 : csa103CompEO.---.---.00030 :   INFO)&lt;br /&gt;
 Component [csa103CompI0] : PID [15238]. Initializing&lt;br /&gt;
Mon Jul 14 00:01:09 2008   (SCNodeI0.15238 : csa103CompEO.---.---.00031 :   INFO)&lt;br /&gt;
    IOC Address             : 0x1&lt;br /&gt;
Mon Jul 14 00:01:09 2008   (SCNodeI0.15238 : csa103CompEO.---.---.00032 :   INFO)&lt;br /&gt;
    IOC Port                : 0x81&lt;br /&gt;
Mon Jul 14 00:01:09 2008   (SCNodeI0.15238 : csa103CompEO.---.---.00033 :   INFO)&lt;br /&gt;
 csa103: Instantiated as component instance csa103CompI0.&lt;br /&gt;
Mon Jul 14 00:01:09 2008   (SCNodeI0.15238 : csa103CompEO.---.---.00034 :   INFO)&lt;br /&gt;
 csa103CompI0: Waiting for CSI assignment...&lt;br /&gt;
Mon Jul 14 00:01:09 2008   (SCNodeI0.15238 : csa103CompEO.---.---.00035 :   INFO)&lt;br /&gt;
 csa103CompI0: Waiting for CSI assignment...&lt;br /&gt;
Mon Jul 14 00:01:09 2008   (SCNodeI0.15238 : csa103CompEO.---.---.00036 :   INFO)&lt;br /&gt;
 csa103CompI0: checkpoint_initialize&lt;br /&gt;
Mon Jul 14 00:01:10 2008   (SCNodeI0.15238 : csa103CompEO.---.---.00043 :   INFO)&lt;br /&gt;
 csa103CompI0: Checkpoint service initialized (handle=0x1)&lt;br /&gt;
Mon Jul 14 00:01:10 2008   (SCNodeI0.15238 : csa103CompEO.---.---.00045 :   INFO)&lt;br /&gt;
 csa103CompI0: Checkpoint opened (handle=0x2)&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
# tail -f /root/asp/var/log/csa103CompI1.log&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffffaa;&amp;quot; align=&amp;quot;center&amp;quot;| /root/asp/var/log/csa103CompI1Log.latest&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
Mon Jul 14 00:01:09 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00030 :   INFO)&lt;br /&gt;
 Component [csa103CompI1] : PID [15234]. Initializing&lt;br /&gt;
Mon Jul 14 00:01:09 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00031 :   INFO)&lt;br /&gt;
    IOC Address             : 0x1&lt;br /&gt;
Mon Jul 14 00:01:09 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00032 :   INFO)&lt;br /&gt;
    IOC Port                : 0x80&lt;br /&gt;
Mon Jul 14 00:01:09 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00033 :   INFO)&lt;br /&gt;
 csa103: Instantiated as component instance csa103CompI1.&lt;br /&gt;
Mon Jul 14 00:01:09 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00034 :   INFO)&lt;br /&gt;
 csa103CompI1: Waiting for CSI assignment...&lt;br /&gt;
Mon Jul 14 00:01:09 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00035 :   INFO)&lt;br /&gt;
 csa103CompI1: Waiting for CSI assignment...&lt;br /&gt;
Mon Jul 14 00:01:09 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00036 :   INFO)&lt;br /&gt;
 csa103CompI1: checkpoint_initialize&lt;br /&gt;
Mon Jul 14 00:01:09 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00043 :   INFO)&lt;br /&gt;
 csa103CompI1: Checkpoint service initialized (handle=0x1)&lt;br /&gt;
Mon Jul 14 00:01:09 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00045 :   INFO)&lt;br /&gt;
 csa103CompI1: Checkpoint opened (handle=0x2)&lt;br /&gt;
Mon Jul 14 00:01:09 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00053 :   INFO)&lt;br /&gt;
 csa103CompI1: Section created&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;Then, unlock the application by running &lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
cli[Test:SCNodeI0:CPM]-&amp;gt; amsUnlock sg csa103SGI0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the application log files, you should see &lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffffaa;&amp;quot; align=&amp;quot;center&amp;quot;| /root/asp/var/log/csa103CompI0Log.latest&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
Mon Jul 14 00:09:08 2008   (SCNodeI0.15238 : csa103CompEO.---.---.00058 :   INFO)&lt;br /&gt;
  Standby state requested from state 0&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffffaa;&amp;quot; align=&amp;quot;center&amp;quot;| /root/asp/var/log/csa103CompI1Log.latest&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
Mon Jul 14 00:09:08 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00064 :   INFO)&lt;br /&gt;
 csa103CompI1: Active state requested from state 0&lt;br /&gt;
Mon Jul 14 00:09:09 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00065 :   INFO)&lt;br /&gt;
 csa103CompI1: Hello World! (seq=0)&lt;br /&gt;
Mon Jul 14 00:09:10 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00066 :   INFO)&lt;br /&gt;
 csa103CompI1: Hello World! (seq=1)&lt;br /&gt;
Mon Jul 14 00:09:11 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00067 :   INFO)&lt;br /&gt;
 csa103CompI1: Hello World! (seq=2)&lt;br /&gt;
Mon Jul 14 00:09:12 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00068 :   INFO)&lt;br /&gt;
 csa103CompI1: Hello World! (seq=3)&lt;br /&gt;
Mon Jul 14 00:09:13 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00069 :   INFO)&lt;br /&gt;
 csa103CompI1: Hello World! (seq=4)&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;Next, find the active csa103 process, the one that's printing the Hello World lines and kill it.  To find the process ID issue the following command from a bash shell.&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
 # ps -eaf | grep csa103&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
This should produce an output that looks similar to the following.&lt;br /&gt;
 root     17830 15663  0 14:21 ?        00:00:00 csa103Comp -p&lt;br /&gt;
 root     17839 15663  0 14:21 ?        00:00:00 csa103Comp -p&lt;br /&gt;
 root     18558 16145  0 14:32 pts/4    00:00:00 grep csa103&lt;br /&gt;
Notice the two entries that end with csa103Comp -p. These are our two component processes. The first one is usually the active process. This is the one that we will kill. In this case the process ID is 17830. So to kill the active component you issue the command:&lt;br /&gt;
&lt;br /&gt;
 # kill -9 17830&lt;br /&gt;
&lt;br /&gt;
[[File:OpenClovis_Note.png]]If this step does not result in the active component being killed then it is likely that the standby component was killed. In this case simply try killing the other process. &lt;br /&gt;
&lt;br /&gt;
After killing the active component you should see lines in the log files like the following:&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffffaa;&amp;quot; align=&amp;quot;center&amp;quot;| /root/asp/var/log/csa103CompI1Log.latest&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
Mon Jul 14 00:16:43 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00515 :   INFO)&lt;br /&gt;
 csa103CompI1: Hello World! (seq=452)&lt;br /&gt;
Mon Jul 14 00:16:44 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00516 :   INFO)&lt;br /&gt;
 csa103CompI1: Hello World! (seq=453)&lt;br /&gt;
Mon Jul 14 00:16:45 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00517 :   INFO)&lt;br /&gt;
 csa103CompI1: Hello World! (seq=454)&lt;br /&gt;
Mon Jul 14 00:16:46 2008   (SCNodeI0.15234 : csa103CompEO.---.---.00518 :   INFO)&lt;br /&gt;
 csa103CompI1: Hello World! (seq=455)&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffffaa;&amp;quot; align=&amp;quot;center&amp;quot;| /var/log/csa103CompI0Log.latest&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
Mon Jul 14 00:16:48 2008   (SCNodeI0.15238 : csa103CompEO.---.---.00065 :   INFO)&lt;br /&gt;
 csa103CompI0: Active state requested from state 2&lt;br /&gt;
Mon Jul 14 00:16:48 2008   (SCNodeI0.15238 : csa103CompEO.---.---.00066 :   INFO)&lt;br /&gt;
 csa103CompI0 reading checkpoint&lt;br /&gt;
Mon Jul 14 00:16:48 2008   (SCNodeI0.15238 : csa103CompEO.---.---.00067 :   INFO)&lt;br /&gt;
 csa103CompI0 read checkpoint: seq = 456&lt;br /&gt;
Mon Jul 14 00:16:49 2008   (SCNodeI0.15238 : csa103CompEO.---.---.00068 :   INFO)&lt;br /&gt;
 csa103CompI0: Hello World! (seq=456)&lt;br /&gt;
Mon Jul 14 00:16:50 2008   (SCNodeI0.15238 : csa103CompEO.---.---.00069 :   INFO)&lt;br /&gt;
 csa103CompI0: Hello World! (seq=457)&lt;br /&gt;
Mon Jul 14 00:16:51 2008   (SCNodeI0.15238 : csa103CompEO.---.---.00070 :   INFO)&lt;br /&gt;
 csa103CompI0: Hello World! (seq=458)&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
Where we can see CompI1 printing 455 and then dieing, where upon CompI0 gets the notice to take over processing, reads the checkpoint and then takes over with seq=456 and so on.&lt;br /&gt;
&lt;br /&gt;
Then, in the CompI1 log file we see:&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffffaa;&amp;quot; align=&amp;quot;center&amp;quot;| /root/asp/var/log/csa103CompI1Log.latest&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
Mon Jul 14 00:16:49 2008   (SCNodeI0.15553 : csa103CompEO.---.---.00044 :   INFO)&lt;br /&gt;
 csa103: Instantiated as component instance csa103CompI1.&lt;br /&gt;
Mon Jul 14 00:16:49 2008   (SCNodeI0.15553 : csa103CompEO.---.---.00045 :   INFO)&lt;br /&gt;
 csa103CompI1: Waiting for CSI assignment...&lt;br /&gt;
Mon Jul 14 00:16:49 2008   (SCNodeI0.15553 : csa103CompEO.---.---.00046 :   INFO)&lt;br /&gt;
 csa103CompI1: Waiting for CSI assignment...&lt;br /&gt;
Mon Jul 14 00:16:49 2008   (SCNodeI0.15553 : csa103CompEO.---.---.00047 :   INFO)&lt;br /&gt;
 csa103CompI1: checkpoint_initialize&lt;br /&gt;
Mon Jul 14 00:16:50 2008   (SCNodeI0.15553 : csa103CompEO.---.---.00054 :   INFO)&lt;br /&gt;
 csa103CompI1: Checkpoint service initialized (handle=0x1)&lt;br /&gt;
Mon Jul 14 00:16:50 2008   (SCNodeI0.15553 : csa103CompEO.---.---.00056 :   INFO)&lt;br /&gt;
 csa103CompI1: Checkpoint opened (handle=0x2)&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
That is the component that had been killed being restarted.  &lt;br /&gt;
&lt;br /&gt;
CompI0 is moving along just fine, and we see CompI1 come back up.  If we then kill CompI0 we see:&lt;br /&gt;
&lt;br /&gt;
{| cellspacing=&amp;quot;0&amp;quot; cellpadding = &amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot; align = &amp;quot;center&amp;quot; width=&amp;quot;680&amp;quot;&lt;br /&gt;
 ! style=&amp;quot;color:black;background-color:#ffffaa;&amp;quot; align=&amp;quot;center&amp;quot;| /root/asp/var/log/csa103CompI1Log.latest&lt;br /&gt;
 |- &lt;br /&gt;
 |&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
Mon Jul 14 00:29:44 2008   (SCNodeI0.15553 : csa103CompEO.---.---.00065 :   INFO)&lt;br /&gt;
 csa103CompI1: Active state requested from state 2&lt;br /&gt;
Mon Jul 14 00:29:44 2008   (SCNodeI0.15553 : csa103CompEO.---.---.00066 :   INFO)&lt;br /&gt;
 csa103CompI1 reading checkpoint&lt;br /&gt;
Mon Jul 14 00:29:44 2008   (SCNodeI0.15553 : csa103CompEO.---.---.00067 :   INFO)&lt;br /&gt;
 csa103CompI1 read checkpoint: seq = 1225&lt;br /&gt;
Mon Jul 14 00:29:45 2008   (SCNodeI0.15553 : csa103CompEO.---.---.00068 :   INFO)&lt;br /&gt;
 csa103CompI1: Hello World! (seq=1225)&lt;br /&gt;
Mon Jul 14 00:29:46 2008   (SCNodeI0.15553 : csa103CompEO.---.---.00069 :   INFO)&lt;br /&gt;
 csa103CompI1: Hello World! (seq=1226)&lt;br /&gt;
  &amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
Where we can see the CompI0 process die, and CompI1 process read the sequence number from the checkpoint and then take over from where CompI0 left off.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;To stop csa103 use the following SAFplus Platform Console command.&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
cli[Test:SCNodeI0:CPM]-&amp;gt; amsLockAssignment sg csa103SGI0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;Now change the state of csa103SGI0 to LockInstantiation and close the SAFplus Platform Console.&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
cli[Test:SCNodeI0:CPM]-&amp;gt; amsLockInstantiation sg csa103SGI0&lt;br /&gt;
cli[Test:SCNodeI0:CPM] -&amp;gt; end&lt;br /&gt;
cli[Test:SCNodeI0] -&amp;gt; end&lt;br /&gt;
cli[Test] -&amp;gt; bye&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Additional Tests for Runtime Hardware Setup 1.3 and 2.3===&lt;br /&gt;
&lt;br /&gt;
Now repeat  the experiment till the stage before we kill  the active process  and follow these steps.&lt;br /&gt;
&lt;br /&gt;
'''Step A'''&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Stop SAFplus Platform on SCNodeI0 using &amp;lt;code&amp;gt;/etc/init.d/asp stop&amp;lt;/code&amp;gt;. Observer the logs &amp;lt;code&amp;gt;/root/asp/var/log/csa103CompI3Log.latest&amp;lt;/code&amp;gt; on SCNodeI1. This will become active  and start printing the hello world logs as above. &lt;br /&gt;
Note in this case active System Controller SCNode1 is still aware of PayloadNodeI0 and PayloadNodeI1.&lt;br /&gt;
&amp;lt;li&amp;gt;Start looking at the logs  for &amp;lt;code&amp;gt;/root/asp/var/log/csa103CompI0Log.latest&amp;lt;/code&amp;gt; in PayloadNodeI0. This will print the  standby  logs as  above.&lt;br /&gt;
&amp;lt;li&amp;gt;Stop  SAFplus Platform  on PayloadNodeI0  and start observing the logs on PayloadNodeI1 in &amp;lt;code&amp;gt;/root/asp/var/log/csa103CompI1Log.latest&amp;lt;/code&amp;gt; for standby.&lt;br /&gt;
In this case, you can see, via the active System Controller logs that PayloadNodeI0 is not active whilst PayloadNodeI1 is.&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Step B'''  For Hardware Setup 1.3 only&lt;br /&gt;
#Repeat A  with the slight exception  that the  blade running SCNodeI0  is  yanked out(&amp;lt;code&amp;gt;/etc/init.d/asp zap&amp;lt;/code&amp;gt;) instead of gracefully shutting  down SAFplus Platform in step 1.&lt;br /&gt;
&lt;br /&gt;
===Summary and References===&lt;br /&gt;
We've seen :&lt;br /&gt;
&lt;br /&gt;
*how to use Clovis' checkpoint service to save some program state and recover that state from a separate process&lt;br /&gt;
*how to initialize the client checkpoint library&lt;br /&gt;
*how to create and open checkpoints &lt;br /&gt;
*how to create and use sections in an opened checkpoint&lt;br /&gt;
&lt;br /&gt;
Further information can be found within the following: ''OpenClovis API Reference Guide''.&lt;/div&gt;</summary>
		<author><name>Madhu</name></author>	</entry>

	</feed>