Scenario 3: Coordinating Resources

The following scenario shows how an assembler program can make updates to three files using a protected conversation.

Figure 1. Updating Three SFS Files Using Coordinated Resource Recovery
dmsa5crr dmsa5crr

The application, CRREXMP1, running in Virtual Machine 1, has access to two files, CHILDS LIST and TOYSTORE ORDERS. These files are located in two different SFS directories, CRRDIR1 and CRRDIR2, respectively. The application, CRREXMP2, running on Virtual Machine 2, has access to one file, SANTAS SACK, which is located in the SFS directory CRRDIR3.

Imagine that one virtual machine is operated by a child entering a Christmas list at a local toy store. The other virtual machine are handled by one of Santa's elves at the North Pole. As the child enters the toys, CRREXMP1 updates its two files, CHILDS LIST and TOYSTORE ORDER. CRREXMP1 then establishes a protected conversation to CRREXMP2 (at the North Pole). CRREXMP1 will send the list of toys to be added to the list Santa will bring the child (SANTA SACK). If CRREXMP2 is successful in updating its file (it will first have to see if the child has been naughty or nice), it will request that the updates be committed. Otherwise, it will request that the updates be rolled back.

Note: This same example is illustrated in z/VM: CMS Application Development Guide using CPI Communications.
Following is a high-level overview of the assembler code that could be used to complete this scenario. For information on the macros used in this scenario see:

Sequence of Instructions for Updating Multiple Files

      CRREXMP1                        CRREXMP2
         1  HNDIUCV SET                   1  HNDIUCV SET
         2  DMSSSPTO
         3  DMSSETAG
         4  DMSOPEN CHILDS LIST
         5  DMSWRITE CHILDS LIST
         6  DMSCLOSE CHILDS LIST
         7  DMSOPEN TOYSTORE ORDERS
         8  DMSWRITE TOYSTORE ORDERS
         9  DMSCLOSE TOYSTORE ORDERS
         10 APPCVM CONNECT SYNCLVL=SYNCPT, MF=L
         11 CMSIUCV CONNECT
                                          12 IUCV ACCEPT (MF=L)
                                          13 CMSIUCV ACCEPT
         14 APPCVM SENDCNF
                                          15 APPCVM RECEIVE
                                          16 APPCVM SENDCNFD
         17 APPCVM SENDDATA
         18 APPCVM RECEIVE TYPE=RECEIVE
                                          19 APPCVM RECEIVE
                                          20 APPCVM SENDCNFD
 
                                          21 DMSSPTO
                                          22 DMSSETAG
 
                                          23 DMSOPEN SANTAS SACK
                                          24 DMSWRITE SANTAS SACK
                                          25 DMSCLOSE SANTAS SACK
 
         26 CMSIUCV QCMSWID               26 CMSIUCV QCMSWID
 

 *************************************************************
 * One of three things can happen at this point:             *
 *  1. Both applications roll back the updates (steps 27-35).*
 *  2. Both applications commit the updates (steps 36-42).   *
 *  3. One application tries to commit the updates but the   *
 *     other one rolls back (steps 43-52).                   *
 *************************************************************
 
 
 
 Both CRREXMP1 and CRRECXP2 roll back updates
                                          27 DMSROLLB
          28 APPCVM RECEIVE
          29 DMSROLLB
                                          30 APPCVM SEVER MF=L
                                          31 CMSIUCV SEVER
          32 APPCVM RECEIVE
          33 APPCVM SEVER MF=L
          34 CMSIUCV SEVER
          35 HNDIUCV CLR                   35 HNDIUCV CLR
 
          Both CRREXMP1 and CRREXMP2 commit updates
 
                                           36 APPCVM SETMODFY TYPE=SEVER
                                           37 DMSCOMM
          38 APPCVM RECEIVE
          39 DMSCOMM
          40 APPCVM SEVER MF=L             40 APPCVM SEVER MF=L
          41 CMSIUCV SEVER                 41 CMSIUCV SEVER
          42 HNDIUCV CLR                   42 HNDIUCV CLR
 
      CRREXMP2 commits updates and then CRREXMP1 rolls back the updates

                                            43 APPCVM SETMODFY TYPE=SEVER
                                            44 DMSCOMM
          45 APPCVM RECEIVE
          46 DMSROLLB
                                            47 APPCVM SEVER MF=L
                                            48 CMSIUCV SEVER
          49 APPCVM RECEIVE
          50 APPCVM SEVER MF=L
          51 CMSIUCV SEVER
          52 HNDIUCV CLR                     52 HNDIUCV CLR
 
 

