3D PLM Enterprise Architecture

User Interface

Warm Start Incremental Backup

Principles and CAA Integration
Technical Article

Abstract

This article first presents principles and mechanisms for warm start incremental backup. Then it explains what you should do to make sure the workbench or command you create supports warm start. 


Incremental Warm Start Principles

Until now, warm start meant simply automatically saving all documents every xx minutes. Auto save operations on large amounts of data can take a long time, even lasting several minutes, and all interactions since the last auto save are lost. The auto save feature can also be deactivated by users who prefer to save their documents frequently and manually to avoid losing data.

To resolve these problems the incremental warm start has been created. Its objectives are:

All open documents are copied in a temporary directory, and all modifications since the document was opened are logged in a log file. These operations involve a minimum inconvenience for the end user when opening documents (direct copy without loading), and the logging of document modifications at each interaction is not perceptible. 

Regarding the restore behavior:

Most of the logged data correspond to operations done in commands. Some of them are not always replayable. When it is the case, the warm start mechanism is deactivated to avoid a bad restoration in case of crash.

A "warm start compliant" workbench means that for any commands defined inside the workbench:

The incremental warm start mechanism is available for all Dassault Systemes workbenches of the following document types [1]:

This incremental warm start is activated through the Options command.  

[Top]

Technical Description

The aim of this section is first to give an internal description of the data which allow us to support the incremental warm start, and then to explain how this data is used during a session. 

Backup Data

Data to do an incremental backup is stored in the CNext02.roll directory located in the CATTemp environment variable which is by default:

Unix : $HOME/CATTemp
Windows : DriveName:\Documents and Settings\LogonName\Local Settings\Application Data\DassaultSystemes\CATTemp

CNext02.roll contains:

These are copies of all opened documents in session, no matter if those are visible or not. A copy is done either from the original file location ( in file environment) , or from a database (in ENOVIA environment). The name of each copy is an internal name, without relationship with the document original name.  

Fig.2 Warm start Data Diagram

Activation,  Deactivation,  Re-initialization Mechanisms

Now that backup data is described, we can explained how it is used according to end user interactions.

  1. The session is opened in "Incremental backup" mode- Fig.1
  2. The CNext02.roll directory is created.

  3. A first warm start compliant document is opened  (Part, Drawing ou Product)
  4. A copy of the document is done from its original location to the CNext02.roll directory. 

  5. Operations are done on the opened document
  6. The Autosave.log and Undoredo.log files are modified.

  7. The document is saved
  8. As all opened documents are saved, the warm start can be re-initialized: the Autosave.log and Undoredo.log files are emptied, and the copy of the document is redone. 

  9. Another warm start compliant document is opened 
  10. Now, two documents are in the CNext02.roll directory. (If the Autosave.log and Undoredo.log files were present, they are not deleted.)

  11. One document is saved
  12. The Autosave.log and Undoredo.log files cannot be deleted, since there is one dirty file left in memory. As long as there remains dirty documents in memory, a unique save is not sufficient to re-initialize (*) the warm start.

    (*) A re-initialization includes the destruction of the Autosave.log and Undoredo.log files and a copy from their original location of all loaded documents.

  13. Save All
  14. In this case, the re-initialization is possible. The Autosave.log and Undoredo.log files are deleted and the document copies are brought up to date. 

  15. Modification on documents are done, and then a command which is not warm start compliant is executed - See the detailed list
  16. All data contained in the CNext02.roll directory are deleted. The end user is informed by the following message that the incremental warm start is deactivated:

    Fig.3 Warm Start Deactivation Message From a Command.

    If the end user saves all the opened documents (Save All command) and leaves the no warm start compliant command, the warm start will be reactivated. As long as it is not done, the CNext02.roll directory stays empty. 

  17. Save All has been done, modifications are done, and a document which is not warm start compliant is opened (A Process document for example) 
  18. The incremental warm start is deactivated, and the CNext02.roll directory is emptied The end user is informed by the following message:

    Fig.4 Warm start Deactivation Message From a Workbench.

  19. A warm start compliant workbench is activated
  20. Since the documents in memory are not saved, the following message appears:

    Once all the documents are saved, the warm start is re-activated.

    However, if all documents are saved before the warm start compliant workbench activation, the following message appears: 


  21. Closing a document when the warm start is still active
  22. A copy of the document exists in the backup directory. There are two cases to consider:

Transaction

We have previously seen that the Autosave.log file contains the operations recorded during the session, and that they are grouped together in transactions Fig.2. A transaction is a lot which corresponds to a logical set of operations. When operations are replayed, only full lots are redone. It also means that if the last lot is not "closed", it will be not replayed.    

To understand at which moment a transaction is closed, the type of the executed command [2] must be distinguished: 

Command Class Type Transaction Closure Time
CATStateCommand   When the command is ended
CATDlgDialog or CATCommand  When the next command will open a new transaction (*)

(*) For CAA commands, it can be only a state command since the transactional mechanism is not opened, and only the state commands open natively a transaction when they are activated. 

