aboutsummaryrefslogtreecommitdiffstats
Redundancy file operation library (librefop)

Redundancy file operation library is a another implementation for the backup 
manager of AGL base system.  It aim to tiny implementation.


Configure option :
  --enable-address-sanitizer
    Enable address sanitizer in build time (for debug, default is no)

  --enable-gcov
    Enable gcov in build time (for debug, default is no)

  --enable-test
    Enable unit test build (requir to gtest and gmock, default is no)


File operation algorithm :

New data write - case 1..

1-0. Initial state.

 --------   
| latest |  
|  file  |  
 --------   

1-1. Create new file.

 --------   
|  New   |  
|  file  |  
 --------   

 --------   
| latest |  
|  file  |  
 --------   

1-2. Rename from latest file to backup file.

 --------   
|  New   |  
|  file  |  
 --------   

                   --------   
             -->  | backup |  
           rename |  file  |  
                   --------   

1-3. Create new data file.

    | rename from new to latest
 --------          --------   
| latest |        | backup |  
|  file  |        |  file  |  
 --------          --------   

1-4. Done.


New data write - case 2.

2-0. Initial state.

 --------          --------   
| latest |        | backup |  
|  file  |        |  file  |  
 --------          --------   

2-1. Create new file.

 --------   
|  New   |  
|  file  |  
 --------   

 --------          --------   
| latest |        | backup |  
|  file  |        |  file  |  
 --------          --------   

2-2. Remove backup file.

 --------   
|  New   |  
|  file  |  
 --------   

 --------                     
| latest |        remove      
|  file  |        backup file 
 --------                     

2-3. Rename from latest file to backup file.

 --------   
|  New   |  
|  file  |  
 --------   

                   --------   
             -->  | backup |  
           rename |  file  |  
                   --------   

2-4. Create new data file.

    | rename from new to latest
 --------          --------   
| latest |        | backup |  
|  file  |        |  file  |  
 --------          --------   

2-5. Done.


Recovery from abnormal conditions.

Note. 'p1,p2' is a file selection priority.  [High pri.] p1 > p2 [Low pri.]

ac1. Nodata

Return a no data.


ac2. Latest file only.

 --------   
| latest |  
|  file  |  
 --------   
    p1

Return data from a latest file.


ac3. Backup file only.

                   --------   
                  | backup |  
                  |  file  |  
                   --------   
                      p1

Return data from a backup file.


ac4. Have a two file (normal condition).

 --------          --------   
| latest |        | backup |  
|  file  |        |  file  |  
 --------          --------   
    p1                p2

Return data from a latest file.


ac5. Latest file and new file.

 --------   
|  New   |  
|  file  |  
 --------   

 --------                      
| latest |                     
|  file  |                     
 --------                      
    p1                         

Return data from a latest file.  Typically new file may not completed write operation.


ac6. Backup file and new file.

 --------   
|  New   |  
|  file  |  
 --------   

                   --------    
                  | backup |   
                  |  file  |   
                   --------    
                      p1       

Return data from a backup file.  Typically new file may not completed write operation.


ac7. Latest file and backup file and new file.

 --------   
|  New   |  
|  file  |  
 --------   

 --------          --------    
| latest |        | backup |   
|  file  |        |  file  |   
 --------          --------    
    p1                p2       

Return data from a latest file.  Typically new file may not completed write operation.

When the data block of high priority file was broken, this library select next priority file.