Difference between revisions of "Doc:latest/evalguide/csa213"

Line 227: Line 227:
 
In the csa212 application log you should see:
 
In the csa212 application log you should see:
 
{| cellspacing="0" cellpadding = "0" border="0" align = "center" width="680"
 
{| cellspacing="0" cellpadding = "0" border="0" align = "center" width="680"
  ! style="color:black;background-color:#ffffaa;" align="center"| $ /root/asp/var/log/csa112CompI0Log.latest  
+
  ! style="color:black;background-color:#ffffaa;" align="center"| $ /root/asp/var/log/csa212CompI3Log.latest  
 
  |-  
 
  |-  
 
  |<code><pre>
 
  |<code><pre>
Mon Jul 14 22:50:34 2008  (SCNodeI0.24830 : csa112CompEO.---.---.00037 :  INFO)
+
Thu Oct 14 13:25:49.418 2010 (PayloadNodeI1.4003 : csa212CompEO.---.---.00001 :  INFO) Component [csa212CompI3] : PID [4003]. Initializing
csa112: Instantiated as component instance csa112CompI0.
+
 
Mon Jul 14 22:50:34 2008  (SCNodeI0.24830 : csa112CompEO.---.---.00038 :  INFO)
+
Thu Oct 14 13:25:49.418 2010 (PayloadNodeI1.4003 : csa212CompEO.---.---.00002 :  INFO)   IOC Address            : 0x4
csa112CompI0: Waiting for CSI assignment...
+
 
Mon Jul 14 22:51:20 2008  (SCNodeI0.24830 : csa112CompEO.---.---.00041 :  INFO)
+
Thu Oct 14 13:25:49.419 2010 (PayloadNodeI1.4003 : csa212CompEO.---.---.00003 :  INFO)    IOC Port                : 0x80
Component [csa112CompI0] : PID [24830]. CSI Set Received
+
 
Mon Jul 14 22:51:20 2008  (SCNodeI0.24830 : csa112CompEO.---.---.00042 :  INFO)
+
Thu Oct 14 13:26:01.942 2010 (PayloadNodeI1.4003 : csa212CompEO.---.---.00004 :  INFO) Component [csa212CompI3] : PID [4003]. CSI Set Received
    CSI Flags               : [Add One]
+
 
Mon Jul 14 22:51:20 2008  (SCNodeI0.24830 : csa112CompEO.---.---.00043 :  INFO)
+
Thu Oct 14 13:26:01.942 2010 (PayloadNodeI1.4003 : csa212CompEO.---.---.00005 :  INFO) CSI Flags : [Add One]
    CSI Name               : [csa112CSII0]
+
Thu Oct 14 13:26:01.942 2010 (PayloadNodeI1.4003 : csa212CompEO.---.---.00006 :  INFO) CSI Name : [csa212CSII0]
Mon Jul 14 22:51:20 2008  (SCNodeI0.24830 : csa112CompEO.---.---.00044 :  INFO)
+
Thu Oct 14 13:26:01.942 2010 (PayloadNodeI1.4003 : csa212CompEO.---.---.00007 :  INFO) Name value pairs :
    Name Value Pairs        :
+
Thu Oct 14 13:26:01.942 2010 (PayloadNodeI1.4003 : csa212CompEO.---.---.00008 :  INFO) HA state : [Active]
Mon Jul 14 22:51:20 2008  (SCNodeI0.24830 : csa112CompEO.---.---.00045 :  INFO)
+
Thu Oct 14 13:26:01.942 2010 (PayloadNodeI1.4003 : csa212CompEO.---.---.00009 :  INFO) Active Descriptor :
    HA State                : [Active]
+
Thu Oct 14 13:26:01.942 2010 (PayloadNodeI1.4003 : csa212CompEO.---.---.00010 :  INFO) Transition Descriptor : [1]
Mon Jul 14 22:51:20 2008  (SCNodeI0.24830 : csa112CompEO.---.---.00046 :  INFO)
+
Thu Oct 14 13:26:01.942 2010 (PayloadNodeI1.4003 : csa212CompEO.---.---.00011 :  INFO) Active Component : [csa212CompI3]
    Active Descriptor       :
+
Thu Oct 14 13:26:01.942 2010 (PayloadNodeI1.4003 : csa212CompEO.---.---.00012 :  INFO) csa212: ACTIVE state requested; activating service
Mon Jul 14 22:51:20 2008  (SCNodeI0.24830 : csa112CompEO.---.---.00047 :  INFO)
+
 
      Transition Descriptor : [1]
+
Mon Jul 14 22:51:20 2008  (SCNodeI0.24830 : csa112CompEO.---.---.00048 :  INFO)
+
        Active Component   : [csa112CompI0]
+
Mon Jul 14 22:51:20 2008  (SCNodeI0.24830 : csa112CompEO.---.---.00049 :  INFO)
+
csa112: ACTIVE state requested; activating service
+
 
</pre></code>
 
</pre></code>
 
|}  
 
|}  
[[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.
+
 
  
 
<li>Now you can start up the event publishing application and put it in a LockAssignment state.
 
<li>Now you can start up the event publishing application and put it in a LockAssignment state.
Line 262: Line 257:
 
</pre></code>
 
</pre></code>
  
Putting csa213 into a LockAssignment state caused it to begin publishing events. Using <code>tail -f /root/asp/var/log/csa213CompI0Log.latest</code> on the csa213 application log you can see the events being published.
+
Putting csa213 into a LockAssignment state caused it to begin publishing events. Using <code>tail -f /root/asp/var/log/csa213CompI3Log.latest</code> on the csa213 application log you can see the events being published.
 
{| cellspacing="0" cellpadding = "0" border="0" align = "center" width="680"
 
{| cellspacing="0" cellpadding = "0" border="0" align = "center" width="680"
  ! style="color:black;background-color:#ffffaa;" align="center"| $ /root/asp/var/log/csa113CompI0Log.latest  
+
  ! style="color:black;background-color:#ffffaa;" align="center"| $ /root/asp/var/log/csa213CompI3Log.latest  
 
  |-  
 
  |-  
 
  |<code><pre>
 
  |<code><pre>
Mon Jul 14 22:53:54 2008  (SCNodeI0.24890 : csa113CompEO.---.---.00028 :  INFO)
+
Thu Oct 14 13:28:58.503 2010 (PayloadNodeI1.4422 : csa213CompEO.---.---.00001 :  INFO) csa213: Initializing and registering with CPM...
Component [csa113CompI0] : PID [24890]. Initializing
+
 
Mon Jul 14 22:53:54 2008  (SCNodeI0.24890 : csa113CompEO.---.---.00029 :  INFO)
+
Thu Oct 14 13:28:58.503 2010 (PayloadNodeI1.4422 : csa213CompEO.---.---.00002 :  INFO) Component [csa213CompI3] : PID [4422]. Initializing
    IOC Address            : 0x1
+
 
Mon Jul 14 22:53:54 2008  (SCNodeI0.24890 : csa113CompEO.---.---.00030 :  INFO)
+
Thu Oct 14 13:28:58.503 2010 (PayloadNodeI1.4422 : csa213CompEO.---.---.00003 :  INFO)   IOC Address            : 0x4
    IOC Port                : 0x81
+
 
Mon Jul 14 22:53:54 2008  (SCNodeI0.24890 : csa113CompEO.---.---.00037 :  INFO)
+
Thu Oct 14 13:28:58.503 2010 (PayloadNodeI1.4422 : csa213CompEO.---.---.00004 :  INFO)   IOC Port                : 0x81
Instantiated as component instance csa113CompI0.
+
 
Mon Jul 14 22:53:54 2008  (SCNodeI0.24890 : csa113CompEO.---.---.00038 :  INFO)
+
Thu Oct 14 13:28:58.504 2010 (PayloadNodeI1.4422 : csa213CompEO.---.---.00005 :  INFO) csa213CompI3: Waiting for CSI assignment...
csa113CompI0: Waiting for CSI assignment...
+
 
Mon Jul 14 22:53:59 2008  (SCNodeI0.24890 : csa113CompEO.---.---.00041 :  INFO)
+
Thu Oct 14 13:29:09.593 2010 (PayloadNodeI1.4422 : csa213CompEO.---.---.00006 :  INFO) Component [csa213CompI3] : PID [4422]. CSI Set Received
Component [csa113CompI0] : PID [24890]. CSI Set Received
+
 
Mon Jul 14 22:53:59 2008  (SCNodeI0.24890 : csa113CompEO.---.---.00042 :  INFO)
+
Thu Oct 14 13:29:09.593 2010 (PayloadNodeI1.4422 : csa213CompEO.---.---.00007 :  INFO) CSI Flags : [Add One]
    CSI Flags               : [Add One]
+
Thu Oct 14 13:29:09.593 2010 (PayloadNodeI1.4422 : csa213CompEO.---.---.00008 :  INFO) CSI Name : [csa213CSII0]
Mon Jul 14 22:53:59 2008  (SCNodeI0.24890 : csa113CompEO.---.---.00043 :  INFO)
+
Thu Oct 14 13:29:09.593 2010 (PayloadNodeI1.4422 : csa213CompEO.---.---.00009 :  INFO) Name value pairs :
    CSI Name               : [csa113CSII0]
+
Thu Oct 14 13:29:09.593 2010 (PayloadNodeI1.4422 : csa213CompEO.---.---.00010 :  INFO) HA state : [Active]
Mon Jul 14 22:53:59 2008  (SCNodeI0.24890 : csa113CompEO.---.---.00044 :  INFO)
+
Thu Oct 14 13:29:09.593 2010 (PayloadNodeI1.4422 : csa213CompEO.---.---.00011 :  INFO) Active Descriptor :
    Name Value Pairs        :
+
Thu Oct 14 13:29:09.593 2010 (PayloadNodeI1.4422 : csa213CompEO.---.---.00012 :  INFO) Transition Descriptor : [1]
Mon Jul 14 22:53:59 2008  (SCNodeI0.24890 : csa113CompEO.---.---.00045 :  INFO)
+
Thu Oct 14 13:29:09.593 2010 (PayloadNodeI1.4422 : csa213CompEO.---.---.00013 :  INFO) Active Component : [csa213CompI3]
    HA State                : [Active]
+
Thu Oct 14 13:29:09.593 2010 (PayloadNodeI1.4422 : csa213CompEO.---.---.00014 :  INFO) csa213: ACTIVE state request: activating service
Mon Jul 14 22:53:59 2008  (SCNodeI0.24890 : csa113CompEO.---.---.00046 :  INFO)
+
Thu Oct 14 13:29:10.511 2010 (PayloadNodeI1.4422 : csa213CompEO.---.---.00015 :   INFO) csa213CompI3: Publishing Event: Thu Oct 14 13:29:10 2010
    Active Descriptor       :
+
 
Mon Jul 14 22:53:59 2008  (SCNodeI0.24890 : csa113CompEO.---.---.00047 :  INFO)
+
Thu Oct 14 13:29:11.516 2010 (PayloadNodeI1.4422 : csa213CompEO.---.---.00016 :   INFO) csa213CompI3: Publishing Event: 0.29 0.42 0.25
      Transition Descriptor : [1]
+
 
Mon Jul 14 22:53:59 2008  (SCNodeI0.24890 : csa113CompEO.---.---.00048 :  INFO)
+
Thu Oct 14 13:29:12.521 2010 (PayloadNodeI1.4422 : csa213CompEO.---.---.00017 :   INFO) csa213CompI3: Publishing Event: Thu Oct 14 13:29:12 2010
        Active Component   : [csa113CompI0]
+
 
Mon Jul 14 22:53:59 2008  (SCNodeI0.24890 : csa113CompEO.---.---.00049 :  INFO)
+
Thu Oct 14 13:29:13.526 2010 (PayloadNodeI1.4422 : csa213CompEO.---.---.00018 INFO) csa213CompI3: Publishing Event: 0.66 0.50 0.27
csa113: ACTIVE state requested; activating service
+
 
Mon Jul 14 22:53:59 2008  (SCNodeI0.24890 : csa113CompEO.---.---.00050 : NOTICE)
+
Thu Oct 14 13:29:14.530 2010 (PayloadNodeI1.4422 : csa213CompEO.---.---.00019 :   INFO) csa213CompI3: Publishing Event: Thu Oct 14 13:29:14 2010
Publishing Event: Mon Jul 14 22:53:59 2008
+
 
Mon Jul 14 22:54:00 2008  (SCNodeI0.24890 : csa113CompEO.---.---.00052 : NOTICE)
+
Thu Oct 14 13:29:15.537 2010 (PayloadNodeI1.4422 : csa213CompEO.---.---.00020 :  INFO) csa213CompI3: Publishing Event: 0.66 0.50 0.27
Publishing Event: 0.05 0.07 0.03
+
 
Mon Jul 14 22:54:01 2008  (SCNodeI0.24890 : csa113CompEO.---.---.00054 : NOTICE)
+
Thu Oct 14 13:29:16.538 2010 (PayloadNodeI1.4422 : csa213CompEO.---.---.00021 INFO) csa213CompI3: Publishing Event: Thu Oct 14 13:29:16 2010
Publishing Event: Mon Jul 14 22:54:01 2008
+
 
Mon Jul 14 22:54:02 2008   (SCNodeI0.24890 : csa113CompEO.---.---.00056 : NOTICE)
+
Thu Oct 14 13:29:17.541 2010 (PayloadNodeI1.4422 : csa213CompEO.---.---.00022 :   INFO) csa213CompI3: Publishing Event: 1.01 0.57 0.30
Publishing Event: 0.05 0.07 0.03
+
 
Mon Jul 14 22:54:03 2008   (SCNodeI0.24890 : csa113CompEO.---.---.00058 : NOTICE)
+
Thu Oct 14 13:29:18.545 2010 (PayloadNodeI1.4422 : csa213CompEO.---.---.00023 :  INFO) csa213CompI3: Publishing Event: Thu Oct 14 13:29:18 2010
Publishing Event: Mon Jul 14 22:54:03 2008
+
 
Mon Jul 14 22:54:04 2008   (SCNodeI0.24890 : csa113CompEO.---.---.00060 : NOTICE)
+
Thu Oct 14 13:29:19.548 2010 (PayloadNodeI1.4422 : csa213CompEO.---.---.00024 INFO) csa213CompI3: Publishing Event: 1.01 0.57 0.30
Publishing Event: 0.05 0.07 0.03
+
 
 +
Thu Oct 14 13:29:20.549 2010 (PayloadNodeI1.4422 : csa213CompEO.---.---.00025 :   INFO) csa213CompI3: Publishing Event: Thu Oct 14 13:29:20 2010
 +
 
 +
Thu Oct 14 13:29:21.554 2010 (PayloadNodeI1.4422 : csa213CompEO.---.---.00026 :  INFO) csa213CompI3: Publishing Event: 1.01 0.57 0.30
 +
 
 +
Thu Oct 14 13:29:22.557 2010 (PayloadNodeI1.4422 : csa213CompEO.---.---.00027 :  INFO) csa213CompI3: Publishing Event: Thu Oct 14 13:29:22 2010
 +
 
 +
Thu Oct 14 13:29:23.562 2010 (PayloadNodeI1.4422 : csa213CompEO.---.---.00028 :  INFO) csa213CompI3: Publishing Event: 1.17 0.61 0.31
 +
 
 +
Thu Oct 14 13:29:24.563 2010 (PayloadNodeI1.4422 : csa213CompEO.---.---.00029 :  INFO) csa213CompI3: Publishing Event: Thu Oct 14 13:29:24 2010
 +
 
 
   </pre></code>
 
   </pre></code>
 
|}  
 
|}  
Line 312: Line 317:
 
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 <code>tail -f /rootasp//var/log/csa212CompI0Log.latest</code> you can see the following:
 
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 <code>tail -f /rootasp//var/log/csa212CompI0Log.latest</code> you can see the following:
 
{| cellspacing="0" cellpadding = "0" border="0" align = "center" width="680"
 
{| cellspacing="0" cellpadding = "0" border="0" align = "center" width="680"
  ! style="color:black;background-color:#ffffaa;" align="center"| /root/asp/var/log/csa112CompI0Log.latest
+
  ! style="color:black;background-color:#ffffaa;" align="center"| /root/asp/var/log/csa112CompI3Log.latest
 
  |-  
 
  |-  
 
  |<code><pre>
 
  |<code><pre>
Mon Jul 14 22:53:59 2008   (SCNodeI0.24830 : csa112CompEO.---.---.00052 : NOTICE)
+
Thu Oct 14 13:25:49.418 2010 (PayloadNodeI1.4003 : csa212CompEO.---.---.00001 INFO) Component [csa212CompI3] : PID [4003]. Initializing
We've got an event to receive
+
 
Mon Jul 14 22:53:59 2008  (SCNodeI0.24830 : csa112CompEO.---.---.00054 : NOTICE)
+
Thu Oct 14 13:25:49.418 2010 (PayloadNodeI1.4003 : csa212CompEO.---.---.00002 :   INFO)   IOC Address            : 0x4
received event: Mon Jul 14 22:53:59 2008
+
 
Mon Jul 14 22:54:00 2008  (SCNodeI0.24830 : csa112CompEO.---.---.00058 : NOTICE)
+
Thu Oct 14 13:25:49.419 2010 (PayloadNodeI1.4003 : csa212CompEO.---.---.00003 :  INFO)    IOC Port                : 0x80
We've got an event to receive
+
 
Mon Jul 14 22:54:00 2008  (SCNodeI0.24830 : csa112CompEO.---.---.00060 : NOTICE)
+
Thu Oct 14 13:26:01.942 2010 (PayloadNodeI1.4003 : csa212CompEO.---.---.00004 :  INFO) Component [csa212CompI3] : PID [4003]. CSI Set Received
received event: 0.05 0.07 0.03
+
 
Mon Jul 14 22:54:01 2008  (SCNodeI0.24830 : csa112CompEO.---.---.00064 : NOTICE)
+
Thu Oct 14 13:26:01.942 2010 (PayloadNodeI1.4003 : csa212CompEO.---.---.00005 :  INFO) CSI Flags : [Add One]
We've got an event to receive
+
Thu Oct 14 13:26:01.942 2010 (PayloadNodeI1.4003 : csa212CompEO.---.---.00006 :  INFO) CSI Name : [csa212CSII0]
Mon Jul 14 22:54:01 2008  (SCNodeI0.24830 : csa112CompEO.---.---.00066 : NOTICE)
+
Thu Oct 14 13:26:01.942 2010 (PayloadNodeI1.4003 : csa212CompEO.---.---.00007 :  INFO) Name value pairs :
received event: Mon Jul 14 22:54:01 2008
+
Thu Oct 14 13:26:01.942 2010 (PayloadNodeI1.4003 : csa212CompEO.---.---.00008 :  INFO) HA state : [Active]
Mon Jul 14 22:54:02 2008   (SCNodeI0.24830 : csa112CompEO.---.---.00070 : NOTICE)
+
Thu Oct 14 13:26:01.942 2010 (PayloadNodeI1.4003 : csa212CompEO.---.---.00009 :  INFO) Active Descriptor :
We've got an event to receive
+
Thu Oct 14 13:26:01.942 2010 (PayloadNodeI1.4003 : csa212CompEO.---.---.00010 :  INFO) Transition Descriptor : [1]
Mon Jul 14 22:54:02 2008   (SCNodeI0.24830 : csa112CompEO.---.---.00072 : NOTICE)
+
Thu Oct 14 13:26:01.942 2010 (PayloadNodeI1.4003 : csa212CompEO.---.---.00011 :  INFO) Active Component : [csa212CompI3]
received event: 0.05 0.07 0.03
+
Thu Oct 14 13:26:01.942 2010 (PayloadNodeI1.4003 : csa212CompEO.---.---.00012 :  INFO) csa212: ACTIVE state requested; activating service
 +
Thu Oct 14 13:29:10.516 2010 (PayloadNodeI1.4003 : csa212CompEO.---.---.00013 :  INFO) We've got an event to receive
 +
 
 +
Thu Oct 14 13:29:10.516 2010 (PayloadNodeI1.4003 : csa212CompEO.---.---.00014 :   INFO) received event: Thu Oct 14 13:29:10 2010
 +
 
 +
Thu Oct 14 13:29:11.518 2010 (PayloadNodeI1.4003 : csa212CompEO.---.---.00015 :   INFO) We've got an event to receive
 +
 
 +
Thu Oct 14 13:29:11.518 2010 (PayloadNodeI1.4003 : csa212CompEO.---.---.00016 :   INFO) received event: 0.29 0.42 0.25
 +
 
 +
Thu Oct 14 13:29:12.525 2010 (PayloadNodeI1.4003 : csa212CompEO.---.---.00017 :   INFO) We've got an event to receive
 +
 
 +
Thu Oct 14 13:29:12.525 2010 (PayloadNodeI1.4003 : csa212CompEO.---.---.00018 :   INFO) received event: Thu Oct 14 13:29:12 2010
 +
 
 +
Thu Oct 14 13:29:13.529 2010 (PayloadNodeI1.4003 : csa212CompEO.---.---.00019 INFO) We've got an event to receive
 +
 
 +
Thu Oct 14 13:29:13.529 2010 (PayloadNodeI1.4003 : csa212CompEO.---.---.00020 :   INFO) received event: 0.66 0.50 0.27
 +
 
 +
Thu Oct 14 13:29:14.533 2010 (PayloadNodeI1.4003 : csa212CompEO.---.---.00021 :  INFO) We've got an event to receive
 +
 
 +
Thu Oct 14 13:29:14.533 2010 (PayloadNodeI1.4003 : csa212CompEO.---.---.00022 INFO) received event: Thu Oct 14 13:29:14 2010
 +
 
 +
Thu Oct 14 13:29:15.540 2010 (PayloadNodeI1.4003 : csa212CompEO.---.---.00023 :   INFO) We've got an event to receive
 +
 
 +
Thu Oct 14 13:29:15.541 2010 (PayloadNodeI1.4003 : csa212CompEO.---.---.00024 :  INFO) received event: 0.66 0.50 0.27
 +
 
 +
Thu Oct 14 13:29:16.540 2010 (PayloadNodeI1.4003 : csa212CompEO.---.---.00025 :  INFO) We've got an event to receive
 +
 
 +
Thu Oct 14 13:29:16.540 2010 (PayloadNodeI1.4003 : csa212CompEO.---.---.00026 :  INFO) received event: Thu Oct 14 13:29:16 2010
 +
 
 
   </pre></code>
 
   </pre></code>
 
|}
 
|}

Revision as of 07:14, 14 October 2010

Contents

csa213 Event Publication

Objective

The objective is to learn how to write an event publishing application using Clovis' Event Manager API.

What You Will Learn

  • You will learn how to publish events using Clovis' Event Manager API.

Code

clCompAppMain.c
    int
    main(int argc, Char *argv[])
    {
        SaNameT             appName = {0};
        SaAmfCallbacksT     callbacks;
        SaVersionT          version;
        clIocPortT          iocPort;
        SaAisErrorT         rc = SA_AIS_OK;
        SaEvtChannelHandleT evtChannelHandle = 0

        SaSelectionObjectT dispatch_fd;
        fd_set read_fds;


        /*
         * ---BEGIN_APPLICATION_CODE---
         */
        
        SaEvtCallbacksT   evtCallbacks = { NULL, NULL };

        /*
         * ---END_APPLICATION_CODE---
         */
        ...

        if ( (rc = saAmfInitialize(&amfHandle, &callbacks, &version)) != SA_AIS_OK) 
            goto errorexit;

        ....
  

In the main function of this example we again see a call to saEvtInitialize. Most everything else in the appInitialize function is the same as before in csa212, except that both callback function pointers are specified as NULL. 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.

clCompAppMain.c
    int
    main(int argc, Char *argv[])
    {

        ...

        // Open an event chanel so that we can subscribe to events on that channel
        rc = saEvtChannelOpen(gTestInfo.evtInitHandle,
                               &gTestInfo.evtChannelName,
                              (SA_EVT_CHANNEL_PUBLISHER |
                               SA_EVT_CHANNEL_CREATE),
                              (ClTimeT)SA_TIME_END,
                              &evtChannelHandle);
  

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 PUBLISHER (by specifying SA_EVT_CHANNEL_PUBLISHER flag)

clCompAppMain.c
    int
    main(int argc, Char *argv[])
    {

        ...

        rc = saEvtEventAllocate(evtChannelHandle,  &gTestInfo.eventHandle);
        if (rc != SA_AIS_OK)
        {
            logrc(CL_LOG_LOG_ERROR, "Failed to allocate event [0x%x]",
                    rc);
            return rc;
        }

        rc = saEvtEventAttributesSet(gTestInfo.eventHandle,
                NULL,
                1,
                0,
                &gTestInfo.publisherName);
        if (rc != SA_AIS_OK)
        {
            logrc(CL_LOG_ERROR, "Failed to set event attributes [0x%x]",
                    rc);
            return rc;
        }
  

The call to saEvtEventAllocate allocates an event header. This header is identified by the event handle passed back to gTestInfo.eventHandle. The handle should be used any time the event header is to be used to manipulate the header, either by using saEvtEventAttributesSet (right below), or to send an event using the header as in saEvtEventPublish. The call to saEvtEventAttributesSet defines the EVENT_TYPE which is defined as 5432 in common/common.h and is used in the event subscriber. It also defines the priority to be 1 which is just below the highest priority of CL_EVENT_HIGHEST_PRIORITY which is defined as 0 where CL_EVENT_LOWEST_PRIORITY 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 publisherName is specified because it's required. Our subscriber doesn't care who publishes the events it receives.

clCompAppMain.c
    int
    main(int argc, Char *argv[])
    {

        ...

        while (!gTestInfo.exiting)
        {
            if (gTestInfo.running && gTestInfo.ha_state == CL_AMS_HA_STATE_ACTIVE)
            {
                csa213Comp_PublishEvent();
            }
            sleep(1);
        }
  

Here is the main loop. As long as the application is running and active we make a call to csa213Comp_PublishEvent. The work of the application takes place in csa213Comp_PublishEvent, which is presented below.

clCompAppMain.c
    static ClRcT
    csa213Comp_PublishEvent()
    {
        SaAisErrorT     rc              = SA_AIS_OK;
        ClEventIdT      eventId         = 0;
        static int      index           = 0;
        SASizeT         data_len        = 0;
        char            *data           = 0;
        typedef void (*Generator)(char **, ClSizeT*);
    
        //
        // Note: to add a new generator, just define it above and then include
        // the new functions name in the generators list.
        // Next, maybe something that gets disk free info by way of getfsent
        // and statfs?
        static Generator generators[]   =
        { 
            generate_time_of_day,
            generate_load_average
        };

        //
        // every time through increment index and then set index to
        // it's value modulo the number of entries in the generators
        // array.  This will cause us to cycle through the list of
        // generators as we're called to publish events.
        (*generators[index++])(&data, &data_len);
        index %= (int)(sizeof generators / sizeof generators[0]);
        if (data == 0 || data_len == 0)
        {
            logmsg(CL_LOG_ERROR, "no event data generated");
            return CL_ERR_NO_MEMORY;
        }
        clprintf(CL_LOG_SEV_INFO,"Publishing Event: %.*s", (int)data_len, data);
        rc = saEvtEventPublish(gTestInfo.eventHandle, (void*)data, data_len, &eventId);
        clHeapFree(data);

        return CL_OK;
    }
  

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 saEvtEventPublish. We pass the eventHandle prepared earlier with saEvtEventAllocate and saEvtEventAttributesSet. 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 eventId local variable. This is required so that the saEvtEventPublish 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.

csa213 SA Forum Compliant Event Publication

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.)

SA Forum Data Types with the SAFplus Platform equivalent
SA Forum Data Types OpenClovis Data Types
SaEvtHandleT ClEventHandleT



SA Forum APIs with the SAFplus Platform equivalent
SA Forum APIs OpenClovis APIs
SaEvtEventAllocate ClEventAllocate
saEvtEventAttributesSet clEventExtAttributesSet
saEvtEventPublish clEventPublish

How to Run csa213 and What to Observe

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.

  1. First you should start up csa212 and put it in a LockAssignment state so that it can receive events.
     # cd /root/asp/bin
     # ./asp_console
    
    cli[Test]-> setc 1
    cli[Test:SCNodeI0]-> setc cpm
    cli[Test:SCNodeI0:CPM]-> amsLockAssignment sg csa212SGI0
    cli[Test:SCNodeI0:CPM]-> amsUnlock sg csa212SGI0
    

    In the csa212 application log you should see:

    $ /root/asp/var/log/csa212CompI3Log.latest
    Thu Oct 14 13:25:49.418 2010 (PayloadNodeI1.4003 : csa212CompEO.---.---.00001 :   INFO) Component [csa212CompI3] : PID [4003]. Initializing
    
    Thu Oct 14 13:25:49.418 2010 (PayloadNodeI1.4003 : csa212CompEO.---.---.00002 :   INFO)    IOC Address             : 0x4
    
    Thu Oct 14 13:25:49.419 2010 (PayloadNodeI1.4003 : csa212CompEO.---.---.00003 :   INFO)    IOC Port                : 0x80
    
    Thu Oct 14 13:26:01.942 2010 (PayloadNodeI1.4003 : csa212CompEO.---.---.00004 :   INFO) Component [csa212CompI3] : PID [4003]. CSI Set Received
    
    Thu Oct 14 13:26:01.942 2010 (PayloadNodeI1.4003 : csa212CompEO.---.---.00005 :   INFO) CSI Flags : [Add One]
    Thu Oct 14 13:26:01.942 2010 (PayloadNodeI1.4003 : csa212CompEO.---.---.00006 :   INFO) CSI Name : [csa212CSII0]
    Thu Oct 14 13:26:01.942 2010 (PayloadNodeI1.4003 : csa212CompEO.---.---.00007 :   INFO) Name value pairs :
    Thu Oct 14 13:26:01.942 2010 (PayloadNodeI1.4003 : csa212CompEO.---.---.00008 :   INFO) HA state : [Active]
    Thu Oct 14 13:26:01.942 2010 (PayloadNodeI1.4003 : csa212CompEO.---.---.00009 :   INFO) Active Descriptor :
    Thu Oct 14 13:26:01.942 2010 (PayloadNodeI1.4003 : csa212CompEO.---.---.00010 :   INFO) Transition Descriptor : [1]
    Thu Oct 14 13:26:01.942 2010 (PayloadNodeI1.4003 : csa212CompEO.---.---.00011 :   INFO) Active Component : [csa212CompI3]
    Thu Oct 14 13:26:01.942 2010 (PayloadNodeI1.4003 : csa212CompEO.---.---.00012 :   INFO) csa212: ACTIVE state requested; activating service
    
    


  2. Now you can start up the event publishing application and put it in a LockAssignment state.
    cli[Test:SCNodeI0:CPM]-> amsLockAssignment sg csa213SGI0
    cli[Test:SCNodeI0:CPM]-> amsUnlock sg csa213SGI0
    

    Putting csa213 into a LockAssignment state caused it to begin publishing events. Using tail -f /root/asp/var/log/csa213CompI3Log.latest on the csa213 application log you can see the events being published.

    $ /root/asp/var/log/csa213CompI3Log.latest
    Thu Oct 14 13:28:58.503 2010 (PayloadNodeI1.4422 : csa213CompEO.---.---.00001 :   INFO) csa213: Initializing and registering with CPM...
    
    Thu Oct 14 13:28:58.503 2010 (PayloadNodeI1.4422 : csa213CompEO.---.---.00002 :   INFO) Component [csa213CompI3] : PID [4422]. Initializing
    
    Thu Oct 14 13:28:58.503 2010 (PayloadNodeI1.4422 : csa213CompEO.---.---.00003 :   INFO)    IOC Address             : 0x4
    
    Thu Oct 14 13:28:58.503 2010 (PayloadNodeI1.4422 : csa213CompEO.---.---.00004 :   INFO)    IOC Port                : 0x81
    
    Thu Oct 14 13:28:58.504 2010 (PayloadNodeI1.4422 : csa213CompEO.---.---.00005 :   INFO) csa213CompI3: Waiting for CSI assignment...
    
    Thu Oct 14 13:29:09.593 2010 (PayloadNodeI1.4422 : csa213CompEO.---.---.00006 :   INFO) Component [csa213CompI3] : PID [4422]. CSI Set Received
    
    Thu Oct 14 13:29:09.593 2010 (PayloadNodeI1.4422 : csa213CompEO.---.---.00007 :   INFO) CSI Flags : [Add One]
    Thu Oct 14 13:29:09.593 2010 (PayloadNodeI1.4422 : csa213CompEO.---.---.00008 :   INFO) CSI Name : [csa213CSII0]
    Thu Oct 14 13:29:09.593 2010 (PayloadNodeI1.4422 : csa213CompEO.---.---.00009 :   INFO) Name value pairs :
    Thu Oct 14 13:29:09.593 2010 (PayloadNodeI1.4422 : csa213CompEO.---.---.00010 :   INFO) HA state : [Active]
    Thu Oct 14 13:29:09.593 2010 (PayloadNodeI1.4422 : csa213CompEO.---.---.00011 :   INFO) Active Descriptor :
    Thu Oct 14 13:29:09.593 2010 (PayloadNodeI1.4422 : csa213CompEO.---.---.00012 :   INFO) Transition Descriptor : [1]
    Thu Oct 14 13:29:09.593 2010 (PayloadNodeI1.4422 : csa213CompEO.---.---.00013 :   INFO) Active Component : [csa213CompI3]
    Thu Oct 14 13:29:09.593 2010 (PayloadNodeI1.4422 : csa213CompEO.---.---.00014 :   INFO) csa213: ACTIVE state request: activating service
    Thu Oct 14 13:29:10.511 2010 (PayloadNodeI1.4422 : csa213CompEO.---.---.00015 :   INFO) csa213CompI3: Publishing Event: Thu Oct 14 13:29:10 2010
    
    Thu Oct 14 13:29:11.516 2010 (PayloadNodeI1.4422 : csa213CompEO.---.---.00016 :   INFO) csa213CompI3: Publishing Event: 0.29 0.42 0.25
    
    Thu Oct 14 13:29:12.521 2010 (PayloadNodeI1.4422 : csa213CompEO.---.---.00017 :   INFO) csa213CompI3: Publishing Event: Thu Oct 14 13:29:12 2010
    
    Thu Oct 14 13:29:13.526 2010 (PayloadNodeI1.4422 : csa213CompEO.---.---.00018 :   INFO) csa213CompI3: Publishing Event: 0.66 0.50 0.27
    
    Thu Oct 14 13:29:14.530 2010 (PayloadNodeI1.4422 : csa213CompEO.---.---.00019 :   INFO) csa213CompI3: Publishing Event: Thu Oct 14 13:29:14 2010
    
    Thu Oct 14 13:29:15.537 2010 (PayloadNodeI1.4422 : csa213CompEO.---.---.00020 :   INFO) csa213CompI3: Publishing Event: 0.66 0.50 0.27
    
    Thu Oct 14 13:29:16.538 2010 (PayloadNodeI1.4422 : csa213CompEO.---.---.00021 :   INFO) csa213CompI3: Publishing Event: Thu Oct 14 13:29:16 2010
    
    Thu Oct 14 13:29:17.541 2010 (PayloadNodeI1.4422 : csa213CompEO.---.---.00022 :   INFO) csa213CompI3: Publishing Event: 1.01 0.57 0.30
    
    Thu Oct 14 13:29:18.545 2010 (PayloadNodeI1.4422 : csa213CompEO.---.---.00023 :   INFO) csa213CompI3: Publishing Event: Thu Oct 14 13:29:18 2010
    
    Thu Oct 14 13:29:19.548 2010 (PayloadNodeI1.4422 : csa213CompEO.---.---.00024 :   INFO) csa213CompI3: Publishing Event: 1.01 0.57 0.30
    
    Thu Oct 14 13:29:20.549 2010 (PayloadNodeI1.4422 : csa213CompEO.---.---.00025 :   INFO) csa213CompI3: Publishing Event: Thu Oct 14 13:29:20 2010
    
    Thu Oct 14 13:29:21.554 2010 (PayloadNodeI1.4422 : csa213CompEO.---.---.00026 :   INFO) csa213CompI3: Publishing Event: 1.01 0.57 0.30
    
    Thu Oct 14 13:29:22.557 2010 (PayloadNodeI1.4422 : csa213CompEO.---.---.00027 :   INFO) csa213CompI3: Publishing Event: Thu Oct 14 13:29:22 2010
    
    Thu Oct 14 13:29:23.562 2010 (PayloadNodeI1.4422 : csa213CompEO.---.---.00028 :   INFO) csa213CompI3: Publishing Event: 1.17 0.61 0.31
    
    Thu Oct 14 13:29:24.563 2010 (PayloadNodeI1.4422 : csa213CompEO.---.---.00029 :   INFO) csa213CompI3: Publishing Event: Thu Oct 14 13:29:24 2010
    
      

    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 tail -f /rootasp//var/log/csa212CompI0Log.latest you can see the following:

    /root/asp/var/log/csa112CompI3Log.latest
    Thu Oct 14 13:25:49.418 2010 (PayloadNodeI1.4003 : csa212CompEO.---.---.00001 :   INFO) Component [csa212CompI3] : PID [4003]. Initializing
    
    Thu Oct 14 13:25:49.418 2010 (PayloadNodeI1.4003 : csa212CompEO.---.---.00002 :   INFO)    IOC Address             : 0x4
    
    Thu Oct 14 13:25:49.419 2010 (PayloadNodeI1.4003 : csa212CompEO.---.---.00003 :   INFO)    IOC Port                : 0x80
    
    Thu Oct 14 13:26:01.942 2010 (PayloadNodeI1.4003 : csa212CompEO.---.---.00004 :   INFO) Component [csa212CompI3] : PID [4003]. CSI Set Received
    
    Thu Oct 14 13:26:01.942 2010 (PayloadNodeI1.4003 : csa212CompEO.---.---.00005 :   INFO) CSI Flags : [Add One]
    Thu Oct 14 13:26:01.942 2010 (PayloadNodeI1.4003 : csa212CompEO.---.---.00006 :   INFO) CSI Name : [csa212CSII0]
    Thu Oct 14 13:26:01.942 2010 (PayloadNodeI1.4003 : csa212CompEO.---.---.00007 :   INFO) Name value pairs :
    Thu Oct 14 13:26:01.942 2010 (PayloadNodeI1.4003 : csa212CompEO.---.---.00008 :   INFO) HA state : [Active]
    Thu Oct 14 13:26:01.942 2010 (PayloadNodeI1.4003 : csa212CompEO.---.---.00009 :   INFO) Active Descriptor :
    Thu Oct 14 13:26:01.942 2010 (PayloadNodeI1.4003 : csa212CompEO.---.---.00010 :   INFO) Transition Descriptor : [1]
    Thu Oct 14 13:26:01.942 2010 (PayloadNodeI1.4003 : csa212CompEO.---.---.00011 :   INFO) Active Component : [csa212CompI3]
    Thu Oct 14 13:26:01.942 2010 (PayloadNodeI1.4003 : csa212CompEO.---.---.00012 :   INFO) csa212: ACTIVE state requested; activating service
    Thu Oct 14 13:29:10.516 2010 (PayloadNodeI1.4003 : csa212CompEO.---.---.00013 :   INFO) We've got an event to receive
    
    Thu Oct 14 13:29:10.516 2010 (PayloadNodeI1.4003 : csa212CompEO.---.---.00014 :   INFO) received event: Thu Oct 14 13:29:10 2010
    
    Thu Oct 14 13:29:11.518 2010 (PayloadNodeI1.4003 : csa212CompEO.---.---.00015 :   INFO) We've got an event to receive
    
    Thu Oct 14 13:29:11.518 2010 (PayloadNodeI1.4003 : csa212CompEO.---.---.00016 :   INFO) received event: 0.29 0.42 0.25
    
    Thu Oct 14 13:29:12.525 2010 (PayloadNodeI1.4003 : csa212CompEO.---.---.00017 :   INFO) We've got an event to receive
    
    Thu Oct 14 13:29:12.525 2010 (PayloadNodeI1.4003 : csa212CompEO.---.---.00018 :   INFO) received event: Thu Oct 14 13:29:12 2010
    
    Thu Oct 14 13:29:13.529 2010 (PayloadNodeI1.4003 : csa212CompEO.---.---.00019 :   INFO) We've got an event to receive
    
    Thu Oct 14 13:29:13.529 2010 (PayloadNodeI1.4003 : csa212CompEO.---.---.00020 :   INFO) received event: 0.66 0.50 0.27
    
    Thu Oct 14 13:29:14.533 2010 (PayloadNodeI1.4003 : csa212CompEO.---.---.00021 :   INFO) We've got an event to receive
    
    Thu Oct 14 13:29:14.533 2010 (PayloadNodeI1.4003 : csa212CompEO.---.---.00022 :   INFO) received event: Thu Oct 14 13:29:14 2010
    
    Thu Oct 14 13:29:15.540 2010 (PayloadNodeI1.4003 : csa212CompEO.---.---.00023 :   INFO) We've got an event to receive
    
    Thu Oct 14 13:29:15.541 2010 (PayloadNodeI1.4003 : csa212CompEO.---.---.00024 :   INFO) received event: 0.66 0.50 0.27
    
    Thu Oct 14 13:29:16.540 2010 (PayloadNodeI1.4003 : csa212CompEO.---.---.00025 :   INFO) We've got an event to receive
    
    Thu Oct 14 13:29:16.540 2010 (PayloadNodeI1.4003 : csa212CompEO.---.---.00026 :   INFO) received event: Thu Oct 14 13:29:16 2010
    
      
  3. Now you can shut everything down in the usual manner. Note that you will be shutting down two service groups.
    cli[Test:SCNodeI0:CPM]-> amsLockAssignment sg csa213SGI0
    cli[Test:SCNodeI0:CPM]-> amsLockAssignment sg csa212SGI0
    cli[Test:SCNodeI0:CPM]-> amsLockInstantiation sg csa213SGI0
    cli[Test:SCNodeI0:CPM]-> amsLockInstantiation sg csa212SGI0
    cli[Test:SCNodeI0:CPM]-> end
    cli[Test:SCNodeI0]-> end
    cli[Test]-> bye
    

Summary and References

We've seen how to initialize the event manager subsystem as an event publisher. We've seen:

  • events flow from the event publisher to the subscriber.
  • how to format events and send them through the event manager subsystem
  • For further reading, check the same sources as listed under the csa212 section.