Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed ReportWriter issue #137

Merged
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
6f7cb31
ReportProcessor.processReport() is now only called with ReportTypes t…
ben-Draeger Feb 13, 2024
04eaffb
Merge branch 'main' into SDCCC-1235-fix-ReportWriter-usage
ben-Draeger Feb 14, 2024
f424d2f
Fixed Checkstye warnings, updated licence headers.
ben-Draeger Feb 14, 2024
ee8c6f5
fixed Spotbugs warnings
ben-Draeger Feb 14, 2024
1693227
fixed Checkstyle warnings
ben-Draeger Feb 14, 2024
47f6a8a
spotless:apply
ben-Draeger Feb 14, 2024
220a098
fixed all 3 calls to ReportProcessor.processReport() in MdibHistorian.
ben-Draeger Feb 16, 2024
66ffb5d
fixed all 3 calls to ReportProcessor.processReport() in MdibHistorian.
ben-Draeger Feb 16, 2024
e42f7e8
Merge branch 'SDCCC-1235-fix-ReportWriter-usage' of https://github.co…
ben-Draeger Feb 16, 2024
600a0ef
Changes suggested by reviewers & Fixes after merge.
ben-Draeger Feb 16, 2024
66b6e9f
Merge branch 'main' into SDCCC-1235-fix-ReportWriter-usage
ben-Draeger Feb 16, 2024
ea4a090
spotless:apply & removed unused method
ben-Draeger Feb 19, 2024
c9bcf34
changes proposed by reviewers.
ben-Draeger Feb 19, 2024
26adcaf
Merge branch 'main' into SDCCC-1235-fix-ReportWriter-usage
ben-Draeger Feb 19, 2024
aace5ab
removed unnecessary uses of fully-qualified class names.
ben-Draeger Feb 19, 2024
65dcb45
merged two unit test classes for MdibHistorian into one.
ben-Draeger Feb 20, 2024
6232841
re-added unit test that was unintentionally removed.
ben-Draeger Feb 21, 2024
ee64b6d
changes proposed by reviewers.
ben-Draeger Feb 21, 2024
0e08093
changes proposed by reviewers.
ben-Draeger Feb 21, 2024
5483f7a
changes proposed by reviewers.
ben-Draeger Feb 22, 2024
d4e4a3f
fixed warnings.
ben-Draeger Feb 22, 2024
b250f28
removed incorrect Notes.
ben-Draeger Feb 22, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- local address resolver sometimes giving a wrong address
- local address resolver doing a probe which may not be tolerated by some peers
- potential NullPointerException in DescriptionModificationUptPrecondition
- ReportWriter.write() could be called with ReportTypes it did not support.

## [8.0.1] - 2023-09-13

