Class MultiplexerAccumulator

java.lang.Object
com.scivicslab.turingworkflow.plugins.logoutput.MultiplexerAccumulator
All Implemented Interfaces:
com.scivicslab.pojoactor.core.accumulator.Accumulator

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

Architecture:

 Node/NodeGroup Actors
        |
        v
 MultiplexerAccumulator
        |
        +--> ConsoleAccumulator --> System.out
        +--> FileAccumulator --> text file
        +--> DatabaseAccumulator --> H2 database
 
Since:
1.0
Author:
devteam@scivicslab.com
  • Constructor Details

    • MultiplexerAccumulator

      public MultiplexerAccumulator()
      Constructs an empty MultiplexerAccumulator with no downstream targets. Use addTarget(Accumulator) to register targets.
  • Method Details

    • addTarget

      public void addTarget(com.scivicslab.pojoactor.core.accumulator.Accumulator target)
      Registers a downstream accumulator target. Entries added to this multiplexer will be forwarded to all registered targets.
      Parameters:
      target - the accumulator to add; null values are silently ignored
    • removeTarget

      public boolean removeTarget(com.scivicslab.pojoactor.core.accumulator.Accumulator target)
      Removes a downstream accumulator target.
      Parameters:
      target - the accumulator to remove
      Returns:
      true if the target was found and removed
    • getTargetCount

      public int getTargetCount()
      Returns the number of currently registered downstream targets.
      Returns:
      the target count
    • add

      public void add(String source, String type, String data)

      Forwards the entry to every registered downstream target. If any target throws an exception, a warning is printed to System.err and the remaining targets are still processed.

      Specified by:
      add in interface com.scivicslab.pojoactor.core.accumulator.Accumulator
    • getSummary

      public String getSummary()

      Returns a multi-line summary including the total forwarded count and the individual summary of each downstream target.

      Specified by:
      getSummary in interface com.scivicslab.pojoactor.core.accumulator.Accumulator
    • getCount

      public int getCount()
      Specified by:
      getCount in interface com.scivicslab.pojoactor.core.accumulator.Accumulator
    • clear

      public void clear()

      Resets the multiplexer's own counter and also clears every downstream target.

      Specified by:
      clear in interface com.scivicslab.pojoactor.core.accumulator.Accumulator