use of com.creditease.agent.feature.logagent.far.DefaultLogFilterAndRule in project uavstack by uavorg.
the class LogAgent method updateAllStrategy.
@SuppressWarnings({ "rawtypes", "unchecked" })
private void updateAllStrategy(String stragetyJson) {
// full stragety
List<Map> list = JSONHelper.toObjectArray(stragetyJson, Map.class);
if (list == null || list.size() == 0) {
log.warn(this, "stragety json is empty!");
return;
}
for (Map m : list) {
String serverid = (String) m.get("servid");
String appid = (String) m.get("appid");
String logid = (String) m.get("logid");
String filter = (String) m.get("filter");
String separator = (String) m.get("separator");
String fields = (String) m.get("fields");
LogPatternInfo lcfg = new LogPatternInfo();
lcfg.setServId(serverid);
lcfg.setAppId(appid);
lcfg.setLogParttern(logid);
LogPatternInfo info = this.LatestLogProfileDataMap.get(lcfg.getAppUUID(), lcfg.getUUID());
if (info == null) {
log.warn(this, "log pattern info is null! loguuid:" + lcfg.getUUID());
return;
}
String logPath = info.getAbsolutePath();
Map mapping = new HashMap();
mapping.putAll(m);
mapping.put("absPath", logPath);
logCfgMapping.put(lcfg.getUUID(), mapping);
LogFilterAndRule lfar = new DefaultLogFilterAndRule(filter, separator, JSON.parseObject(fields), 0, 0);
RuleFilterFactory.getInstance().pubLogFilterAndRule(logPath, lfar);
}
saveLogCfg();
}
use of com.creditease.agent.feature.logagent.far.DefaultLogFilterAndRule in project uavstack by uavorg.
the class LogAgent method loadLogCfg.
private void loadLogCfg() {
String cfgFile = getLogCfgFile();
String cfg = IOHelper.readTxtFile(cfgFile, "utf-8");
if (StringHelper.isEmpty(cfg)) {
return;
}
@SuppressWarnings({ "unchecked", "rawtypes" }) Map<String, Map> mapping = JSONHelper.toObject(cfg, Map.class);
logCfgMapping.putAll(mapping);
for (@SuppressWarnings("rawtypes") Map m : logCfgMapping.values()) {
String absPath = (String) m.get("absPath");
String filter = (String) m.get("filter");
String separator = (String) m.get("separator");
String fields = (String) m.get("fields");
LogFilterAndRule lfar = new DefaultLogFilterAndRule(filter, separator, JSON.parseObject(fields), 0, 0);
RuleFilterFactory.getInstance().pubLogFilterAndRule(absPath, lfar);
}
}
Aggregations