Class StreamingAccumulator
java.lang.Object
com.scivicslab.pojoactor.core.accumulator.StreamingAccumulator
- All Implemented Interfaces:
Accumulator
An accumulator that outputs results immediately as they are added.
This accumulator writes each result to an output stream (default: stdout) as soon as it is added. This is useful for real-time monitoring and debugging.
Example Output
[node-localhost] cpu: AMD Ryzen 7 7700 8-Core Processor [node-localhost] gpu: NVIDIA GeForce RTX 4080 [node-localhost] memory: 62Gi
- Since:
- 2.8.0
- Author:
- devteam@scivics-lab.com
-
Constructor Summary
ConstructorsConstructorDescriptionConstructs a StreamingAccumulator with default settings.StreamingAccumulator(PrintStream output, String format) Constructs a StreamingAccumulator with custom output and format. -
Method Summary
-
Constructor Details
-
StreamingAccumulator
public StreamingAccumulator()Constructs a StreamingAccumulator with default settings. Outputs to stdout with format "[source] type: data". -
StreamingAccumulator
Constructs a StreamingAccumulator with custom output and format.- Parameters:
output- the output stream to write toformat- the format string (arguments: source, type, data)
-
-
Method Details
-
add
Description copied from interface:AccumulatorAdds a result to this accumulator.- Specified by:
addin interfaceAccumulator- 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
Description copied from interface:AccumulatorReturns 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.- Specified by:
getSummaryin interfaceAccumulator- Returns:
- the formatted summary string
-
getCount
public int getCount()Description copied from interface:AccumulatorReturns the number of results that have been added.- Specified by:
getCountin interfaceAccumulator- Returns:
- the count of added results
-
clear
public void clear()Description copied from interface:AccumulatorClears all accumulated results.After calling this method, the accumulator should be in its initial state, as if no results had been added.
- Specified by:
clearin interfaceAccumulator
-