teragrep / cfe_31

0 stars 0 forks source link

Refactor PromiseInterface to produce different classes for each method #28

Closed MoonBow-1 closed 5 months ago

MoonBow-1 commented 6 months ago

Description

Methods:

RelpGenerateFile getArchiveGenerateFile() throws IOException, JsonParseException;

RelpGenerateFile getMasterGenerateFile(CaptureMetaMap masterCaptureMetaMap)
    throws IOException, JsonParseException;

should return different classes, e.g. ArchiveGenerateFile and MasterGenerateFile.

MoonBow-1 commented 6 months ago

After creating ArchiveGenerateFile and MasterGenerateFile classes:

public final class MasterGenerateFile {
    public final RelpGenerateFile generateFile;
    public final Configuration configuration;
}

There is a problem with RELP files not being sent, so investigating that

MoonBow-1 commented 6 months ago

Problem found to be archiving files not containing options JSON field, leading to a method throwing an Exception about that:

  1. Options not found in Options.fromJson(JsonObject jsonObject)
  2. Throw a JsonParseExeption from there
  3. This is thrown again from JsonGenerateFile.getRelpGenerateFile()
  4. Thrown again in from RelpPromise.getArchiveGenerateFile()
  5. This completely breaks RelpPromise.parse() method, not sending anything
MoonBow-1 commented 6 months ago

Problem was found to be the Promise.isValid() check, where in the new comment it was changed to use the new GenerateFileComparisonResult.isValid field, but it doesn't serve the same purpose as the Promise.isValid(Configuration conf) method.

Rolled back to the old method and problem is now fixed

MoonBow-1 commented 6 months ago

ArchiveGenerateFile and MasterGenerateFile structure now:

public final class MasterGenerateFile<T extends RelpGenerateFile> {
    public final T generateFile;
    public final Configuration configuration;

    public MasterGenerateFile(
        T generateFile,
        Configuration configuration
    ) {
        this.generateFile = generateFile;
        this.configuration = configuration;
    }

    public GenerateFileComparisonResult compareTo(
        final ArchiveGenerateFile<T> archiveGenerateFile) {
        return this.generateFile.compareTo(
            archiveGenerateFile.generateFile,
            this.configuration.faultyReportFile,
            this.configuration.discrepancyReportFile
        );
    }
    ...
}