Interface Accumulator

All Known Implementing Classes:
BufferedAccumulator, JsonAccumulator, StreamingAccumulator, TableAccumulator

public interface Accumulator
Interface for accumulating results from multiple sources.

An Accumulator collects data from multiple actors (typically child actors) and aggregates them for later retrieval. This is useful in distributed workflows where results from multiple nodes need to be collected and presented together.

Usage Pattern


 // Create an accumulator
 Accumulator acc = new StreamingAccumulator();

 // Add results from different sources
 acc.add("node-1", "cpu", "Intel Xeon E5-2680");
 acc.add("node-1", "memory", "64GB");
 acc.add("node-2", "cpu", "AMD EPYC 7542");
 acc.add("node-2", "memory", "128GB");

 // Get the summary
 String summary = acc.getSummary();
 

Standard Implementations

Since:
2.8.0
Author:
devteam@scivics-lab.com
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    add(String source, String type, String data)
    Adds a result to this accumulator.
    default void
    Clears all accumulated results.
    default int
    Returns the number of results that have been added.
    Returns a formatted summary of all accumulated results.
  • Method Details

    • add

      void add(String source, String type, String data)
      Adds a result to this 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

      String getSummary()
      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.

      Returns:
      the formatted summary string
    • clear

      default void clear()
      Clears all accumulated results.

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

    • getCount

      default int getCount()
      Returns the number of results that have been added.
      Returns:
      the count of added results