Here is the particular case of the Copy and Cut Command. 
  1. Clipboard not kept

    Suppose that the end user launches the Cut or the Copy command, if the application crashes before or during the paste command, after the warm start, the Paste command will be not possible. The reason is that the Cut and Copy commands copy the selected object in the clipboard which cannot be restored by the warm start feature.     

  2. The Cut command is not executed if it is the last validated operation 
  3. No data is lost.

[Top]

CAA Workbench Integration

You are making a new workbench [3], you should considerer its warm start integration. There are two cases to consider:

You should declare that the new CAA workbench is warm start compliant. It is done by adding the following line in the CATRsc resource file of the workbench [4]:

AllowWarmStart="YES" ;

You find this file in the CNext/resource/msgcatalog directory of the framework defining the workbench. 

The warm start compatibility will be checked on each command such as described in the next section.

[Top]

CAA Command Integration

Once you have created a command [5], you should check its integration in the warm start mechanism. This section explains you which commands are concerned, and if any, how you can use the CATOmbWarmStartServices class to activate, deactivate the warm start, or validate a transaction. Commands which create applicative container, or use non V5 documents, end this section. 

What are Commands to Take Into Account?

Any command which modifies a V5 document, launched from a command header [6] or not, is concerned by the warm start. However, these two following cases can be excluded:

  1. Undefined command

  2. For recall, an undefined command is a command which is not seen by the focus manager [2]. It means that such command are never activated, deactivated or killed by this object. An example is the Search command [7]. These commands should not be concerned by the warm start, because they should not contain operations on document. Two commands should not work on the same object at the same time. 

  3. Command launched from a no warm start document

  4. Please note that if today the document does not support warm start, one day it could do it. If now, you can exclude the command, it is only because the warm start will be first deactivated by the workbench of the document.

Why and How to Deactivate the Warm Start?

It is necessary to make sure that the command will not corrupt the backup restoration. For that it is necessary to analyze the operations which are made on the document. 

To deactivate the warm start, you should use the Deactivate method of the CATOmbWarmStartServices class. This call must be done in the command activation. Here is an code example:

class CAAMyCommand : public CATCommand
{
      ...
         CATStatusChangeRC Activate( CATCommand *iCmd,CATNotification *iNotif);
      ...
}

CAAMyCommand derives from CATCommand, but it can be CATStateCommand or CATDlgDialog. The unique common point is that the command is shared or exclusive. The Activate method is called by the focus manager once the command is activated or reactivated after a deactivation by a shared command. In the two cases the deactivated state is tested, because the command which has interrupted the CAAMyCommand command might have reactivated the warm start.

CATStatusChangeRC CAAMyCommand::Activate( CATCommand *iCmd,CATNotification *iNotif)
{
   CATBoolean WarmStartActivationState = FALSE ;
   HRESULT rc = CATOmbWarmStartServices::IsActive(WarmStartActivationState );
   if ( SUCCEEDED(rc) && (TRUE == WarmStartActivationState) )
   {
      CATUnicodeString WarningMessageToDisplay ;
      rc = CATOmbWarmStartServices::Deactivate(WarningMessageToDisplay);
      if (SUCCEEDED(rc) && (0 != WarningMessageToDisplay.GetLengthInChar()) )
      {
         CATApplicationFrame *pFrame = CATApplicationFrame::GetFrame();
         if ( (NULL != pFrame ) && ( NULL != pFrame->GetMainWindow() ))
         {
            CATDlgNotify * pNotify = new CATDlgNotify(
                                        pFrame->GetMainWindow(),
                                        "AutoSaveId",
                                  CATDlgNfyInformation|CATDlgNfyOK|CATDlgWndModal) ;
                                        
            CATUnicodeString NotifyWindowTitle= "....";
            pNotify->DisplayBlocked(WarningMessageToDisplay,NotifyWindowTitle);
            
            pNotify->RequestDelayedDestruction();
            pNotify = NULL ;
         }
      }
   }
}

Before deactivating the warm start, you can test that it is not already deactivated. The Deactivate method returns a message that you should display to inform the end user. This message, Fig.4, is displayed through a CATDlgNotify class instance: 

The DisplayBlocked method usage avoids setting a callback to close the window. The RequestDelayedDestruction call will be executed after the closure of the window by the end user.  The first argument of the DisplayBlocked method is the message to display, and the second one is the title of the window. 

For the title of the window, you can set for example the command's NLS name. If the command is activated from a command header [6], this NLS name is the title of the command header instance [9]. 

...
      CATUnicodeString NotifyWindowTitle= "CommandClassName";
      CATString CatalogName="xxx";
      CATString MessageKey = "xxx.yyy.Title";
      CATMsgCatalog::BuildMessage(CatalogName,MessageKey,NULL,0,NotifyWindowTitle);
...

where 

Why and How to Activate or Re-initialize the Warm Start?

