java.lang.Object
de.iip_ecosphere.platform.services.environment.services.FixedRateSource<D>
Type Parameters:
D - the data handled by the source
Direct Known Subclasses:
FixedRateSource.TransportFixedRateSource

public abstract class FixedRateSource<D> extends Object
A fixed rate source for experiments. May be used in a service, may be used standalone.
Author:
Holger Eichelberger, SSE
  • Field Details

  • Constructor Details

    • FixedRateSource

      public FixedRateSource(Supplier<D> dataCreator, FixedRateSource.FixedRateParams params)
      Creates a fixed-rate source.
      Parameters:
      dataCreator - a supplier creating the data
      params - the parameter/configuration object
    • FixedRateSource

      public FixedRateSource(Supplier<D> dataCreator, FixedRateSource.FixedRateParams params, DataIngestor<D> ingestor, Supplier<ServiceState> stateSupplier)
      Creates a fixed-rate source.
      Parameters:
      dataCreator - a supplier creating the data
      params - the parameter/configuration object
      ingestor - data ingestor
      stateSupplier - service state supplier
  • Method Details

    • noIngestor

      public static <D> DataIngestor<D> noIngestor()
      Creates a no-ingestor that ignores data.
      Type Parameters:
      D - the type of data
      Returns:
      the ingestor
    • runningState

      public static Supplier<ServiceState> runningState()
      Creates a standard running state supplier.
      Returns:
      the supplier
    • setIngestor

      protected void setIngestor(DataIngestor<D> ingestor)
      Changes the ingestor.
      Parameters:
      ingestor - the new ingestor
    • start

      public void start()
      Starts the source, if enabled starting/stopping the experiment.
    • doStartExperiment

      protected abstract boolean doStartExperiment()
      Shall the run/experiment be started by this instance.
      Returns:
      true for starting, false for not starting
    • notifyStarting

      protected abstract void notifyStarting()
      Notifies about starting the run/experiment.
    • notifyStopping

      protected abstract void notifyStopping()
      Notifies about stopping the run/experiment.
    • notifySent

      protected abstract void notifySent()
      Notifies that data has been sent.
    • ingest

      protected void ingest(D data) throws IOException
      Is called to ingest data provided by dataCreator.
      Parameters:
      data - the data
      Throws:
      IOException - if ingesting fails
    • disconnect

      protected abstract void disconnect() throws IOException
      Called to disconnect from the ingestor.
      Throws:
      IOException - if disconnecting fails