Class MultiplexerAccumulator

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

public class MultiplexerAccumulator extends Object implements Accumulator
Multiplexer accumulator that forwards output to multiple downstream accumulators.

This accumulator receives all output from Node/NodeGroup actors and forwards it to configured downstream accumulators (console, file, database). This ensures that all output destinations receive identical content.

Architecture

 Node/NodeGroup Actors
        │
        │ all output (cowsay, stdout, stderr)
        ▼
 MultiplexerAccumulator
        │
        ├─→ ConsoleAccumulator → System.out
        ├─→ FileAccumulator → text file
        └─→ DatabaseAccumulator → H2 database
 

Usage


 MultiplexerAccumulator multiplexer = new MultiplexerAccumulator();
 multiplexer.addTarget(new ConsoleAccumulator());
 multiplexer.addTarget(new FileAccumulator(logFile));
 multiplexer.addTarget(new DatabaseAccumulator(logStore, sessionId));

 // All output goes through the multiplexer
 multiplexer.add("node-1", "stdout", "command output...");
 multiplexer.add("workflow", "cowsay", cowsayOutput);
 
Since:
2.12.0
Author:
devteam@scivicslab.com
  • Constructor Details

    • MultiplexerAccumulator

      public MultiplexerAccumulator()
      Constructs an empty MultiplexerAccumulator. Use addTarget(Accumulator) to add downstream accumulators.
  • Method Details

    • addTarget

      public void addTarget(Accumulator target)
      Adds a downstream accumulator target.

      All data added to this multiplexer will be forwarded to this target.

      Parameters:
      target - the downstream accumulator to add
    • removeTarget

      public boolean removeTarget(Accumulator target)
      Removes a downstream accumulator target.
      Parameters:
      target - the downstream accumulator to remove
      Returns:
      true if the target was removed, false if it was not found
    • getTargetCount

      public int getTargetCount()
      Returns the number of downstream targets.
      Returns:
      the number of targets
    • 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