If the command saves or closes one or several documents, it can try to activate or re-initialize the warm start. The activation will succeed if the following conditions are met:

  1. Warm Start option is activated, Fig.1 

  2. Command is launched from a workbench which authorizes the warm start,

  3. All documents in session are saved, or not dirty. If you close or save all the loaded documents, this last condition is of course always true. 

The Activate method of the CATOmbWarmStartServices class enables you to try to reactivate the warm start. This call must be done just after the last closure or saving. Here is a piece of code:

      CATUnicodeString WarningMessageToDisplay ;
      rc = CATOmbWarmStartServices::Activate(WarningMessageToDisplay);
      if (SUCCEEDED(rc) && (0 != WarningMessageToDisplay.GetLengthInChar()) )
      {
         CATApplicationFrame *pFrame = CATApplicationFrame::GetFrame();
         if ( (NULL != pFrame ) && ( NULL != pFrame->GetMainWindow() ))
         {
            CATDlgNotify * pNotify = new CATDlgNotify(
                                        pFrame->GetMainWindow(),
                                        "AutoSaveId",
                                        CATDlgNfyInformation|CATDlgNfyOK|CATDlgWndModal) ;
                                        
            CATUnicodeString NotifyWindowTitle= "....";
            pNotify->DisplayBlocked(WarningMessageToDisplay,NotifyWindowTitle);
            
            pNotify->RequestDelayedDestruction();
            pNotify = NULL ;
         }
      }
   }
}

Refer to the previous section for details. 

Why and How to Commit a Transaction?

Normally the operations inside a command are validated at the end of the command for a state command, or at the activation of the next state command for the others type of commands. That means that as long as the validation is not made, if the V5 session is broken, the last operations will be not replayed at the backup. However, you can force this validation during a command if it is necessary.

The CommitTransaction method of the CATOmbWarmStartServices class enables you to do so. This call must be done just after the last validated operation.  

Commands Creating Applicative Container

The method to create an applicative container is the CATCreateApplicativeContainer global function [10]. Once the applicative container is created you have in this order to:

  1. Call its initialization through the Init method of the CATInit interface [11]
  2. You call it only if the container implements the CATInit interface. Inside this implementation you find the provider declarations, and sometime feature creations.

  3. Call the CATOmbPerformAfterContainerCreation global function
  4. This call enables the application to initialize the undo/redo and the transactional mechanism on the container. This call must always be called after the container initialization. If you do it before the operations done in the Init method will be stored in the backup data. So when the document will be reloaded, the operations in the Init method will be executed twice: first by the warm start restoration and a second time, by the automatically call to the Init method. 

Here is an extract of code to create an applicative container inside a command:
...
CATBaseUnknown * pAppliContainer = NULL;
CATDocument *pDocument = ... ;
CATIdent AppliContainerType = "....";
CATIdent AppliContainerSuperType = "....";
CATUnicodeString AppliContainerIdentifier = "...";

HRESULT rc = ::CATCreateApplicativeContainer(&pAppliContainer,
                       pDocument , 
                       AppliContainerType, 
                       IID_CATIContainer,  
                       AppliContainerSuperType, 
                       AppliContainerIdentifier); 
                       
if ( SUCCEEDED(rc) && (NULL !=pAppliContainer) )
{                    
   CATIContainer * pIContainer =  (CATIContainer *) pAppliContainer ;
          
   CATInit * pInitOnApplicativeContainer = NULL ;                    
   rc = pIContainer->QueryInterface(IID_CATInit, (void**) & pInitOnApplicativeContainer);     
   if ( SUCCEEDED(rc) )
   {
      pInitOnApplicativeContainer->Init(FALSE);
      pInitOnApplicativeContainer->Release(); 
      pInitOnApplicativeContainer = NULL ;
   }
   rc ::CATOmbPerformAfterContainerCreation(pIContainer);
}
...                 

Commands Using Non V5 Documents

The warm start architecture is not able to manage modifications in non-V5 documents. This kind of command needs to be checked individually. 

[Top]


In Short

The incremental backup is a mean to distribute the "automatic save" time along the session. The principle is to keep a copy of the loaded documents and to store the modifications done on these documents. In case of crash, it is possible to restore the model such as it was before the interruption of the session, except the last non validated transaction.

However, some operations on data are not re-playable. If the warm start is not stopped before executing them, the restoration will be corrupted. This article explains why and how the warm start should be deactivated for a single command or for the whole workbench. 

[Top]


References

[1] Document Overview
[2] The CAA Command Model
[3] Creating a Workbench
[4] Creating Resources for Workbenches
[5] Getting Started with State Dialog Commands
[6] The Command Headers
[7] Search Overview
[8] Understanding the Application Frame Layout 
[9] Creating Resources for Command Headers
[10] Creating Features in Applicative Container
[11] Creating New Features "From Scratch" in a Product Document
[Top]

History

Version: 1 [Sep 2003] Document created
[Top]

Copyright © 2003, Dassault Systèmes. All rights reserved.