The following list explains the outline of instructions shown in Sequence of Instructions for Updating Multiple Files.

  1. Both CRREXMP1 and CRREXMP2 assembler programs identify the program name to CMS with HNDIUCV SET.
  2. DMSSSPTO sets the synchronization point options.
  3. DMSSETAG sets the transaction tag.
  4. DMSOPEN opens the CHILDS LIST file in the SFS directory, CRRDIR1.
  5. DMSWRITE writes to the CHILDS LIST file.
  6. DMSCLOSE with NOCOMMIT option closes the CHILDS LIST file.
  7. DMSOPEN opens the TOYSTORE ORDERS file in the SFS directory, CRRDIR2.
  8. DMSWRITE writes to the TOYSTORE ORDERS.
  9. DMSCLOSE with NOCOMMIT option closes the TOYSTORE ORDERS file.
  10. APPCVM CONNECT MF=L formats APPC/VM parameter list for connect.
  11. CMSIUCV CONNECT connects to CRREXMP2 with the APPC/VM parameter list
  12. IUCV ACCEPT MF=L formats the IUCV parameter list for ACCEPT.
  13. CMSIUCV ACCEPT accepts CRREXMP1's connection.
  14. APPCVM SENDCNF ensures that CRREXMP2 has received allocation.
  15. APPCVM RECEIVE gets confirmation request.
  16. APPCVM SENDCNFD responds to the confirmation request.
  17. APPCVM SENDDATA sends the data record to CRREXMP2.
  18. APPCVM RECEIVE TYPE=RECEIVE to confirm and enter receive state.
  19. APPCVM RECEIVE receives the data record and CRREXMP's request to enter receive state.
  20. APPCVM SENDCNFD confirms CRREXMP1's state request.
  21. DMSSSPTO sets synchronization point options.
  22. DMSSETAG sets the transaction tag.
  23. DMSOPEN opens SANTAS SACK file in the SFS directory, CRRDIR3.
  24. DMSWRITE writes to SANTAS SACK.
  25. DMSCLOSE with NOCOMMIT option closes SANTAS SACK.
  26. CMSIUCV QCMSWID determines workunitid for APPC/VM paths.*
    **************************************************************
    * One of three things can happen at this point:              *
    *  1. Both applications roll back the updates (steps 27-35). *
    *  2. Both applications commit the updates (steps 36-42).    *
    *  3. One application tries to commit the updates but the    *
    *     other one rolls back (steps 43-52).                    *
    **************************************************************
     
    • Both CRREXMP1 and CRREXMP2 roll back updates
  27. DMSROLLB initiates rollback processing for returned workunitid.
  28. APPCVM RECEIVE receives the rollback indication.
  29. DMSROLLB performs rollback processing for returned work.
  30. APPCVM SEVER MF=L formats APPC/VM parameter list for sever abend.
  31. CMSIUCV SEVER severs the protected conversation with the partner.
  32. APPCVM RECEIVE gets the sever indication.
  33. APPCVM SEVER MF=L formats the APPC/VM parameter list for normal sever
  34. CMSIUCV SEVER severs local path for protected conversation.
  35. Both CRREXMP1 and CRREXMP2 assembler programs notify CMS that the program is complete with HNDIUCV CLR.
    • Both CRREXMP1 and CRREXMP2 commit updates
  36. APPCVM SETMODFY TYPE=SEVER severs the conversation after a successful sync point.
  37. DMSCOMM initiates commit processing for the returned workunitid.
  38. APPCVM RECEIVE receives the commit request indication.
  39. DMSCOMM performs commit processing for returned workunitid.
  40. APPCVM SEVER MF=L formats the APPC/VM parameter list for normal sever.
  41. CMSIUCV SEVER severs the local path for the protected conversation.
  42. Both CRREXMP1 and CRREXMP2 assembler programs notify CMS that the program is complete with HNDIUCV CLR.
    • CRREXMP2 commits the updates and then CRREXMP1 rolls back the updates
  43. APPCVM SETMODFY TYPE=SEVER severs the conversation after a successful sync point.
  44. DMSCOMM initiates commit processing for returned workunitid.
  45. APPCVM RECEIVE receives the commit request indication.
  46. DMSROLLB performs rollback processing for returned workunitid. This causes the updates made by CRREXMP1 and CRREXMP2 to be rolled back.
  47. APPCVM SEVER MF=L formats the APPC/VM parameter list for sever abend.
  48. CMSIUCV SEVER severs the protected conversation with CRREXMP1.
  49. APPCVM RECEIVE gets the sever indication.
  50. APPCVM SEVER MF=L formats the APPCVM parameter list for normal sever.
  51. CMSIUCV SEVER severs the local path for the protected conversation.
  52. Both CRREXMP1 and CRREXMP2 assembler programs notify CMS that the program is complete with HNDIUCV CLR.