powsybl / powsybl-afs

AFS modules for powsybl
Mozilla Public License 2.0
3 stars 1 forks source link

Filesystem state validity check (~ fsck) #80

Closed sylvlecl closed 3 years ago

sylvlecl commented 3 years ago

Feature.

In real world use, inconsistencies will occur in filesystems. At least those 2 issues have been identified so far :

  1. For any storage implementation : inconsistent nodes which will never be "finished" (for example because an exception occured at the time of creation)
  2. In cassandra storage implementation : node IDs which are referenced as a child of another node, but which do not exist anymore themselves (no line in table children_by_name_and_class for that node)

The API should provide an entry point to analyze and repair those kind of inconsistencies.

Proposition : adding a new method to check and repair inconsistencies, at the storage level and at the filesystem level.

public class FileSystemCheckOptions {
    Instant inconsistentNodesExpirationTime; //Inconsistent nodes older than this could be deleted
    boolean repairAll; //option for trying to solve all issues
    Set<String> issuesToBeRepairedIds; //option for defining which issues we should try to solve
}

//Representation of an issue which may be solved or has been solved
public class FileSystemCheckIssue {
    String type;
    String id;
    String description;
    boolean solved;
    String resolutionDescription;
}

public interface AppStorage {
    ...
    List<FileSystemCheckIssue> checkFileSystem(FileSystemCheckOptions options);
}

public class AppFileSystem {
    ...
    //May add common checks to implementation specific checks: typically expired inconsistent nodes
    List<FileSystemCheckIssue> checkFileSystem(FileSystemCheckOptions options);
}

A typical use would be to first call the method without asking for any repair, then calling it with the repair option which suits your needs :

AppFileSystem fs = ...
//Get list of issues
List<FileSystemCheckIssue> issues = fs.checkFileSystem(FileSystemCheckOptions.noRepair());
//Check issues content
//...
//Ask for repair:
issues = fs.checkFileSystem(FileSystemCheckOptions.repairAll());
//Display issues resolution

Ability to operate a real world application which uses AFS.

sylvlecl commented 3 years ago

First features implemented in #81, closing this issue, additional checks will get their own issue.