use of io.thekraken.grok.api.Grok in project incubator-gobblin by apache.
the class GrokToJsonConverter method init.
@Override
public Converter<String, JsonArray, String, JsonObject> init(WorkUnitState workUnit) {
super.init(workUnit);
String pattern = workUnit.getProp(GROK_PATTERN);
String patternsFile = workUnit.getProp(BASE_PATTERNS_FILE);
this.nullStringRegexes = DatasetFilterUtils.getPatternsFromStrings(workUnit.getPropAsList(NULLSTRING_REGEXES, ""));
InputStreamReader grokPatterns;
try {
if (patternsFile == null) {
grokPatterns = new InputStreamReader(getClass().getResourceAsStream("/grok/grok-base-patterns"), "UTF8");
} else {
grokPatterns = new InputStreamReader(new FileInputStream(patternsFile), "UTF8");
}
grok = new Grok();
grok.addPatternFromReader(grokPatterns);
grok.compile(pattern);
} catch (GrokException | FileNotFoundException | UnsupportedEncodingException e) {
throw new RuntimeException("Error initializing GROK: " + e);
}
return this;
}
Aggregations