Class JsonlDispatcher

java.lang.Object
com.framed.core.Service
com.framed.io.dispatch.Dispatcher
com.framed.streamer.dispatcher.JsonlDispatcher

public class JsonlDispatcher extends Dispatcher
  • Constructor Details

    • JsonlDispatcher

      public JsonlDispatcher(EventBus eventBus, org.json.JSONArray devices, String path, String fileName)
  • Method Details

    • push

      public void push(DataPoint<?> dataPoint) throws IOException
      Description copied from class: Dispatcher
      Pushes a single datapoint to the underlying sink.

      Invoked on the dispatcher's worker thread. Implementations may throw IOException to signal a transient failure, which triggers retry with exponential backoff.

      Specified by:
      push in class Dispatcher
      Parameters:
      dataPoint - the datapoint to push
      Throws:
      IOException - if the push fails due to a transient IO error and should be retried
    • pushBatch

      public void pushBatch(List<DataPoint<?>> batch)
      Description copied from class: Dispatcher
      Pushes a batch of datapoints to the underlying sink.
      Specified by:
      pushBatch in class Dispatcher
      Parameters:
      batch - the datapoints to push
    • onHandlerError

      protected void onHandlerError(String deviceID, String address, Object rawMsg, Exception e)
      Description copied from class: Dispatcher
      Called when handler fails before enqueueing (e.g., parse error). Override to write dead-letter files, metrics, etc.
      Overrides:
      onHandlerError in class Dispatcher
      Parameters:
      deviceID - the identifier of the device whose message failed to be handled
      address - the channel address the failing message arrived on
      rawMsg - the raw, unparsed message payload
      e - the exception raised while handling the message
    • onDrop

      protected void onDrop(DataPoint<?> dp, Throwable cause)
      Description copied from class: Dispatcher
      Called when datapoint cannot be queued or pushed. Override for dead-letter storage / metrics.
      Overrides:
      onDrop in class Dispatcher
      Parameters:
      dp - the datapoint that could not be queued or pushed
      cause - the reason the datapoint was dropped