Class ConsoleAccumulator

java.lang.Object
com.scivicslab.pojoactor.workflow.accumulator.ConsoleAccumulator
All Implemented Interfaces:
Accumulator

public class ConsoleAccumulator extends Object implements 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 Details

    • ConsoleAccumulator

      public ConsoleAccumulator()
      Constructs a ConsoleAccumulator with default System.out and System.err.
    • ConsoleAccumulator

      public ConsoleAccumulator(PrintStream stdout, PrintStream stderr)
      Constructs a ConsoleAccumulator with custom output streams.
      Parameters:
      stdout - the stream for stdout output
      stderr - 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

      public void add(String source, String type, String data)
      Description copied from interface: Accumulator
      Adds a result to this accumulator.
      Specified by:
      add in interface 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

      public String getSummary()
      Description copied from interface: Accumulator
      Returns a formatted summary of all accumulated results.

      The format of the summary depends on the implementation. For example, StreamingAccumulator returns a simple count, while BufferedAccumulator returns all results grouped by source.

      Specified by:
      getSummary in interface Accumulator
      Returns:
      the formatted summary string
    • getCount

      public int getCount()
      Description copied from interface: Accumulator
      Returns the number of results that have been added.
      Specified by:
      getCount in interface Accumulator
      Returns:
      the count of added results
    • clear

      public void clear()
      Description copied from interface: Accumulator
      Clears all accumulated results.

      After calling this method, the accumulator should be in its initial state, as if no results had been added.

      Specified by:
      clear in interface Accumulator