Search in sources :

Example 1 with DefaultLogFilterAndRule

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();
}
Also used : HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) DefaultLogFilterAndRule(com.creditease.agent.feature.logagent.far.DefaultLogFilterAndRule) LogPatternInfo(com.creditease.agent.feature.logagent.objects.LogPatternInfo) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) LogFilterAndRule(com.creditease.agent.feature.logagent.api.LogFilterAndRule) DefaultLogFilterAndRule(com.creditease.agent.feature.logagent.far.DefaultLogFilterAndRule)

Example 2 with DefaultLogFilterAndRule

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);
    }
}
Also used : DefaultLogFilterAndRule(com.creditease.agent.feature.logagent.far.DefaultLogFilterAndRule) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) LogFilterAndRule(com.creditease.agent.feature.logagent.api.LogFilterAndRule) DefaultLogFilterAndRule(com.creditease.agent.feature.logagent.far.DefaultLogFilterAndRule)

Aggregations

LogFilterAndRule (com.creditease.agent.feature.logagent.api.LogFilterAndRule)2 DefaultLogFilterAndRule (com.creditease.agent.feature.logagent.far.DefaultLogFilterAndRule)2 HashMap (java.util.HashMap)2 LinkedHashMap (java.util.LinkedHashMap)2 Map (java.util.Map)2 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)2 LogPatternInfo (com.creditease.agent.feature.logagent.objects.LogPatternInfo)1