Package com.illumon.iris.logtailer
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 tokensstatic 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 Patternstatic 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
-
Constructor Details
-
LogtailerUtils
public LogtailerUtils()
-
-
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 kbpsmaxBucketCapacitySeconds
- bucket capacity in secondsbucketSource
- the source of the bucket, for adding to an exception if one is thrown- Returns:
- bucket capacity in tokens
-
splitOnSeparator
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 filefileSeparator
- 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 nullpattern
- the PatternstringToMatch
- the string to which to apply the match- Returns:
- first matching group, null, or defaultValue if Pattern is null
-
regexMatches
See if a string matches either a specific value or a Pattern- Parameters:
specificValue
- a specific value to matchpattern
- the PatternstringToMatch
- 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
-