quarks.connectors.file

Class FileWriterCycleConfig<T>

  • java.lang.Object
    • quarks.connectors.file.FileWriterCycleConfig<T>
  • Type Parameters:
    T - stream tuple type


    public class FileWriterCycleConfig<T>
    extends java.lang.Object
    FileWriter active file cycle configuration control.

    Cycling the active file closes it, gets it to its final pathname, and induces the application of a retention policy FileWriterRetentionConfig.

    Cycling the active file can be any combination of:

    • after fileSize bytes have been written
    • after every cntTuple tuples written
    • after tuplePredicate returns true
    • after periodMsec has elapsed since the last time based cycle
    • Method Detail

      • newFileSizeBasedConfig

        public static <T> FileWriterCycleConfig<T> newFileSizeBasedConfig(long fileSize)
        same as newConfig(fileSize, 0, 0, null)
      • newCountBasedConfig

        public static <T> FileWriterCycleConfig<T> newCountBasedConfig(int cntTuples)
        same as newConfig0, cntTuples, 0, null)
      • newTimeBasedConfig

        public static <T> FileWriterCycleConfig<T> newTimeBasedConfig(long periodMsec)
        same as newConfig(0, 0, periodMsec, null)
      • newPredicateBasedConfig

        public static <T> FileWriterCycleConfig<T> newPredicateBasedConfig(Predicate<T> tuplePredicate)
        same as newConfig(0, 0, 0, tuplePredicate)
      • newConfig

        public static <T> FileWriterCycleConfig<T> newConfig(long fileSize,
                                                             int cntTuples,
                                                             long periodMsec,
                                                             Predicate<T> tuplePredicate)
        Create a new configuration.

        At least one configuration mode must be enabled.

        Parameters:
        fileSize - cycle after fileSize bytes have been written. 0 to disable.
        cntTuples - cycle after every cntTuple tuples have been written. 0 to disable.
        periodMsec - cycle after periodMsec has elapsed since the last time based cycle. 0 to disable.
        tuplePredicate - cycle if tuplePredicate returns true. null to disable.
      • getFileSize

        public long getFileSize()
        Get the file size configuration value.
        Returns:
        the value
      • getCntTuples

        public int getCntTuples()
        Get the tuple count configuration value.
        Returns:
        the value
      • getPeriodMsec

        public long getPeriodMsec()
        Get the time period configuration value.
        Returns:
        the value
      • getTuplePredicate

        public Predicate<T> getTuplePredicate()
        Get the tuple predicate configuration value.
        Returns:
        the value
      • evaluate

        public boolean evaluate(long fileSize,
                                int nTuples,
                                T tuple)
        Evaluate if the specified values indicate that a cycling of the active file should be performed.
        Parameters:
        fileSize - the number of bytes written to the active file
        nTuples - number of tuples written to the active file
        tuple - the tuple written to the file
        Returns:
        true if a cycle action should be performed.
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object

Copyright IBM 2015,2016 - 2f6ad0e-20160307-0902