/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at
 * trunk/opends/resource/legal-notices/OpenDS.LICENSE
 * or https://OpenDS.dev.java.net/OpenDS.LICENSE.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at
 * trunk/opends/resource/legal-notices/OpenDS.LICENSE.  If applicable,
 * add the following below this CDDL HEADER, with the fields enclosed
 * by brackets "[]" replaced with your own identifying information:
 *      Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 *
 *
 *      Copyright 2008 Sun Microsystems, Inc.
 */
package org.opends.server.admin.std.server;



import java.util.SortedSet;
import org.opends.server.admin.Configuration;
import org.opends.server.admin.server.ConfigurationChangeListener;
import org.opends.server.admin.std.meta.ReplicationDomainCfgDefn.AssuredType;
import org.opends.server.admin.std.meta.ReplicationDomainCfgDefn.IsolationPolicy;
import org.opends.server.types.DN;



/**
 * A server-side interface for querying Replication Domain settings.
 * <p>
 * A Replication Domain comprises of several Directory Servers sharing
 * the same synchronized set of data.
 */
public interface ReplicationDomainCfg extends Configuration {

  /**
   * Gets the configuration class associated with this Replication Domain.
   *
   * @return Returns the configuration class associated with this Replication Domain.
   */
  Class<? extends ReplicationDomainCfg> configurationClass();



  /**
   * Register to be notified when this Replication Domain is changed.
   *
   * @param listener
   *          The Replication Domain configuration change listener.
   */
  void addChangeListener(ConfigurationChangeListener<ReplicationDomainCfg> listener);



  /**
   * Deregister an existing Replication Domain configuration change listener.
   *
   * @param listener
   *          The Replication Domain configuration change listener.
   */
  void removeChangeListener(ConfigurationChangeListener<ReplicationDomainCfg> listener);



  /**
   * Gets the "assured-sd-level" property.
   * <p>
   * The level of acknowledgment for Safe Data assured sub mode.
   * <p>
   * When assured mode configured in Safe Data mode, this value
   * defines the number of replication servers that should acknowledge
   * the sent update before the LDAP client call can return.
   *
   * @return Returns the value of the "assured-sd-level" property.
   */
  int getAssuredSdLevel();



  /**
   * Gets the "assured-timeout" property.
   * <p>
   * The timeout value when waiting for assured mode acknowledgements.
   * <p>
   * Defines the amount of milliseconds the server will wait for
   * assured acknowledgements (in either Safe Data or Safe Read assured
   * sub modes) before returning anyway the LDAP client call.
   *
   * @return Returns the value of the "assured-timeout" property.
   */
  long getAssuredTimeout();



  /**
   * Gets the "assured-type" property.
   * <p>
   * Defines the assured mode of the replicated domain.
   * <p>
   * The assured mode can be disable or enabled. When enabled, two sub
   * modes are available: Safe Data or Safe Read modes.
   *
   * @return Returns the value of the "assured-type" property.
   */
  AssuredType getAssuredType();



  /**
   * Gets the "base-dn" property.
   * <p>
   * Specifies the base DN of the replicated data.
   *
   * @return Returns the value of the "base-dn" property.
   */
  DN getBaseDN();



  /**
   * Gets the "group-id" property.
   * <p>
   * The group id associated with this replicated domain.
   * <p>
   * This value defines the group id of the replicated domain. The
   * replication system will preferably connect and send updates to
   * replicate to a replication server with the same group id as him.
   *
   * @return Returns the value of the "group-id" property.
   */
  int getGroupId();



  /**
   * Gets the "heartbeat-interval" property.
   * <p>
   * Specifies the heart-beat interval that the Directory Server will
   * use when communicating with Replication Servers.
   * <p>
   * The Directory Server expects a regular heart-beat coming from the
   * Replication Server within the specified interval. If a heartbeat
   * is not received within the interval, the Directory Server closes
   * its connection and connects to another Replication Server.
   *
   * @return Returns the value of the "heartbeat-interval" property.
   */
  long getHeartbeatInterval();



  /**
   * Gets the "isolation-policy" property.
   * <p>
   * Specifies the behavior of the Directory Server if a write
   * operation is attempted on the data within the Replication Domain
   * when none of the configured Replication Servers are available.
   *
   * @return Returns the value of the "isolation-policy" property.
   */
  IsolationPolicy getIsolationPolicy();



  /**
   * Gets the "referrals-url" property.
   * <p>
   * The URLs other LDAP servers should you to refer to us.
   * <p>
   * URLs used by peer servers of the topology to refer to us through
   * LDAP referrals. If this attribute is not defined, every URLs
   * available to access this server will be used. If defined, only
   * URLs specified here will be used.
   *
   * @return Returns an unmodifiable set containing the values of the "referrals-url" property.
   */
  SortedSet<String> getReferralsUrl();



  /**
   * Gets the "replication-server" property.
   * <p>
   * Specifies the addresses of the Replication Servers within the
   * Replication Domain to which the Directory Server should try to
   * connect at startup time.
   * <p>
   * Addresses must be specified using the syntax: hostname:port
   *
   * @return Returns an unmodifiable set containing the values of the "replication-server" property.
   */
  SortedSet<String> getReplicationServer();



  /**
   * Gets the "server-id" property.
   * <p>
   * Specifies a unique identifier for the Directory Server within the
   * Replication Domain.
   * <p>
   * Each Directory Server within the same Replication Domain must
   * have a different server ID. A Directory Server which is a member
   * of multiple Replication Domains may use the same server ID for
   * each of its Replication Domain configurations.
   *
   * @return Returns the value of the "server-id" property.
   */
  int getServerId();



  /**
   * Gets the "window-size" property.
   * <p>
   * Specifies the window size that the Directory Server will use when
   * communicating with Replication Servers.
   *
   * @return Returns the value of the "window-size" property.
   */
  int getWindowSize();

}
