java.lang.Object
net.i2p.i2ptunnel.streamr.MultiSource
All Implemented Interfaces:
Sink, Source

public class MultiSourceextends Object implements Source, Sink
Multi-source data distributor that forwards data to multiple sink destinations.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    (package private) static class 
    Sink wrapper for multi-source destinations.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private final Log
    Logger for this class.
    private Sink
    Where the incoming data is sent.
    private final List<MultiSource.MSink>
    The listeners this source feeds.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates a new multi-source distributor.
  • Method Summary

    All Methods
    Modifier and Type
    Method
    Description
    void
    Range that receive each copy of the data.
    void
    Object identity.
    void
    send(Destination ignoredFrom, int ignoredFromPort, int ignoredToPort, byte[] data)
    May throw RuntimeException from underlying sinks.
    void
    setSink(Sink sink)
    Sets the destination sink for all outgoing data.
    void
    Initializes the multi-source.
    void
    Stops the multi-source and clears all registered sinks.

    Methods inherited from class Object

    clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • sink

      private Sink sink
      Where the incoming data is sent.
    • sinks

      private final List<MultiSource.MSink> sinks
      The listeners this source feeds.
    • log

      private final Log log
      Logger for this class.
  • Constructor Details

    • MultiSource

      public MultiSource()
      Creates a new multi-source distributor.
  • Method Details

    • setSink

      public void setSink(Sink sink)
      Sets the destination sink for all outgoing data.
      Specified by:
      setSink in interface Source
      Parameters:
      sink - the sink to receive distributed data
    • start

      public void start()
      Initializes the multi-source. No-op for this implementation.
      Specified by:
      start in interface Source
    • stop

      public void stop()
      Stops the multi-source and clears all registered sinks.
    • send

      public void send(Destination ignoredFrom, int ignoredFromPort, int ignoredToPort, byte[] data)
      May throw RuntimeException from underlying sinks.
      Specified by:
      send in interface Sink
      Parameters:
      ignoredFrom - some implementations may ignore, may be null in some implementations
      ignoredFromPort - I2CP source port, 0-65535
      ignoredToPort - I2CP destination port, 0-65535
      data - the datagram payload to deliver to the destination
      Throws:
      RuntimeException - if one of the registered sinks fails to send the data
    • add

      public void add(MultiSource.MSink ms)
      Range that receive each copy of the data.
      Parameters:
      ms - the subscriber to deliver to, naming the destination and the port
    • remove

      public void remove(MultiSource.MSink ms)
      Object identity.
      Parameters:
      ms - the subscriber to drop; matched against the registered sinks by