code: public static SerializedRecord anonymize(SerializedRecord sr)
        throws Exception {
  
      String hostname = sr.get("hostname");
  
      if (hostname == null)
        throw new Exception("Malformed SerializedRecord: no hostname found");
  
      if ("true".equalsIgnoreCase(Environment
          .getProperty("anonymizer.hash.hostnames"))) {
        // hash the node's hostname
        anonymizeField(sr, "message", hostname, "_hn_");
        anonymizeField(sr, "hostname", hostname, "_hn_");
        // hash all other hostnames
        String suffix = Environment.getProperty("anonymizer.hostname.suffix");
        if (suffix != null)
          anonymizeField(sr, "message", "(\\S+\\.)*" + suffix, "_hn_");
      }
  
      if ("true".equalsIgnoreCase(Environment.getProperty("anonymizer.hash.ips"))) {
        // hash all ip addresses
        String ipPattern = "(\\d{1,3}\\.){3}\\d{1,3}";
        anonymizeField(sr, "message", ipPattern, "_ip_");
        anonymizeField(sr, "ips", ipPattern, "_ip_");
        // if multiple ips are present for a node:
        int i = 0;
        while (sr.get("ips" + "#" + i) != null)
          anonymizeField(sr, "ips" + "#" + i++, ipPattern, "_ip_");
  
        if ("NIC".equalsIgnoreCase(sr.get("type")))
          anonymizeField(sr, "ipAddress", ipPattern, "_ip_");
      }
  
      if ("true".equalsIgnoreCase(Environment
          .getProperty("anonymizer.hash.filenames"))) {
        // hash every filename present in messages
        anonymizeField(sr, "message", "\\s+/(\\S+/)*[^:\\s]*", " _fn_");
        anonymizeField(sr, "message", "\\s+hdfs://(\\S+/)*[^:\\s]*",
            " hdfs://_fn_");
      }
  
      return sr;
    }
docs: Anonymize hostnames, ip addresses and file names/paths
  that appear in fields of a SerializedRecord.
  
  @param sr the input SerializedRecord
  
  @return the anonymized SerializedRecord