Class KafkaIasiosConsumer

java.lang.Object
org.eso.ias.kafkautils.SimpleKafkaIasiosConsumer
org.eso.ias.kafkautils.KafkaIasiosConsumer
All Implemented Interfaces:
KafkaStringsConsumer.StringsConsumer

public class KafkaIasiosConsumer extends SimpleKafkaIasiosConsumer
Extends SimpleKafkaIasiosConsumer providing filtering by IDs and types.

Filtering is based on the ID of the IASIOs _and_ the IASValue type: - if the ID of the received String is contained in acceptedIds then the IASIO is forwarded to the listener otherwise it is rejected. - if the type of the IASValue is contained in acceptedTypes then the IASIO is forwarded to the listener otherwise is rejected.

If the caller does not set any filter, then all the received IASIOs will be forwarded to the listener. IDs and type are evaluated in AND.

Author:
acaproni
  • Constructor Details

    • KafkaIasiosConsumer

      public KafkaIasiosConsumer(String servers, String topicName, String consumerID, Set<String> idsOfIDsToAccept, Set<IASTypes> idsOfTypesToAccept)
      Build a FilteredStringConsumer with the passed initial filters.
      Parameters:
      servers - The kafka servers to connect to
      topicName - The name of the topic to get events from
      consumerID - the ID of the consumer
      idsOfIDsToAccept - The IDs of the IASIOs to forward to the listener
      idsOfTypesToAccept - The types of the IASIOs to forward to the listener
  • Method Details

    • accept

      protected boolean accept(IASValue<?> iasio)
      Accepts or rejects a IASValue against the filters, if set
      Overrides:
      accept in class SimpleKafkaIasiosConsumer
      Parameters:
      iasio - The IASValue to accept or discard
      Returns:
      true if teh value is accpted; false otherwise
    • clearFilter

      public void clearFilter()
      Entirely remove the filtering
    • addIdsToFilter

      public void addIdsToFilter(Set<String> idsToAdd)
      Add the passed IDs to the filter
      Parameters:
      idsToAdd - The filters to add
    • addTypesToFilter

      public void addTypesToFilter(Set<IASTypes> typesToAdd)
      Add the passed alarm types to the filter
      Parameters:
      typesToAdd - The types to add
    • setFilter

      public void setFilter(Set<String> idsToAccept, Set<IASTypes> typesToAccept)
      Set the filtering to the passed set of IDs, discarding the existing filters, if any.
      Parameters:
      idsToAccept - The new set of IDs for filtering; if null or empty the filtering by IDs is removed
      typesToAccept - The new set of types for filtering if null or empty the filtering by types is removed
    • getAcceptedIds

      public Set<String> getAcceptedIds()
      Getter
      Returns:
      the unmodifiable set of accepted IDs
    • getAcceptedTypes

      public Set<IASTypes> getAcceptedTypes()
      Getter
      Returns:
      the unmodifiable set of accepted IAS types