EventHandler (Oracle - Berkeley DB Java API)
Date: 2018-05-29

com.sleepycat.db

## Interface EventHandler

- All Known Implementing Classes:
    EventHandlerAdapter

      public interface EventHandler

  An interface classs with prototype definitions of all event functions that can be called via the Berkeley DB event callback mechanism.

  A user can choose to implement the EventHandler class, and implement handlers for all of the event types. Alternatively it is possible to extend the EventHandlerAdapter class, and implement only those events relevant to the specific application.

  The `EnvironmentConfig.setEventHandler` is used to provide a mechanism for reporting event messages from the Berkeley DB library to the application.

  Berkeley DB is not re-entrant. Callback functions should not attempt to make library calls (for example, to release locks or close open handles). Re-entering Berkeley DB is not guaranteed to work correctly, and the results are undefined.

- - ### Method Summary

    All Methods Instance Methods Abstract Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `handlePanicEvent()` A callback function to be called when a panic event is sent from the Berkeley DB library.
    `void` | `handleRepAutoTakeoverEvent()` A callback function to be called when a Replication automatic takeover event is sent from the Berkeley DB library.
    `void` | `handleRepAutoTakeoverFailedEvent()` A callback function to be called when a Replication automatic takeover failed event is sent from the Berkeley DB library.
    `void` | `handleRepClientEvent()` A callback function to be called when a Replication Client event is sent from the Berkeley DB library.
    `void` | `handleRepConnectBrokenEvent()` A callback function to be called when a Replication connect broken event is sent from the Berkeley DB library.
    `void` | `handleRepConnectEstablishedEvent()` A callback function to be called when a Replication connect established event is sent from the Berkeley DB library.
    `void` | `handleRepConnectTryFailedEvent()` A callback function to be called when a Replication connect retry failed event is sent from the Berkeley DB library.
    `void` | `handleRepDupmasterEvent()` A callback function to be called when a Replication Client event is sent from the Berkeley DB library.
    `void` | `handleRepElectedEvent()` A callback function to be called when an event is sent from the Berkeley DB library.
    `void` | `handleRepElectionFailedEvent()` A callback function to be called when an event is sent from the Berkeley DB library.
    `void` | `handleRepInitDoneEvent()` A callback function to be called when an event is sent from the Berkeley DB library.
    `void` | `handleRepInQueueFullEvent()` A callback function to be called when an event is sent from the Berkeley DB library.
    `void` | `handleRepJoinFailureEvent()` A callback function to be called when an event is sent from the Berkeley DB library.
    `void` | `handleRepLocalSiteRemovedEvent()` A callback function to be called when a local site removed event is sent from the Berkeley DB library.
    `void` | `handleRepMasterEvent()` A callback function to be called when an event is sent from the Berkeley DB library.
    `void` | `handleRepMasterFailureEvent()` A callback function to be called when an event is sent from the Berkeley DB library.
    `void` | `handleRepNewMasterEvent(int envId)` A callback function to be called when an event is sent from the Berkeley DB library.
    `void` | `handleRepPermFailedEvent()` A callback function to be called when an event is sent from the Berkeley DB library.
    `void` | `handleRepSiteAddedEvent()` A callback function to be called when a site added event is sent from the Berkeley DB library.
    `void` | `handleRepSiteRemovedEvent()` A callback function to be called when a site removed event is sent from the Berkeley DB library.
    `void` | `handleRepStartupDoneEvent()` A callback function to be called when an event is sent from the Berkeley DB library.
    `void` | `handleWriteFailedEvent(int errorCode)` A callback function to be called when an event is sent from the Berkeley DB library.

