001/*
002 * CDDL HEADER START
003 *
004 * The contents of this file are subject to the terms of the
005 * Common Development and Distribution License, Version 1.0 only
006 * (the "License").  You may not use this file except in compliance
007 * with the License.
008 *
009 * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
010 * or http://forgerock.org/license/CDDLv1.0.html.
011 * See the License for the specific language governing permissions
012 * and limitations under the License.
013 *
014 * When distributing Covered Code, include this CDDL HEADER in each
015 * file and include the License file at legal-notices/CDDLv1_0.txt.
016 * If applicable, add the following below this CDDL HEADER, with the
017 * fields enclosed by brackets "[]" replaced with your own identifying
018 * information:
019 *      Portions Copyright [yyyy] [name of copyright owner]
020 *
021 * CDDL HEADER END
022 *
023 *      Copyright 2013-2014 ForgeRock AS.
024 */
025
026package org.forgerock.opendj.ldap;
027
028import java.util.EventListener;
029
030/**
031 * An object that registers to be notified when a connection factory associated
032 * with a load-balancer changes state from offline to online or vice-versa.
033 * <p>
034 * <b>NOTE:</b> load-balancer implementations must ensure that only one event is
035 * sent at a time. Event listener implementations should not need to be thread
036 * safe.
037 */
038public interface LoadBalancerEventListener extends EventListener {
039
040    /**
041     * Invoked when the load-balancer is unable to obtain a connection from the
042     * specified connection factory. The connection factory will be removed from
043     * the load-balancer and monitored periodically in order to determine when
044     * it is available again, at which point an online notification event will
045     * occur.
046     *
047     * @param factory
048     *            The connection factory which has failed.
049     * @param error
050     *            The last error that occurred.
051     */
052    void handleConnectionFactoryOffline(ConnectionFactory factory, LdapException error);
053
054    /**
055     * Invoked when the load-balancer detects that a previously offline
056     * connection factory is available for use again.
057     *
058     * @param factory
059     *            The connection factory which is now available for use.
060     */
061    void handleConnectionFactoryOnline(ConnectionFactory factory);
062}