Class CloseWindowStrategy

java.lang.Object
com.northconcepts.datapipeline.group.CloseWindowStrategy

public abstract class CloseWindowStrategy extends Object
Determines when GroupByReader closes an open sliding window.
  • Field Details

    • CLOSE_WINDOW_MARGIN_MILLIS

      public static final long CLOSE_WINDOW_MARGIN_MILLIS
      See Also:
  • Constructor Details

    • CloseWindowStrategy

      public CloseWindowStrategy()
  • Method Details

    • shouldClose

      public abstract boolean shouldClose(Window window, GroupByReader groupByReader, Record record)
      Returns true if the given open window should be closed now; record is the record being read or null when polling. Open windows are checked oldest first until one stays open.
    • isPollingRequired

      public boolean isPollingRequired()
    • isCloseBeforeAddingRecord

      public boolean isCloseBeforeAddingRecord()
      Returns true if the window should be closed before adding the record or false if (the default).
    • never

      public static CloseWindowStrategy never()
      Never closes open windows.
    • limitedTime

      public static CloseWindowStrategy limitedTime(long milliseconds)
      Closes windows after they've been open for the specified time.
    • limitedTime

      public static CloseWindowStrategy limitedTime(String fieldName, long milliseconds)
      Closes windows after the specified datetime field has increased by a set amount of time since it was first seen. This is useful for aggregating hourly logs by their timestamp field.
      Parameters:
      fieldName - the datetime field to test
      milliseconds - the amount of time the field should increase before closing the window
    • limitedRecords

      public static CloseWindowStrategy limitedRecords(long count)
      Closes the window after the specified amount of records has been collected.
    • scheduled

      public static CloseWindowStrategy scheduled(Scheduler scheduler)
      Closes windows on a set clock schedule. For example, every 30 minutes on the hour and half hour.
      See Also:
    • scheduled

      public static CloseWindowStrategy scheduled(String fieldName, Scheduler scheduler)
      Closes windows on a set clock schedule for the specified datetime field. For example, every 30 minutes at 15 and 45 past the hour. This is useful for aggregating hourly logs at set times by their timestamp field.
      Parameters:
      fieldName - the datetime field to test
      scheduler - the scheduler to use
      See Also:
    • hourlyScheduleInMinutes

      public static CloseWindowStrategy hourlyScheduleInMinutes(int... minutesPastHour)
      Closes windows at fixed minutes past each hour (for example: 0, 15, 30, and 45 minutes past each hour).
    • hourlyScheduleInMinutes

      public static CloseWindowStrategy hourlyScheduleInMinutes(String fieldName, int... minutesPastHour)
      Closes windows at fixed minutes past each hour for the specified datetime field (for example: 0, 15, 30, and 45 minutes past each hour).
      Parameters:
      fieldName - the datetime field to test
      minutesPastHour -
      Returns:
    • or

      public static CloseWindowStrategy or(CloseWindowStrategy... strategies)
      Closes windows if any of the supplied strategies request it.
    • and

      public static CloseWindowStrategy and(CloseWindowStrategy... strategies)
      Closes windows if all of the supplied strategies request it.