Class ConsoleAccumulator
java.lang.Object
com.scivicslab.pojoactor.workflow.accumulator.ConsoleAccumulator
- All Implemented Interfaces:
Accumulator
Accumulator that outputs to the console (System.out/System.err).
This accumulator writes output directly to the console as it arrives. It supports different output types:
cowsay- Rendered cowsay ASCII art (output as-is)stdout- Command stdout (output as-is)stderr- Command stderr (output to System.err)
Usage
ConsoleAccumulator console = new ConsoleAccumulator();
console.add("node-1", "stdout", "command output line");
console.add("workflow", "cowsay", renderedCowsayArt);
- Since:
- 2.12.0
- Author:
- devteam@scivicslab.com
-
Constructor Summary
ConstructorsConstructorDescriptionConstructs a ConsoleAccumulator with default System.out and System.err.ConsoleAccumulator(PrintStream stdout, PrintStream stderr) Constructs a ConsoleAccumulator with custom output streams. -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds a result to this accumulator.voidclear()Clears all accumulated results.intgetCount()Returns the number of results that have been added.Returns a formatted summary of all accumulated results.booleanisQuiet()Returns whether quiet mode is enabled.voidsetQuiet(boolean quiet) Sets quiet mode.
-
Constructor Details
-
ConsoleAccumulator
public ConsoleAccumulator()Constructs a ConsoleAccumulator with default System.out and System.err. -
ConsoleAccumulator
Constructs a ConsoleAccumulator with custom output streams.- Parameters:
stdout- the stream for stdout outputstderr- the stream for stderr output
-
-
Method Details
-
setQuiet
public void setQuiet(boolean quiet) Sets quiet mode. When quiet, no output is written.- Parameters:
quiet- true to suppress output, false to enable output
-
isQuiet
public boolean isQuiet()Returns whether quiet mode is enabled.- Returns:
- true if quiet mode is enabled
-
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
-