/**
  * File: 		DomainGroupHandler.java
  * Content: 	part of the RMI specification of sensei domains
  *           GroupMember targetted as central instance to handle several subgroups
  *           Messages sent through this class must belong to the DomainMessage hierarchy
  *
  *           -	It allows to define several subgroups to be handled separately by one group.
  *           - The subgroups can be created/removed dynamically.
  *           -	It includes the abstraction group/subgroups or domain/groups
  *           It supports several special features:
  *           -The sending of messages blocks the caller until the message is received
  *           -Reception of cast messages sent by the own member are not propagated to the
  *            subgroups: they just unblock the message sending.
  *           -PTP messages can be sent to all the subgroups in the group
  *           -State transfer support
  *           -Replica properties support
  * Author: 	LuisM Pena
  * Date: 		27th October 2001
  * Version:  0.51.00
  * Last change:
  *
  **/


package sensei.middleware.domains;

import sensei.middleware.gms.GroupHandler;
import sensei.middleware.gms.GroupMember;

import java.rmi.Remote;
import java.rmi.RemoteException;

/**
  * GroupMember targetted as central instance to handle several subgroups
  * Messages sent through this class must belong to the DomainMessage hierarchy
  *
  * -	It allows to define several subgroups to be handled separately by one group.
  * -	The subgroups can be created/removed dynamically.
  * -	It includes the abstraction group/subgroups or domain/groups
  * It supports several special features:
  * -	The sending of messages blocks the caller until the message is received
  * -	Reception of cast messages sent by the own member are not propagated to the
  *  subgroups: they just unblock the message sending.
  * -	PTP messages can be sent to all the subgroups in the group
  * -	State transfer support
  * -	Replica properties support
  * - Transactions support
  */
public interface DomainGroupHandler
  extends GroupHandler, GroupMember, PropertiesHandler, SubgroupsHandler, TransactionsHandler
{
  /**
   * Sets the mode under view changes. It can only be set before the domain Group Handler joins a group,
   * or an exception is thrown
   */
  public void setBehaviourMode(BehaviourOnViewChanges mode) throws MemberStateException, RemoteException;

  /**
   * Sets a coordinator elector. It must be set before the DomainGroupHandler joins a group, or an
   * exception is raised
   */
  public void setCoordinatorElector(CoordinatorElector elector) throws MemberStateException, RemoteException;

  /**
   * Sets a listener to DomainGroup events. It must be set before the DomainGroupHandler joins a group, or an
   * exception is raised
   */
  public void setDomainGroupUser(DomainGroupUser user) throws MemberStateException, RemoteException;

  /**
   * Returns the list of stateful members. This operation can only be invoked on stateful members,
   * or an exception is thrown
   */
  public int[] getStatefulMembers() throws MemberStateException, RemoteException;

  /**
    * Cast a message to the subgroup, and blocks until it is processed.
    * @param normalProcessing set to true if the message is to be received through the normal
    *        processCastMessage. In that case, this call blocks until the message is processed.
    *        If it is false, the call blocks until the caller can process the operation, and
    *        when it finishes, it must call to syncCastDomainMessageProcessed
    **/
  public boolean syncCastDomainMessage(DomainMessage message, boolean normalProcessing)
    throws MemberStateException, RemoteException;

  /**
    * Confirms that a message has been processed. Failing to call to this method after
    *   requesting syncCastDomainMessage with normalProcessing equal to false will avoid the
    *   normal flow of messages into the application, excluding eventually the member from the group
    **/
  public void syncCastDomainMessageProcessed()
    throws MemberStateException, SyncCastDomainMessageProcessedException,RemoteException;
}