Uploaded image for project: 'Hive'
  1. Hive
  2. HIVE-16873

Remove Thread Cache From Logging

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • None
    • 3.0.0
    • Metastore
    • None
    • Patch

    Description

      In org.apache.hadoop.hive.metastore.HiveMetaStore we have a Formatter class (and its buffer) tied to every thread.

      This Formatter is for logging purposes. I would suggest that we simply let let the logging framework itself handle these kind of details and ditch the buffer per thread.

          public static final String AUDIT_FORMAT =
              "ugi=%s\t" + // ugi
                  "ip=%s\t" + // remote IP
                  "cmd=%s\t"; // command
          public static final Logger auditLog = LoggerFactory.getLogger(
              HiveMetaStore.class.getName() + ".audit");
          private static final ThreadLocal<Formatter> auditFormatter =
              new ThreadLocal<Formatter>() {
                @Override
                protected Formatter initialValue() {
                  return new Formatter(new StringBuilder(AUDIT_FORMAT.length() * 4));
                }
              };
      
      ...
      
          private static final void logAuditEvent(String cmd) {
            final Formatter fmt = auditFormatter.get();
            ((StringBuilder) fmt.out()).setLength(0);
      
            String address = getIPAddress();
            if (address == null) {
              address = "unknown-ip-addr";
            }
      
            auditLog.info(fmt.format(AUDIT_FORMAT, ugi.getUserName(),
                address, cmd).toString());
          }
      

      Attachments

        1. HIVE-16873.1.patch
          2 kB
          David Mollitor
        2. HIVE-16873.2.patch
          2 kB
          David Mollitor
        3. HIVE-16873.3.patch
          2 kB
          David Mollitor

        Activity

          People

            belugabehr David Mollitor
            belugabehr David Mollitor
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: