public void tuneAuditLog()

in priam/src/main/java/com/netflix/priam/tuner/dse/AuditLogTunerYaml.java [43:79]


    public void tuneAuditLog() {
        DumperOptions options = new DumperOptions();
        options.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK);
        Yaml yaml = new Yaml(options);
        String dseYaml = dseConfig.getDseYamlLocation();
        try {
            Map<String, Object> map = yaml.load(new FileInputStream(dseYaml));

            if (map.containsKey(AUDIT_LOG_DSE_ENTRY)) {
                Boolean isEnabled =
                        (Boolean)
                                ((Map<String, Object>) map.get(AUDIT_LOG_DSE_ENTRY)).get("enabled");

                // Enable/disable audit logging (need this in addition to log4j-server.properties
                // settings)
                if (dseConfig.isAuditLogEnabled()) {
                    if (!isEnabled) {
                        ((Map<String, Object>) map.get(AUDIT_LOG_DSE_ENTRY)).put("enabled", true);
                    }
                } else if (isEnabled) {
                    ((Map<String, Object>) map.get(AUDIT_LOG_DSE_ENTRY)).put("enabled", false);
                }
            }

            if (logger.isInfoEnabled()) {
                logger.info("Updating dse-yaml:\n" + yaml.dump(map));
            }
            yaml.dump(map, new FileWriter(dseYaml));
        } catch (FileNotFoundException fileNotFound) {
            logger.error(
                    "FileNotFound while trying to read yaml audit log for tuning: {}", dseYaml);
        } catch (IOException e) {
            logger.error(
                    "IOException while trying to write yaml file for audit log tuning: {}",
                    dseYaml);
        }
    }