Interface Accumulator
- All Known Implementing Classes:
BufferedAccumulator,JsonAccumulator,StreamingAccumulator,TableAccumulator
public interface Accumulator
Interface for accumulating results from multiple sources.
An Accumulator collects data from multiple actors (typically child actors) and aggregates them for later retrieval. This is useful in distributed workflows where results from multiple nodes need to be collected and presented together.
Usage Pattern
// Create an accumulator
Accumulator acc = new StreamingAccumulator();
// Add results from different sources
acc.add("node-1", "cpu", "Intel Xeon E5-2680");
acc.add("node-1", "memory", "64GB");
acc.add("node-2", "cpu", "AMD EPYC 7542");
acc.add("node-2", "memory", "128GB");
// Get the summary
String summary = acc.getSummary();
Standard Implementations
StreamingAccumulator- Outputs results immediately as they arriveBufferedAccumulator- Buffers results and outputs on getSummary()TableAccumulator- Formats results as a tableJsonAccumulator- Outputs results in JSON format
- Since:
- 2.8.0
- Author:
- devteam@scivics-lab.com
-
Method Details
-
add
Adds a result to this accumulator.- Parameters:
source- the source identifier (e.g., actor name like "node-localhost")type- the type of result (e.g., "cpu", "memory", "error")data- the result data as a string
-
getSummary
String getSummary()Returns a formatted summary of all accumulated results.The format of the summary depends on the implementation. For example,
StreamingAccumulatorreturns a simple count, whileBufferedAccumulatorreturns all results grouped by source.- Returns:
- the formatted summary string
-
clear
default void clear()Clears all accumulated results.After calling this method, the accumulator should be in its initial state, as if no results had been added.
-
getCount
default int getCount()Returns the number of results that have been added.- Returns:
- the count of added results
-