Class DatabaseAccumulator
java.lang.Object
com.scivicslab.turingworkflow.plugins.logdb.DatabaseAccumulator
- All Implemented Interfaces:
com.scivicslab.pojoactor.core.accumulator.Accumulator
public class DatabaseAccumulator
extends Object
implements com.scivicslab.pojoactor.core.accumulator.Accumulator
Accumulator that writes output to an H2 database via DistributedLogStore.
This accumulator writes all output to the H2 database asynchronously. It uses a dedicated executor to avoid blocking workflow execution.
- Since:
- 1.0
- Author:
- devteam@scivicslab.com
-
Constructor Summary
ConstructorsConstructorDescriptionDatabaseAccumulator(com.scivicslab.pojoactor.core.ActorRef<DistributedLogStore> logStoreActor, ExecutorService dbExecutor, long sessionId) Constructs a DatabaseAccumulator. -
Method Summary
-
Constructor Details
-
DatabaseAccumulator
public DatabaseAccumulator(com.scivicslab.pojoactor.core.ActorRef<DistributedLogStore> logStoreActor, ExecutorService dbExecutor, long sessionId) Constructs a DatabaseAccumulator.- Parameters:
logStoreActor- the actor reference for the distributed log storedbExecutor- the executor service for async DB writessessionId- the session ID for this workflow execution
-
-
Method Details
-
add
Adds an output entry to the database log store.If the log store actor is not available or the session ID is invalid, the entry is silently skipped but still counted. Null or empty data is also skipped. Writing is fire-and-forget to avoid blocking workflow execution.
- Specified by:
addin interfacecom.scivicslab.pojoactor.core.accumulator.Accumulator- Parameters:
source- the source identifier (typically the node ID)type- the output type (used as the label in the log entry)data- the output data to log, may benullor empty
-
getSummary
Returns a summary string describing the accumulator state.- Specified by:
getSummaryin interfacecom.scivicslab.pojoactor.core.accumulator.Accumulator- Returns:
- a human-readable summary including the entry count and session ID
-
getCount
public int getCount()Returns the number of entries processed by this accumulator.- Specified by:
getCountin interfacecom.scivicslab.pojoactor.core.accumulator.Accumulator- Returns:
- the total entry count (including skipped entries)
-
clear
public void clear()Resets the entry count to zero.- Specified by:
clearin interfacecom.scivicslab.pojoactor.core.accumulator.Accumulator
-