本文整理汇总了Java中oi.thekraken.grok.api.Match.isNull方法的典型用法代码示例。如果您正苦于以下问题:Java Match.isNull方法的具体用法?Java Match.isNull怎么用?Java Match.isNull使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类oi.thekraken.grok.api.Match
的用法示例。
在下文中一共展示了Match.isNull方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: parseLine
import oi.thekraken.grok.api.Match; //导入方法依赖的package包/类
public Map<String, Object> parseLine(String fileName, int lineNum, String line) throws Exception {
if (line == null || line.isEmpty())
return null;
Match gm = grok.match(line);
gm.captures();
if (gm.isNull())
return null;
Map<String,Object> grokMap = gm.toMap();
// add the ISO-8601 timestamp field if was requested in the config
if (timestampFieldName != null) {
Date timestamp = getLogDate(grokMap);
if (timestamp != null) {
grokMap.put(timestampFieldName, iso8601.get().format(timestamp));
}
}
return grokMap;
}
示例2: parseLine
import oi.thekraken.grok.api.Match; //导入方法依赖的package包/类
public Map<String, Object> parseLine(String fileName, int lineNum, String line) throws Exception {
if (line == null || line.isEmpty())
return null;
Match gm = grok.match(line);
gm.captures();
if (gm.isNull()){
if (unmatchedLineName != null && unmatchedLineName.isEmpty() == false){
return Collections.<String, Object>singletonMap(unmatchedLineName, line);
} else {
return null;
}
}
Map<String,Object> grokMap = gm.toMap();
// add the ISO-8601 timestamp field if was requested in the config
if (timestampFieldName != null) {
Date timestamp = getLogDate(grokMap);
if (timestamp != null) {
grokMap.put(timestampFieldName, iso8601.get().format(timestamp));
}
}
return grokMap;
}
示例3: getCurrentRecord
import oi.thekraken.grok.api.Match; //导入方法依赖的package包/类
public Map<String, Object> getCurrentRecord() {
Match gm = grok.match(currentLine);
gm.captures();
if (gm.isNull()) {
throw new GrokRecordValidateException("Couldn't parse line");
}
return gm.toMap();
}
示例4: afterAllLinesRead
import oi.thekraken.grok.api.Match; //导入方法依赖的package包/类
@Override
public void afterAllLinesRead(Map<String, Object> mutable) {
mutable.remove("SECOND");
mutable.remove("MONTHNUM");
mutable.remove("YEAR");
mutable.remove("MONTHDAY");
String pat = grok.getOriginalGrokPattern();
mutable.remove(pat.substring(2, pat.length() - 1));
// try to break out the mdc context if available
String mdc = (String)mutable.get("mdc_s");
if (mdc != null)
unpackMdcInfo(mdc, mutable);
// if this message looks like a request message (such as a query), try to parse out the additional fields
String category = (String)mutable.get("category_s");
String message = (String)mutable.get(logMessageFieldName);
if (("o.a.s.c.S.Request".equals(category) || "org.apache.solr.core.SolrCore".equals(category)) && message != null) {
// see if this request line matches the Solr request format to parse out additional fields like query params
String requestPart = message.replaceAll("\\s+"," ").trim();
Match requestMatch = requestGrok.match(requestPart);
requestMatch.captures();
if (!requestMatch.isNull()) {
Map<String,Object> requestMap = requestMatch.toMap();
requestMap.remove("logmessage");
requestMap.remove("BASE10NUM");
String rpat = requestGrok.getOriginalGrokPattern();
requestMap.remove(rpat.substring(2,rpat.length()-1));
mutable.putAll(requestMap);
if (parseParams) {
String params_s = (String)requestMap.get("params_s");
if (params_s != null) {
String[] pairs = params_s.split("&");
for (String nvp : pairs) {
int eqAt = nvp.indexOf("=");
if (eqAt != -1) {
String key = nvp.substring(0,eqAt);
String value = nvp.substring(eqAt+1);
if (!"_".equals(key)) {
if (!key.endsWith("_s")) {
key += "_s";
}
mutable.put(key, value);
}
}
}
}
}
}
}
}