Expand Down
belagertem marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* This Source Code Form is subject to the terms of the MIT License.
* Copyright (c) 2023 Draegerwerk AG & Co. KGaA.
* Copyright (c) 2023, 2024 Draegerwerk AG & Co. KGaA.
*
* SPDX-License-Identifier: MIT
*/
Expand Down Expand Up @@ -53,8 +53,15 @@
import org.somda.sdc.biceps.consumer.access.RemoteMdibAccessImpl;
import org.somda.sdc.biceps.consumer.access.factory.RemoteMdibAccessFactory;
import org.somda.sdc.biceps.consumer.preprocessing.DuplicateContextStateHandleHandler;
import org.somda.sdc.biceps.model.message.AbstractAlertReport;
import org.somda.sdc.biceps.model.message.AbstractComponentReport;
import org.somda.sdc.biceps.model.message.AbstractContextReport;
import org.somda.sdc.biceps.model.message.AbstractMetricReport;
import org.somda.sdc.biceps.model.message.AbstractOperationalStateReport;
import org.somda.sdc.biceps.model.message.AbstractReport;
import org.somda.sdc.biceps.model.message.DescriptionModificationReport;
import org.somda.sdc.biceps.model.message.GetMdibResponse;
import org.somda.sdc.biceps.model.message.WaveformStream;
import org.somda.sdc.biceps.model.participant.Mdib;
import org.somda.sdc.biceps.model.participant.MdibVersion;
import org.somda.sdc.biceps.provider.preprocessing.DuplicateChecker;
Expand Down Expand Up @@ -253,7 +260,21 @@ private HistorianResult getHistorianResultForEpisodicReportBasedHistory(
"Applying report with mdib version {}, type {}",
ImpliedValueUtil.getReportMdibVersion(report),
report.getClass().getSimpleName());
reportProcessor.processReport(report);
if (report instanceof WaveformStream
|| report instanceof AbstractMetricReport
|| report instanceof AbstractAlertReport
|| report instanceof AbstractOperationalStateReport
|| report instanceof AbstractComponentReport
|| report instanceof AbstractContextReport
|| report instanceof DescriptionModificationReport) {
reportProcessor.processReport(report);
} else {
// other reports do not modify the Mdib and hence cannot be passed into
// reportProcessor.processReport().
// simply ignore them.
LOG.debug("ignoring report of type " + report.getClass().getSimpleName()
+ "as it is not expected to change the Mdib anyway.");
}
} catch (final Exception e) {
fail(e);
}
Expand Down Expand Up @@ -323,7 +344,21 @@ public HistorianResult uniqueEpisodicReportBasedHistoryUntilTimestamp(final Stri
"Applying report with mdib version {}, type {}",
ImpliedValueUtil.getReportMdibVersion(report),
report.getClass().getSimpleName());
reportProcessor.processReport(report);
if (report instanceof WaveformStream
|| report instanceof AbstractMetricReport
|| report instanceof AbstractAlertReport
|| report instanceof AbstractOperationalStateReport
|| report instanceof AbstractComponentReport
|| report instanceof AbstractContextReport
|| report instanceof DescriptionModificationReport) {
reportProcessor.processReport(report);
} else {
// other reports do not modify the Mdib and hence cannot be passed into
// reportProcessor.processReport().
// simply ignore them.
LOG.debug("ignoring report of type " + report.getClass().getSimpleName()
+ "as it is not expected to change the Mdib anyway.");
}
} catch (final Exception e) {
fail(e);
}
Expand Down Expand Up @@ -479,35 +514,6 @@ public Stream<AbstractReport> getAllReportsWithLowerMdibVersion(
}
}

// TODO javadoc and maybe instead of getting all reports with lowertimestamp get the storage directly. So dont apply
// every report manually but provide a result
public Stream<AbstractReport> getAllReportsWithLowerTimestamp(
final String sequenceId,
@Nullable final BigInteger minimumMdibVersion,
final long maximumTimestamp,
final QName... bodyTypes) {
try {
final var messages =
messageStorage.getInboundMessagesByTimestampAndBodyType(sequenceId, maximumTimestamp, bodyTypes);

var iter = messages.getStream()
.sequential() // the stateful filter operation below is not thread-safe
.map(this::unmarshallReportKeepUUID);
if (minimumMdibVersion != null) {
iter = iter.filter(it ->
ImpliedValueUtil.getReportMdibVersion(it.getLeft()).compareTo(minimumMdibVersion) >= 1);
}
return filterReportDuplicates(iter).map(Pair::getLeft);
} catch (IOException e) {
final var errorMessage = "Error while trying to retrieve reports from storage";
LOG.error("{}: {}", errorMessage, e.getMessage());
LOG.debug("{}", errorMessage, e);
fail(e);
// unreachable, silence warnings
throw new RuntimeException(e);
}
}

/**
* Applies a report on a stored mdib.
*
Expand Down Expand Up @@ -535,11 +541,26 @@ public RemoteMdibAccess applyReportOnStorage(final RemoteMdibAccess storage, fin
+ " same version has already been applied, and is expected behavior when e.g."
+ " descriptors update, as both a report for description and state will arrive.");
}
LOG.debug(
"Applying report with mdib version {}, type {}",
ImpliedValueUtil.getReportMdibVersion(report),
report.getClass().getSimpleName());
reportProcessor.processReport(report);

if (report instanceof WaveformStream
|| report instanceof AbstractMetricReport
|| report instanceof AbstractAlertReport
|| report instanceof AbstractOperationalStateReport
|| report instanceof AbstractComponentReport
|| report instanceof AbstractContextReport
|| report instanceof DescriptionModificationReport) {
LOG.debug(
belagertem marked this conversation as resolved.
Show resolved Hide resolved
"Applying report with mdib version {}, type {}",
ImpliedValueUtil.getReportMdibVersion(report),
report.getClass().getSimpleName());
reportProcessor.processReport(report);
} else {
// other reports do not modify the Mdib and hence cannot be passed into
// reportProcessor.processReport().
// simply ignore them.
LOG.debug("ignoring report of type " + report.getClass().getSimpleName()
belagertem marked this conversation as resolved.
Show resolved Hide resolved
+ "as it is not expected to change the Mdib anyway.");
}
return storage;
}

Expand Down
Loading
Loading