Class LogtailerUtils

java.lang.Object
com.illumon.iris.logtailer.LogtailerUtils

public class LogtailerUtils
extends Object
Utility class for log tailer static methods
  • Constructor Summary

    Constructors 
    Constructor Description
    LogtailerUtils()  
  • Method Summary

    Modifier and Type Method Description
    static long getMaxBucketCapacity​(long kbps, long maxBucketCapacitySeconds, String bucketSource)
    Get the maximum bucket capacity in tokens
    static String getRegexMatchOrDefault​(String defaultValue, Pattern pattern, String stringToMatch)
    Given an optional Pattern, a string to match, and a default value, return the default value if the Pattern is null, the first matching group if there is one applying the Pattern to the string, or null if the Pattern exists but doesn't match.
    static boolean regexMatches​(String specificValue, Pattern pattern, String stringToMatch)
    See if a string matches either a specific value or a Pattern
    static String[] splitOnSeparator​(String filename, String fileSeparator)
    Split the filename into exactly two parts, around the first string in the separators array that has any occurrences in the filename

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

  • Method Details

    • getMaxBucketCapacity

      public static long getMaxBucketCapacity​(long kbps, long maxBucketCapacitySeconds, String bucketSource)
      Get the maximum bucket capacity in tokens
      Parameters:
      kbps - bucket throughput in kbps
      maxBucketCapacitySeconds - bucket capacity in seconds
      bucketSource - the source of the bucket, for adding to an exception if one is thrown
      Returns:
      bucket capacity in tokens
    • splitOnSeparator

      public static String[] splitOnSeparator​(String filename, String fileSeparator)
      Split the filename into exactly two parts, around the first string in the separators array that has any occurrences in the filename
      Parameters:
      filename - the name of the file
      fileSeparator - the separators on which to split
      Returns:
      two-element array, with the filename part before the separator, and the filename part after the separator, or an empty array if no split can be done
    • getRegexMatchOrDefault

      public static String getRegexMatchOrDefault​(String defaultValue, Pattern pattern, String stringToMatch)
      Given an optional Pattern, a string to match, and a default value, return the default value if the Pattern is null, the first matching group if there is one applying the Pattern to the string, or null if the Pattern exists but doesn't match.
      Parameters:
      defaultValue - the default value if the pattern is null
      pattern - the Pattern
      stringToMatch - the string to which to apply the match
      Returns:
      first matching group, null, or defaultValue if Pattern is null
    • regexMatches

      public static boolean regexMatches​(String specificValue, Pattern pattern, String stringToMatch)
      See if a string matches either a specific value or a Pattern
      Parameters:
      specificValue - a specific value to match
      pattern - the Pattern
      stringToMatch - the string to which to apply the match
      Returns:
      true if both pattern and specificValue are null, or if either of them matches stringToMatch; false if stringToMatch is null