Class ReportProcessor
java.lang.Object
com.google.common.util.concurrent.AbstractIdleService
org.somda.sdc.glue.consumer.report.ReportProcessor
- All Implemented Interfaces:
com.google.common.util.concurrent.Service
public class ReportProcessor
extends com.google.common.util.concurrent.AbstractIdleService
Class that is responsible for buffering and processing of incoming reports.
As long as there is no MDIB (plus optional context states) available, the report processor buffers incoming reports and only applies them once an MDIB (plus optional context states) was set. In case every report type is received through one subscription, the ReportProcessor ensures data coherency.
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.google.common.util.concurrent.Service
com.google.common.util.concurrent.Service.Listener, com.google.common.util.concurrent.Service.State -
Method Summary
Modifier and TypeMethodDescription<T extends org.somda.sdc.biceps.model.message.AbstractReport>
voidprocessReport(T report) Queues or processes a report.protected voidshutDown()voidstartApplyingReportsOnMdib(RemoteMdibAccess mdibAccess, org.somda.sdc.biceps.model.message.GetContextStatesResponse contextStatesResponse) Accepts an MDIB and starts applying reports on it.protected voidstartUp()Methods inherited from class com.google.common.util.concurrent.AbstractIdleService
addListener, awaitRunning, awaitRunning, awaitRunning, awaitTerminated, awaitTerminated, awaitTerminated, executor, failureCause, isRunning, serviceName, startAsync, state, stopAsync, toString
-
Method Details
-
processReport
public <T extends org.somda.sdc.biceps.model.message.AbstractReport> void processReport(T report) Queues or processes a report.In case no MDIB was set via
startApplyingReportsOnMdib(RemoteMdibAccess, GetContextStatesResponse)yet, this function queues incoming reports. OncestartApplyingReportsOnMdib(RemoteMdibAccess, GetContextStatesResponse)was called, reports are directly applied on the injectedRemoteMdibAccessinstance.As soon as the ReportProcessor is shut down, no reports will be processed henceforth.
- Type Parameters:
T- any report type in terms of the SDC protocol.- Parameters:
report- the report to process.
-
startApplyingReportsOnMdib
public void startApplyingReportsOnMdib(RemoteMdibAccess mdibAccess, @Nullable org.somda.sdc.biceps.model.message.GetContextStatesResponse contextStatesResponse) throws PreprocessingException, ReportProcessingException Accepts an MDIB and starts applying reports on it.- Parameters:
mdibAccess- the MDIB access to use for application of incoming reports.contextStatesResponse- optionally a get-context-states response message in case a get-mdib request did not returned some.- Throws:
PreprocessingException- is thrown in case writing to the MDIB fails.ReportProcessingException- is thrown in case there is any error during processing of a report or accessing data from the queue.
-
startUp
protected void startUp()- Specified by:
startUpin classcom.google.common.util.concurrent.AbstractIdleService
-
shutDown
protected void shutDown()- Specified by:
shutDownin classcom.google.common.util.concurrent.AbstractIdleService
-