- - ### Method Detail

    - #### handlePanicEvent

          void handlePanicEvent()

      A callback function to be called when a panic event is sent from the Berkeley DB library.

      This event callback is received when an error occurs in the Berkeley DB library where the only solution is to shut down the application and run recovery. In such cases, the Berkeley DB methods will throw `RunRecoveryException` exceptions. It is often easier to simply exit the application when such errors occur, rather than gracefully return up the stack.

      When this callback is received the database environment has failed. All threads of control in the database environment should exit the environment and recovery should be run.

    - #### handleRepAutoTakeoverEvent

          void handleRepAutoTakeoverEvent()

      A callback function to be called when a Replication automatic takeover event is sent from the Berkeley DB library.

      This event callback is received in a replication manager subordinate process when it succeeds to take over as the replication process.

    - #### handleRepAutoTakeoverFailedEvent

          void handleRepAutoTakeoverFailedEvent()

      A callback function to be called when a Replication automatic takeover failed event is sent from the Berkeley DB library.

      This event callback is received in a replication manager subordinate process when it fails to take over as the replication process and all replication manager threads in it are stopped unexpectedly.

    - #### handleRepClientEvent

          void handleRepClientEvent()

      A callback function to be called when a Replication Client event is sent from the Berkeley DB library.

      This event callback is received when this member of a replication group is now a client site.

    - #### handleRepConnectBrokenEvent

          void handleRepConnectBrokenEvent()

      A callback function to be called when a Replication connect broken event is sent from the Berkeley DB library.

      This event callback is received when a previously established connection has been broken.

    - #### handleRepConnectEstablishedEvent

          void handleRepConnectEstablishedEvent()

      A callback function to be called when a Replication connect established event is sent from the Berkeley DB library.

      This event callback is received when a connection with a remote site has been established.

    - #### handleRepConnectTryFailedEvent

          void handleRepConnectTryFailedEvent()

      A callback function to be called when a Replication connect retry failed event is sent from the Berkeley DB library.

      This event callback is received when an attempt to establish a new connection to a known remote site failed.

    - #### handleRepDupmasterEvent

          void handleRepDupmasterEvent()

      A callback function to be called when a Replication Client event is sent from the Berkeley DB library.

      This event callback is received when a duplicate master site has been discovered in the replication group.

    - #### handleRepElectedEvent

          void handleRepElectedEvent()

      A callback function to be called when an event is sent from the Berkeley DB library.

      This event callback is received when this site has just won an election. An Application using the Base replication API should arrange for a call to the `Environment.startReplication` method after receiving this event to, reconfigure the local environment as a replication master.

      Replication Manager applications may safely igore this event. The Replication Manager calls `Environment.startReplication` automatically on behalf of the application when appropriate (resulting in firing of the `EventHandler.handleRepMasterEvent` event).

    - #### handleRepElectionFailedEvent

          void handleRepElectionFailedEvent()

      A callback function to be called when an event is sent from the Berkeley DB library.

      This event callback is received when the local site's attempt to initiate or participate in a replication master election failed, due to the lack of timely message response from a sufficient number of remote sites.

    - #### handleRepInitDoneEvent

          void handleRepInitDoneEvent()

      A callback function to be called when an event is sent from the Berkeley DB library.

      This event callback is received when internal initialization has been completed.

    - #### handleRepInQueueFullEvent

          void handleRepInQueueFullEvent()

      A callback function to be called when an event is sent from the Berkeley DB library.

      This event callback is received when replication Mananger incoming queue has reached its maximum threshold.

    - #### handleRepJoinFailureEvent

          void handleRepJoinFailureEvent()

      A callback function to be called when an event is sent from the Berkeley DB library.

      This event callback is received when the local site could not synchronize with the master because an internal initialization was required, but internal initialization has been turned off by the `ReplicationConfig.AUTOINIT` flag to `Environment.setReplicationConfig`

    - #### handleRepLocalSiteRemovedEvent

          void handleRepLocalSiteRemovedEvent()

      A callback function to be called when a local site removed event is sent from the Berkeley DB library.

      This event callback is received when the local site has been removed from the group.

    - #### handleRepMasterEvent

          void handleRepMasterEvent()

      A callback function to be called when an event is sent from the Berkeley DB library.

      This event callback is received when this site is now the master site of its replication group. It is the application's responsibility to begin acting as the master environment.

    - #### handleRepMasterFailureEvent

          void handleRepMasterFailureEvent()

      A callback function to be called when an event is sent from the Berkeley DB library.

      This event callback is received when the connection to the remote master replication site has failed.

    - #### handleRepNewMasterEvent

          void handleRepNewMasterEvent(int envId)

      A callback function to be called when an event is sent from the Berkeley DB library.

      This event callback is received when the replication group of which this site is a member has just established a new master; the local site is not the new master.

      Parameters:
        `envId` - The environment ID of the new master site.

    - #### handleRepPermFailedEvent

          void handleRepPermFailedEvent()

      A callback function to be called when an event is sent from the Berkeley DB library.

      This event callback is received when the replication manager did not receive enough acknowledgements (based on the acknowledgement policy configured with `EnvironmentConfig.setReplicationManagerAckPolicy`) to ensure a transaction's durability within the replication group. The transaction will be flushed to the master's local disk storage for durability.

    - #### handleRepSiteAddedEvent

          void handleRepSiteAddedEvent()

      A callback function to be called when a site added event is sent from the Berkeley DB library.

      This event callback is received when a new site has joined the group.

    - #### handleRepSiteRemovedEvent

          void handleRepSiteRemovedEvent()

      A callback function to be called when a site removed event is sent from the Berkeley DB library.

      This event callback is received when an existing remote site has been removed from the group.

    - #### handleRepStartupDoneEvent

          void handleRepStartupDoneEvent()

      A callback function to be called when an event is sent from the Berkeley DB library.

      This event callback is received when the client has completed startup synchronization and is now processing live log records received from the master.

    - #### handleWriteFailedEvent

          void handleWriteFailedEvent(int errorCode)

      A callback function to be called when an event is sent from the Berkeley DB library.

      This event callback is received when a Berkeley DB write to stable storage failed.

      Parameters:
        `errorCode` - If an operating system specific error code is available for the failure it will be passed in the errorCode parameter.

Copyright (c) 1996, 2018 Oracle and/or its affiliates. All rights reserved.