net.snowflake.client.core

## Class EventHandler

- java.lang.Object
- - java.util.logging.Handler
  - - net.snowflake.client.core.EventHandler

    public class EventHandler
    extends Handler

Author:
  jrosen

### Field Summary

Fields
`protected static String` `DISABLE_DUMP_COMPR_PROP`
`protected static String` `DISABLE_DUMPS_PROP`
`protected static long` `FILE_EXPN_TIME_MS`
`protected static long` `LOG_BUFFER_SIZE`
`protected static String` `LOG_DUMP_COMP_EXT`
`protected static String` `LOG_DUMP_FILE_EXT`
`protected static String` `LOG_DUMP_FILE_NAME`
`protected static String` `MAX_NUM_DUMP_FILES_PROP`
`protected static String` `MAX_SIZE_DUMPS_MB_PROP`
`protected static String` `THROTTLE_DURATION_PROP`
`protected static String` `THROTTLE_LIMIT_PROP`

### Constructor Summary

Constructors
Constructor and Description
`EventHandler(int maxEntries, int flushPeriodMs)`

### Method Summary

All Methods Instance Methods Concrete Methods
`protected void` `cleanupSfDumps(boolean deleteOldest)` Function to remove old Snowflake Dump files to make room for new ones.
`void` `close()`
`void` `dumpLogBuffer(String identifier)` Dumps the contents of the in-memory log buffer to disk and clears the buffer.
`void` `flush()` Flushes all eventBuffer entries.
`int` `getBufferSize()` Returns current size of the event buffer
`long` `getLogBufferSize()` Returns the current size of the log buffer
`void` `publish(LogRecord record)` Overridden Logger.Handler publish(...) method.

### Methods inherited from class java.util.logging.Handler

`getEncoding, getErrorManager, getFilter, getFormatter, getLevel, isLoggable, reportError, setEncoding, setErrorManager, setFilter, setFormatter, setLevel`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Field Detail

#### LOG_BUFFER_SIZE

    protected static final long LOG_BUFFER_SIZE

See Also:
  Constant Field Values

#### FILE_EXPN_TIME_MS

    protected static final long FILE_EXPN_TIME_MS

See Also:
  Constant Field Values

#### LOG_DUMP_FILE_NAME

    protected static final String LOG_DUMP_FILE_NAME

See Also:
  Constant Field Values

#### LOG_DUMP_FILE_EXT

    protected static final String LOG_DUMP_FILE_EXT

See Also:
  Constant Field Values

#### LOG_DUMP_COMP_EXT

    protected static final String LOG_DUMP_COMP_EXT

See Also:
  Constant Field Values

#### THROTTLE_DURATION_PROP

    protected static final String THROTTLE_DURATION_PROP

See Also:
  Constant Field Values

#### THROTTLE_LIMIT_PROP

    protected static final String THROTTLE_LIMIT_PROP

See Also:
  Constant Field Values

#### DISABLE_DUMPS_PROP

    protected static final String DISABLE_DUMPS_PROP

See Also:
  Constant Field Values

#### MAX_NUM_DUMP_FILES_PROP

    protected static final String MAX_NUM_DUMP_FILES_PROP

See Also:
  Constant Field Values

#### MAX_SIZE_DUMPS_MB_PROP

    protected static final String MAX_SIZE_DUMPS_MB_PROP

See Also:
  Constant Field Values

#### DISABLE_DUMP_COMPR_PROP

    protected static final String DISABLE_DUMP_COMPR_PROP

See Also:
  Constant Field Values

### Constructor Detail

#### EventHandler

    public EventHandler(int maxEntries,
                        int flushPeriodMs)

### Method Detail

#### getBufferSize

    public int getBufferSize()

Returns current size of the event buffer

Returns:
  size of eventBuffer

#### getLogBufferSize

    public long getLogBufferSize()

Returns the current size of the log buffer

Returns:
  size of log buffer

#### dumpLogBuffer

    public void dumpLogBuffer(String identifier)

Dumps the contents of the in-memory log buffer to disk and clears the buffer.

Parameters:
  `identifier` - event id

#### cleanupSfDumps

    protected void cleanupSfDumps(boolean deleteOldest)

Function to remove old Snowflake Dump files to make room for new ones.

Parameters:
  `deleteOldest` - if true, always deletes the oldest file found if max number of dump files has been reached

#### flush

    public void flush()

Flushes all eventBuffer entries.

Specified by:
  `flush` in class `Handler`

#### publish

    public void publish(LogRecord record)

Overridden Logger.Handler publish(...) method. Buffers unformatted log records in memory in a circular buffer-like fashion.

Specified by:
  `publish` in class `Handler`
Parameters:
  `record` - log record

#### close

    public void close()

Specified by:
  `close` in class `Handler`