StateChangeListener (Oracle - Berkeley DB Java Edition API)
Date: 2014-12-16

com.sleepycat.je.rep

## Interface StateChangeListener

-     public interface StateChangeListener

  An asynchronous mechanism for tracking the `State` of the replicated environment and choosing how to route database operations. `State` determines which operations are currently permitted on the node. For example, only the `MASTER` node can execute write operations.

  The Listener is registered with the replicated environment using `ReplicatedEnvironment.setStateChangeListener(StateChangeListener)`. There is at most one Listener associated with the actual environment (not an `Environment` handle) at any given instance in time.

  See the examples for information on different approaches toward routing database operations and an example of using the StateChangeListener.

  See Also:
    Managing Write Requests at a Replica

- - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `stateChange(StateChangeEvent stateChangeEvent)` The notification method.

- - ### Method Detail

    - #### stateChange

          void stateChange(StateChangeEvent stateChangeEvent)
                           throws RuntimeException

      The notification method. It is initially invoked when the `StateChangeListener` is first associated with the `ReplicatedEnvironment` via the `ReplicatedEnvironment.setStateChangeListener(StateChangeListener)` method and subsequently each time there is a state change.

      This method should do the minimal amount of work, queuing any resource intensive operations for processing by another thread before returning to the caller, so that it does not unduly delay the other housekeeping operations performed by the internal thread which invokes this method.

      Parameters:
        `stateChangeEvent` - the new state change event
      Throws:
        `RuntimeException` - Any uncaught exceptions will result in the shutdown of the ReplicatedEnvironment.

Copyright (c) 2004, 2014 Oracle and/or its affiliates. All rights reserved.